Hierarchy problem :-(

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

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

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