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

    Replace objects with Null objects

    Scheduled Pinned Locked Moved SDK Help
    2 Posts 0 Posters 393 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 14/10/2009 at 16:01, xxxxxxxx wrote:

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

      ---------
      Is there a quick or sane way to replace selected objects (possibly within a hierarchy with children) with Null objects?

      This is part of my generator plugin which may or may not return the original cloned objects and the results childed to them. I use GetAndCheckHierarchyClone(..., TRUE) which returns a Null object with the clones childed. Then generated objects are childed to the clones. If the user disables an option to retain the clones in the generated result, those clones need to be replaced by Null objects so as to retain the transforms and hierarchical relationships. For instance:

      Plugin
      - Op1
      -- Op2
      - Op3
      - Op4

      Should be, when replacing with Null objects:

      Plugin
      - Null1
      -- Res1
      -- Null2
      --- Res2
      - Null3
      -- Res3
      - Null4
      -- Res4

      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 14/10/2009 at 18:44, xxxxxxxx wrote:

        This works. It is extremely tricky in-place manipulation of the hierarchy so hopefully this works in general cases:

        > // NullifyClones \> // - Replace all child clones with Null objects \> //\*---------------------------------------------------------------------------\* \> Bool NullifyClones(BaseObject\* op) \> //\*---------------------------------------------------------------------------\* \> { \>      BaseObject\*     onull; \>      BaseObject\*     cop; \>      BaseObject\* nop; \>      for (; op; op = nop) \>      { \>           nop =          op->GetNext(); \>           if (!op->GetBit(BIT_ACTIVE)) continue; \>           onull =          BaseObject::Alloc(Onull); \>           if (!onull)     return FALSE; \>           onull->SetName(op->GetName()); \>           onull->SetMl(op->GetMl()); \>           onull->InsertAfter(op); \>           for (cop = op->GetDown(); cop; cop = nop) \>           { \>                nop =     cop->GetNext(); \>                cop->Remove(); \>                cop->InsertUnderLast(onull); \>           } \>           op->Remove(); \>           blDelete(op); \>           // Recurse to children \>           if (onull->GetDown()) \>           { \>                if (!NullifyClones(onull->GetDown()))     return FALSE; \>           } \>           nop =          onull->GetNext(); \>      } \>      return TRUE; \> }

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