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
    • Recent
    • Tags
    • Users
    • Login

    InsertObject with existing BaseObjects

    Scheduled Pinned Locked Moved SDK Help
    5 Posts 0 Posters 419 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/07/2010 at 12:37, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:   11.514 
      Platform:      
      Language(s) :     C++  ;

      ---------
      Hello,

      I am writing a plugin to save and restore geometry groupings in the BaseDocument for a major visual effect studio in Los Angeles.

      The reason being is that our texture artists have to regroup their geometry for each new model version they receive to paint. I have created a plugin which saves the hierarchy to an xml file and can restore it.

      I am having an issue with using BaseObject::InsertUnder(BaseObject * ) with existing BaseObjects in the scene.
      Basically, I am trying to move existing polygon shapes / Null objects to new locations in the scenegraph.

      After I call
      obj- >InsertUnder( parentObj );
      the object lives in 2 locations in the scenegraph, it's original location and the new spot.
      When you select either of the same name objects, both are highlighted.
      If you attempt to move the NULL objects above,  c4d crashes. It only becomes stable, if I manually parent the 'old location' object to it's new location. Then, I am left with only one object in the proper location.

      The other issue is after I call 'obj- >InsertUnder( parentObj );', and get 2 copies of obj,
      if I attempt to traverse the scenegraph (w obj- >GetNext() / obj->GetDown ),
      I have a circular loop in the graph.

      ###############

      I am wondering if I need to issue a command to trigger the BaseDocument to refresh or flush the object from its original location.

      I have tried this : **
      obj- >InsertUnder( parentObj );
      obj->Message(MSG_UPDATE);
      doc->Message(MSG_UPDATE);
      doc->SetChanged();
      EventAdd(); **

      with no luck.

      I have also tried adding Undos :
      **
      StopAllThreads();
      doc->StartUndo();
      doc->AddUndo(UNDO_NEW, returnObj);//add an undo for the insertion
      doc->EndUndo();**

      but, no luck.

      Is there something that I'm missing?
               
      ################

      Please note, this is only w/ existing objects.
      If I Alloc a new object, I am able to parent it with InsertObject / InsertUnder just fine.

      Thanks for the 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 15/07/2010 at 14:55, xxxxxxxx wrote:

        Howdy,

        Originally posted by xxxxxxxx

        ...I am trying to move existing polygon shapes / Null objects to new locations in the scenegraph. After I call
        obj- >InsertUnder( parentObj );
        the object lives in 2 locations in the scenegraph, it's original location and the new spot....

        Hmmmm, did you first remove the object from its original location with:

        obj->Remove();
        

        ... before trying to insert it in the new location?

        Adios,
        Cactus Dan

        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/07/2010 at 15:29, xxxxxxxx wrote:

          No, I did not try that.
          So, using InsertUnder actually makes a new object?
          I see....

          Thanks for the response - let me try it out.

          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/07/2010 at 15:40, xxxxxxxx wrote:

            That's it, sir. Works like a charm!

            I didn't realize that everytime you call an 'Insert' command you build a copy of the object in the document. Interesting...

            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/07/2010 at 15:41, xxxxxxxx wrote:

              Howdy,

              No. InsertUnder() doesn't make a new object. Using InsertUnder() on an existing object without first removing it with Remove() causes a discrepancy in where the object is really located, and that's probably why Cinema 4D crashed on you.

              You must always remove an object first from it's current location in a hierarchy before inserting it into another hierarchy. Using obj->Remove() only removes the object from its current hierarchy, but the object is still in memory.

              Adios,
              Cactus Dan

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