Skip to content

Instantly share code, notes, and snippets.

@mp5gosu
Created February 2, 2021 17:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mp5gosu/c99a7acf018426b8700122d4a65eaf87 to your computer and use it in GitHub Desktop.
Save mp5gosu/c99a7acf018426b8700122d4a65eaf87 to your computer and use it in GitHub Desktop.
Cinema 4D Hierarchy Iterator helper for iterating over all object
def GetNextObject(op, op_stop=None):
"""
Hierarchy iteration helper from https://developers.maxon.net/?p=596
:param op_stop: The object to stop at. Returns None when this object is found.
:type op_stop: c4d.BaseObject
:param op: the object to get the next node from
:return: The next object
"""
if op is None:
return None
if op.GetDown():
return op.GetDown()
while not op.GetNext() and op.GetUp():
op = op.GetUp()
if op == op_stop:
return None
if op == op_stop:
return None
return op.GetNext()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment