1
$\begingroup$

I stumbled upon this expression whilst writting a script: Custom bone prop in pose mode

and I strugle to explain it in programming terms. What I mean is that you access the "Armature" object (which seams to be in a list or dictioanary thus the []) and then you "apply" a pose ("mode" method? of "Object" class) to it, and after, you specify another dictionary (or list) on top of it. What I am trying to say is that obviously I don't seem to grasp the API's "structure". Is there a place other than the API reference where I can find a complete overview of that structure. I am fairly knowledgable in Python programming but I keep getting lost in all that intelocked reference page. I'd greatly appreciate any help pointing in the right way.

$\endgroup$
3
  • 3
    $\begingroup$ bpy.data.objects is indeed a disctionary like structure that holds references to objects you can access by name. Each armature hase a pose member, which in turns holds a dictionary like structure that holds a reference to all its bones that you can access by name. Every Bone can hold what is called a custom property, essentially making itself into a dictionary regarding the python API, where the keys are the custom property names and the values are the values of the properties. This is fairly common python practices, I respectfully suggest you take more courses about python ^^ Cheers $\endgroup$
    – Gorgious
    Commented Oct 8 at 19:39
  • $\begingroup$ @Gorgious thank you very much for you explanation, seems like I have some studying to do! I would like a simple clarification on what you mean by "dictionary like structure". Thanks again for your help! $\endgroup$ Commented Oct 8 at 20:00
  • $\begingroup$ @Gorgious this should be posted as an answer ;) along with more explanations for the above comments if you can. $\endgroup$
    – Lauloque
    Commented Oct 8 at 21:36

1 Answer 1

1
$\begingroup$
bpy.data.objects["Armature"].pose.bones["Bone"]["prop"]
  1. bpy — the API entry.

  2. bpy.data — ID data blocks collections.

  3. bpy.data.objectsbpy.types.BlendDataObjects or bpy_prop_collection of bpy.types.Object, __getitem__ supports an index: objects[0], a name: objects['Object Name'] or an object name and library path tuple: objects['Object Name', r'D:\Desktop\library.blend'] or objects.__getitem__(('Object Name', r'D:\Desktop\library.blend')), the library path can be None.

  4. bpy.data.objects["Armature"]bpy.types.Object.

  5. bpy.data.objects["Armature"].pose or bpy.types.Object.posebpy.types.Pose if the object's data is bpy.types.Armature or None if not.

  6. bpy.data.objects["Armature"].pose.bones or bpy.types.Pose.bonesbpy_prop_collection of bpy.types.PoseBone.

  7. bpy.data.objects["Armature"].pose.bones["Bone"]bpy.types.PoseBone.

  8. bpy.data.objects["Armature"].pose.bones["Bone"]["prop"] or bpy.types.bpy_struct["prop"] or bpy.types.bpy_struct.__getitem__("prop") or bpy.types.bpy_struct.get("prop") — getting a value of a custom property of bpy.types.PoseBone which is a bpy.types.bpy_struct subclass.

$\endgroup$

You must log in to answer this question.

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