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:


And if 'Sphere' has a single child object, named, say, 'Cube', then we would do this:


but unfortunately, this would not work:


Nor this, which would be even more ideal:


However, this would still work:


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?

  • $\begingroup$ Usually via scene references: either bpy.context.scene.objects['Cube'] or bpy.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: blender.stackexchange.com/a/132829/31447 $\endgroup$ – brockmann Sep 9 '19 at 18:57
  • $\begingroup$ Sure, I can elaborate. The scene graph is a term used, in some contexts more familiar to me, to refer to the scene tree. In OpenGL, as an example, you typically have a root, any number of transform objects beneath it, and finally mesh data. (I'm aware that this is a simplification.) However, it takes on a tree-like structure, and given that my example Sphere was top-level, I can often refer to its child as '/Sphere/Cube', like a file path relative to the scene graph. Is that possible, at all, in Blender? $\endgroup$ – Michael Eric Oberlin Sep 9 '19 at 19:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.