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

    How does InsertObject work [SOLVED]

    SDK Help
    0
    3
    298
    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
      Helper
      last edited by

      On 17/07/2015 at 16:03, xxxxxxxx wrote:

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

      ---------
      Hello,

      I'm getting crazy. I want to cut an object and insert it as an child to an null object. Here's my code:

      BaseObject* op = doc->GetFirstObject();  
      BaseObject* wallsNull = BaseObject::Alloc(Onull);  
      wallsNull->SetName("UE4Ex_Walls");  
      doc->InsertObject(wallsNull,nullptr,nullptr);  
      doc->InsertObject(op,wallsNull,nullptr);
      

      After executing this, my whole objects of the scene are inside the "wallsNull" and not only the first one. Also cinema freezes.
      What I'm doing wrong?

      Edit: Cinema doesn't freeze but I can't close it.

      Thanks

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

        On 17/07/2015 at 16:20, xxxxxxxx wrote:

        You can only insert a new object once into the document.  If you want it to be at the root, use the first doc->ObjectInsert() call.  The second call is gibberish. You cannot insert op underneath the object your are inserting.  If you want that then you have to remove op and insert under it:

        doc->InsertObject(wallsNull, nullprt, nullptr);
        op->Remove();
        doc->InsertObject(op, wallsNull, nullptr);
        

        So, removing op frees it from the document's hierarchical chain so that you can then reinsert it into the document where you want in that hierarchy.  Understand?

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

          On 17/07/2015 at 16:30, xxxxxxxx wrote:

          Thank you so much!!! I understand and it works now 🙂

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