Jump to content

thunderdoc

Little help about recursive hierarchy

Recommended Posts

Hi,

I'm struggling a bit with recursive hierarchy iteration, I don't fully understand how it work but at least I can make it work in the entire object manager.

 

But now I'd like to iterate thought all the child objects of the selected object only, like this:

8TEvFpv.png

 

 

Here's my code:

objchildren = [] #list of selected objs

def recur_iter(obj):
    while obj:
        objchildren.append(obj)
        recur_iter(obj.GetDown())
        obj = obj.GetNext()

        
def main():
    recur_iter(doc.GetActiveObject())

 

Currently, this is selecting every object under the object I've selected, it's not stopping in the Sphere.3.

I also tried changing obj = obj.GetNext() to GetPredGetDown, and even removing this line (which causes C4D to crash, lol)

 

So, anyone cal help me to understand the theory behind a simple recursive hierarchy iteration code ? I watched and read all the tutorials in the web, but I can't understand yet :/

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

YOUTUBE CHANNEL:

ABOUT US:

C4D Cafe is the largest CINEMA 4D community. We provide facilities for discussion, showcasing and learning our favorite software :) Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, get your own private messenger, post status updates, manage your profile and much more. If you need to find solution to your problem or otherwise ask for help, Cafe is the right place.
×
×
  • Create New...