So it's my first time writing a python script for Blender so I may not be entirely familiar with the API but I know enough python to code something. I'm trying to find an armature in code that is the child of an object.

object = bpy.data.objects['Armature']

for obj in bpy.data.objects:
    if(obj.parent == object):
        if(obj.type == 'ARMATURE'):
            armatureTo = obj.data

From what I've read online, that should work. It's getting the object with name Armature, which is the parent object I mentioned. Then iterating through the objects in the scene and checking if the parent objects and object types match with the armature I want and setting the variable to that object.

I'd greatly appreciate any help you can give me.


1 Answer 1


Look at the objects children

Instead of looking for objects with that parent, loop over that objects children. All objects in a blend are in bpy.data.objects which may or may not be linked to a collection in the context scene. Recommend working from scene rather than data, when applicable.

If the armature object "Armature" is in the scene iterate over its children.

import bpy

scene = bpy.context.scene
ob = scene.objects.get("Armature")

if ob:
    for c in ob.children:
        print(c.name, c.type)

To iterate over all objects in scene

for o in context.scene.objects:
    if o.parent == ob:
        print(o.name, o.type)

Do not confuse an object ss being the parent of its data. The default armature object named "Armature"

enter image description here

The object (yellow with my theme)

>>> C.object

has the data part (green)

>>> C.object.data

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .