import c4d
def crawl_and_collect_objects(obj, object_list, depth=0):
object_list.append(obj)
child = obj.GetDown()
while child:
crawl_and_collect_objects(child, object_list, depth + 1)
child = child.GetNext()
def main_2():
doc = c4d.documents.GetActiveDocument()
if doc is None:
return
active_object = doc.GetActiveObject()
if active_object is None:
return
object_list = []
crawl_and_collect_objects(active_object, object_list)
print("Collected Objects:")
for obj in object_list:
print(obj.GetName())
cube = c4d.BaseObject(c4d.Ocube)
cube.InsertUnder(obj)
doc.InsertObject(cube)
c4d.EventAdd()
def main():
obj_list = doc.GetActiveObjects(1)
for obj in obj_list:
cube = c4d.BaseObject(c4d.Ocube)
cube.InsertUnder(obj)
doc.InsertObject(cube)
c4d.EventAdd()
if __name__=='__main__':
main()