So I've been a programmer for a long time, and a modeler for a while now, and I've just gotten started on using Python in Blender. One thing bugs me about the interface and I'm hoping I'm just overlooking it.
To select an object of name 'Sphere', we would use code like this:
bpy.data.objects['Sphere']
And if 'Sphere' has a single child object, named, say, 'Cube', then we would do this:
bpy.data.objects['Sphere'].children[0]
but unfortunately, this would not work:
bpy.data.objects['Sphere'].children('Cube')
Nor this, which would be even more ideal:
bpy.data.objects['Sphere/Cube']
However, this would still work:
bpy.data.objects['Cube']
with the additional restraint that no two objects, regardless of relative location, can have the same name.
Is it even possible to find something by scene graph path like that?
bpy.context.scene.objects['Cube']orbpy.context.scene.objects.get("Cube"). Consider if you run it, there is nothing selected it is just a reference. Also they can not have the same name even one of them is the parent object (try it and you'll see). What do you mean by scene graph? Can you please eleborate? Btw: Object selection in the 3d view: https://blender.stackexchange.com/a/132829/31447 – brockmann Sep 09 '19 at 18:57