Replace objects with Null objects



  • 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



  • 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; \> }


Log in to reply