Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    object GetName and setName?

    Scheduled Pinned Locked Moved SDK Help
    16 Posts 0 Posters 1.2k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      Helper
      last edited by

      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

      On 15/08/2007 at 21:13, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:   rease9.5 
      Platform:   Windows  ;   
      Language(s) :     C++  ;

      ---------
      I want to get or set the name of object from the basic propjecties in the object's  attributes plant when I  will be  adding  new object to scene . how do I to do? help me please?

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

        On 15/08/2007 at 22:27, xxxxxxxx wrote:

        obj->SetName() and obj->GetName(). These methods are part of the BaseList2D class from which most Cinema 4D 'objects' (objects, tags, materials, shaders, document, tracks, sequences, keys,...) are derived.

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

          On 16/08/2007 at 04:27, xxxxxxxx wrote:

          the result was nothing(can't get any name string from object) when I have been debug the function as obj->getname();  and break me program by obj->setname(...)

          1 Reply Last reply Reply Quote 0
          • H Offline
            Helper
            last edited by

            THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

            On 16/08/2007 at 05:01, xxxxxxxx wrote:

            cannot confirm. Works as always without any problems. Please post a code snippet of your routine.

            1 Reply Last reply Reply Quote 0
            • H Offline
              Helper
              last edited by

              THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

              On 16/08/2007 at 07:42, xxxxxxxx wrote:

              Code would be most helpful to see what you're doing.

              1 Reply Last reply Reply Quote 0
              • H Offline
                Helper
                last edited by

                THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                On 16/08/2007 at 18:56, xxxxxxxx wrote:

                this is my addcamera section code:
                ......
                String camname;
                 BaseDocument* doc = GetActiveDocument();
                 if (!doc) return false;
                  
                    BaseObject* null = BaseObject::Alloc(Onull);
                    if (!null)
                 {
                  return false;
                 }
                    doc->InsertObject(null, NULL, NULL, TRUE);

                CameraObject* cam = (CameraObject* )BaseObject::Alloc(Ocamera);
                  
                 if ( !cam )
                 {
                  MessageDialog("CameraObject Create Fail!");
                  return false;
                 }
                 //set camera name
                    Bool bFindResult = TRUE;
                    LONG Id_Cam = 1;
                 while ( bFindResult )
                 { 
                  if (nTypeObj == 0)
                  {
                   camname = String("0_TSPCam"+ LongToString(Id_Cam));
                  }
                  else
                  {
                   camname = String("1_TSPCam"+ LongToString(Id_Cam));
                  }
                  BaseObject* camobj = doc->SearchObject( camname );
                  if ( !camobj )
                  {
                   bFindResult = FALSE;
                   //set camera name
                   cam->SetName(camname);          ///====> Break My Programe and exit c4d
                  }
                  else
                  {
                   ++Id_Cam;
                  }
                }

                doc->InsertObject(cam, NULL, NULL, TRUE);
                ......
                }

                1 Reply Last reply Reply Quote 0
                • H Offline
                  Helper
                  last edited by

                  THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                  On 16/08/2007 at 20:53, xxxxxxxx wrote:

                  Have you tried:

                  CameraObject* cam = CameraObject::Alloc();

                  ??

                  Otherwise, I don't see the reason for the problem offhand. Have you commented out code to see exactly where the crash occurs - instead of debug breakpoints? Hate to be snobbish, but I find that differences between debug and non-debug can themselves introduce inconsistencies. I will only build debug if ABSOLUTELY necessary because of this long-standing discrepancy! Nothing more degrading than hunting a ghost bug due to crappy debug support (i.e.: Windows!) - been there, did it enough to know better. 😉

                  1 Reply Last reply Reply Quote 0
                  • H Offline
                    Helper
                    last edited by

                    THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                    On 17/08/2007 at 01:54, xxxxxxxx wrote:

                    Hi,

                    This line cannot work:
                    BaseObject* camobj = doc->SearchObject( camname );

                    The Camera is not yet in the document! You first need to insert it into the document before you can search for it in the doc. So just after alloc:

                    doc->InsertObject(cam,NULL,NULL,FALSE);

                    And you can set the name of the camera directly with the pointer. Why do you search for it first???

                    BaseObject* camobj = doc->SearchObject( camname )
                    is the same as "CameraObject *cam".
                    Simply do:

                    CameraObject* cam = (CameraObject* )BaseObject::Alloc(Ocamera);  
                    if(!cam) return;  
                    doc->InsertObject(cam,NULL,NULL,FALSE);  
                    cam->SetName("the name you want");
                    

                    There is no need to search for it. If it´s allocated and you got a valid pointer, the pointer will....tata...point at it. 😉 So, you can directly work with the pointer.

                    1 Reply Last reply Reply Quote 0
                    • H Offline
                      Helper
                      last edited by

                      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                      On 17/08/2007 at 03:44, xxxxxxxx wrote:

                      I think that he is searching for an already existing camera in the document before adding the new one.

                      1 Reply Last reply Reply Quote 0
                      • H Offline
                        Helper
                        last edited by

                        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                        On 17/08/2007 at 03:55, xxxxxxxx wrote:

                        *doh* of course. 😄 I was focusing on that camera and thought "why the hell is he seeking for it and not simply inserting it?". LOL thanks for clearing that up Kuro. 🙂

                        well, the code seems ok to me then. Allocation should also call the appropriate constructor of CameraObject. At least it works just fine for me.

                        Time to start the weekend...without code! 🙂

                        1 Reply Last reply Reply Quote 0
                        • H Offline
                          Helper
                          last edited by

                          THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                          On 19/08/2007 at 18:28, xxxxxxxx wrote:

                          Who can give me a new C++ sdk for release 9.5 ?  I want to replace the old one and have a try?

                          1 Reply Last reply Reply Quote 0
                          • H Offline
                            Helper
                            last edited by

                            THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                            On 19/08/2007 at 19:37, xxxxxxxx wrote:

                            Can't really help much there. I'm using VS 6.0 for Windows 32-bit plugins and don't have an R9.5 api lib. I do 8.2, 8.5, 9.1, 9.6, and 10.1 only due to feature support differences.

                            Are you getting any warnings or errors during build of the api library or your plugin project?

                            One thing that you may want to try is setting the name after inserting the camera into the document:

                                 String camname;  
                              
                                 BaseDocument* doc = GetActiveDocument();  
                                 if (!doc) return false;  
                                    
                                 BaseObject* null = BaseObject::Alloc(Onull);  
                                   
                                 if (!null)  
                                 {  
                                      return false;  
                                 }  
                                   
                                 doc->InsertObject(null, NULL, NULL, TRUE);  
                                   
                                 CameraObject* cam = (CameraObject* )BaseObject::Alloc(Ocamera);  
                                    
                                 if ( !cam )  
                                 {  
                                      MessageDialog("CameraObject Create Fail!");  
                                      return false;  
                                 }  
                                   
                                 //set camera name  
                                 LONG Id_Cam = 1;  
                                 BaseObject*     camobj;  
                                 for (;;)  
                                 {   
                                      if (nTypeObj == 0)  
                                      {  
                                           camname = String("0_TSPCam"+ LongToString(Id_Cam));  
                                      }  
                                      else  
                                      {  
                                           camname = String("1_TSPCam"+ LongToString(Id_Cam));  
                                      }  
                                      camobj = doc->SearchObject( camname );  
                                   
                                      if ( !camobj )  
                                      {  
                                           break;  
                                      }  
                                      else  
                                      {  
                                           ++Id_Cam;  
                                      }  
                                 }  
                              
                                 doc->InsertObject(cam, NULL, NULL, FALSE);  
                                 //set camera name  
                                 cam->SetName(camname);  
                              
                            ......  
                              
                            }
                            

                            Also note that instead of wasting a variable for a basically 'infinite loop', you can just break the loop and set the name as shown. I'd also pull the BaseObject* camobj declaration outside of the loop just for memory and speed purposes - just reuse the variable in the loop, but declare it once just before the loop. You've also already established that no other has the name, so you can use FALSE for the InsertObject() argument.

                            1 Reply Last reply Reply Quote 0
                            • H Offline
                              Helper
                              last edited by

                              THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                              On 19/08/2007 at 20:08, xxxxxxxx wrote:

                              Hi Robert ( Kuroyume s DevelopmentZone), I'm using .net2003 for Windows 32-bit plugins and api lib(_api_v8_rel.lib), can you give me c++ sdk and api lib for the 9.1 or 10.1? thank you for your help.

                              1 Reply Last reply Reply Quote 0
                              • H Offline
                                Helper
                                last edited by

                                THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                                On 20/08/2007 at 06:08, xxxxxxxx wrote:

                                when my program execute to obj->getname();but it raise error and crash c4d application.  cinema4d.exe-application error: then instruction at "0x0081a299" reference memory at "0x00000004". then memory could not be "read".  click on ok to terminate the program; click on Cancel to debug the program. 
                                and my  program execute to obj->SetName("name") but it raise error and crash c4d application.  cinema4d.exe-application error: then instruction at "0x0081c2e2" reference memory at "0x00000000". then memory could not be "read".  click on ok to terminate the program; click on Cancel to debug the program. 
                                can anyone help for me?  
                                thanks.

                                1 Reply Last reply Reply Quote 0
                                • H Offline
                                  Helper
                                  last edited by

                                  THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                                  On 20/08/2007 at 08:04, xxxxxxxx wrote:

                                  These instructions are of no help, except for the fact that you are most probably trying to access a null-pointer (that´s what the zeros tell you). And when it happens at this exact function call, then I´d say that "obj" is not a valid pointer.

                                  So, you should look at why obj may not be there in order to fix your problem.

                                  Hope that helps

                                  1 Reply Last reply Reply Quote 0
                                  • H Offline
                                    Helper
                                    last edited by

                                    THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                                    On 20/08/2007 at 10:30, xxxxxxxx wrote:

                                    Not much that I can do to help with the api library as I don't have .net2003, but instead VS6.0 (32-bit) and VS 2005 Pro (strictly for 64-bit plugin builds). 10.1 wouldn't help as you can't run them in R9.5. 🙂

                                    Which version of .net are you using (Express, Pro, other)? You may want to thoroughly check your plugin build settings against the cinema4dsdk project build settings to make sure that they agree where they must. I always build the api libraries from the cinema4dsdk project and use those in my builds instead of rebuilding the api library every time. I also copy the Resource folder to a data disk and develop plugins from there instead of in the actual Cinema 4D install. You can use Post-build commands to copy the necessary files and run Cinema 4D on successful builds.

                                    You can download the R9.5 resource libs from my site:

                                    http://www.kuroyumes-developmentzone.com/c4d/Resource_9.5.zip

                                    These are built with VS6.0 so may not work.

                                    1 Reply Last reply Reply Quote 0
                                    • First post
                                      Last post