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

    Hierarchy problem :-(

    SDK Help
    0
    3
    614
    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

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

      On 22/12/2002 at 10:58, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:   8.014 
      Platform:    Mac  ;  
      Language(s) :   C.O.F.F.E.E  ;

      ---------
      Well, let's see if I can explain this in a simple way:

      I have a routine that goes through all objects in a document, recursively (thank you Mikael for it 😉
      Each object that matches a criteria is affected by an action.
      My problem is when the action is deleting the objects
      If two objects in a row (meaning one following another) meet the criteria, only the first one is deleted.
      I believe this is due to the fact that the recursive routine calls the deletion routine and the next thing it does it to recursively call itself with object->GetNext( ), so it skips one object.
      I tried doint a conditional reculsive call with just object (no ->GetNext( )) whenever the action is deletion but I get stack overflows.
      Can anyone help me?
      I can provide a listing.
      Thank you very much in advance.

      Rui Batista

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

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

        On 24/12/2002 at 01:26, xxxxxxxx wrote:

        Ok, I solved it.
        I believe this is not the most elegant method (and not the fastest) but it works.
        To anyone else who encounters such a problem I explain my solution:

        I created an empty string to which I add the name of each object I need to delete, followed by a non-ASCII character, as a separator.
        After creating the string, one cycle removes each name from inside the string and performs a FindObject( ) for it and consequent object->Remove( ). The cycle goes on until the string is empty.
        Not elegant, but it works 😉

        Rui Batista

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

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

          On 24/12/2002 at 04:41, xxxxxxxx wrote:

          Was this a cruel way to make me reply? I cannot let such a "solution" pass by unchallenged... 😉
          This is a basic tree traversal problem. Unless I've misunderstood what you're doing, it should be trivial to modify David's code:

              
              
              ProcessHierarchy(obj)  
              {  
                while(obj)  
                {  
                  var next = obj->GetNext();  
                  if (IsToBeDeleted(obj))  
                  {  
                    obj->Remove();  
                  }  
                  else  
                  {  
                    ProcessHierarchy(obj->GetDown());  
                  }  
                  obj = next;  
                }  
              }
          
          1 Reply Last reply Reply Quote 0
          • First post
            Last post