Recently i have come across the need to create a heirachy of objects in blender (like the OOPS Schematic).
However, it appears that the Object class only supports getting the parent of an object (getParent()), not getting its children which i need to do.
For the moment though, i have come up with this function to get the children of an object :
Code: Select all
def getChildren(obj):
children = []
for ob in Blender.Object.Get():
if ob.getParent() == obj:
children.append(ob)
if len(children) != 0: return children
else: return None
Code: Select all
def printChildren(obj,level=0):
children = getChildren(obj)
if children == None: return
else:
for child in children:
print "%s%s" % (" "*level, child.getName())
printChildren(child,level+1)
print "Children of your object :"
printChildren(Blender.Object.Get("My Object"))