Missing link Armature - Armature_object

Hi there!

Im kinda missing the link of the armature(s) I have in a .blend and armature objects. It is important to me cause I wanna manipulate the armature’s bones via python script sooo… FIRST I need to access the armature correctly, right?

I added an armatura and, naturally, Blender called it “Armature”. Then I spent 1/2 day to realize I am accessing it in 2 different ways - (1) as an object of type “Armature” through Blender’s module “Object”; and (2) as an Armature - through Blender’s “Armature” module. The first approach gets me to the name at OB box (see below) while the second one gives me the string from AR box. Cause practically they are different, I renamed them manually to Armature_ob and Armature_ar thus making possible to easily distinguish which one of the two I have and which is still in search:


To complicate the situation and test my script in a file with more than one armature (can happen), I added another armature with names Armature_ob2 and Armature_ar2 in the fields above.

Now, by using the code:

    objects = Object.Get()
    for ob in objects:
        if ob.type=="Armature":
            print ob
            print ob.name
            oaName = ob.name

Im browsing though ALL objects and can access any armature by object’s name (Armature_ob, Armature_ob2) and get ALL object’s properties, etc. Particularly, I have that output of this code:

[Object "Armature_ob"]
[Object "Armature_ob2"]

Approaching though the Armature module, using this code:

    armatures = Armature.Get()
    print armatures
    for ar in armatures:
        print ar

I have this output:

{'Armature_ar2': [Armature: "Armature_ar2"], 'Armature_ar': [Armature: "Armature_ar"]}

and I can access ALL elements of the armature such as bones.

The problem is that if I dont know if Armature_ar or Armature_ar2 corresponds to Armature_ob, for example, I cant find it out though the API. Or - the opposite - if know that I have Armature_ob and Armature_ob without knowing which one uses Armature_ar, for example, or both use it - I cant determine this vie the API… At least I havent found HOW TO… Is it possible? And how, please??? :eek:

As always, I explain things in a very detailed way so that you dont spend 1/2 day lost in the problem as I did :smiley: Perhaps the problem is very small but there’s something missing in my knowledge (or in the API 2.49) on how to get to Armature_ob as soon as I have Armature_ar in place AND/OR vice-versa. Any help on linking these or pointing me out to appropriate resource with solution - very much appreciated!!! :spin:


Hi Abidos, i wonder if you found the solution. If yes, please share it with us and rename the thread as “solved”

@ migius - Unfortunately, not yet! :frowning:

Im still in search though… :eyebrowlift:

AFAIK no datablock knows which objects it is used by (though it does store a “users” integer). To find out you need to loop through the objects list and see if object.data == your datablock.

Or of course you could also get the objects first, then extract the data from them. :wink:

hi Abidos,
the solution could be to generate mapping:

import Blender
from Blender import *

def arm_obj_mapping():
	arm2obj_map_dic = {}
	obj2arm_map_dic = {}
	objects = Object.Get()
	for obj in objects:
		if obj.type=='Armature':
			obj_name_str = obj.name
			arm_name_str = obj.getData().name

			obj2arm_map_dic[obj_name_str] = arm_name_str

			if arm_name_str in arm2obj_map_dic.keys():
				arm2obj_map_dic[arm_name_str] = [obj_name_str]

	return obj2arm_map_dic, arm2obj_map_dic

print arm_obj_mapping()

@ Artfunkel - that sounds logical just I was missing that link… :evilgrin:

@ migius - Oh, great! Two directional dicts showing links from the armature to its object and vice-versa! That’s what I was looking for!!! Thanks a lot for saving my time on that! :spin:


removed by binoculos

removed by binoculos