PyConstraint get targets names

I cant find a way to get the targets names
I want to get the names so i can tell to blender to move them to another layer
I know its a weird use, but the advantage its i don’t have name dependency in my code

Here is an example:

import Blender 
 
ob = Blender.Object.GetSelected()[0] 
pose = ob.getPose() 
 
for n in pose.bones.keys(): 
    cns =  pose.bones[n].constraints 
    for i in cns: 
        try:     
            print i[Blender.Constraint.Settings.TARGET] 
            print i[Blender.Constraint.Settings.BONE] 
        except: 
            print 'constraint has no target'

thanks Loolarge, but I’m taking about getting the targets inside the script of a script constraint

juako: have a look at the script template for PyConstraints (see text editor), and look out for the ‘doTarget’ function. From there, you can directly modify the bone directly as long as the function still returns a valid matrix (return target_matrix), you might be able to get it to work, though I’d like to remind you that this is kindof evil :wink:

Aligorith, you are right its pretty evil and i like it jua jua…
You are right if you add something like this to the template

 
def doTarget(target_object, subtarget_bone, target_matrix, id_properties_of_constraint):
 print target_object.name
 return target_matrix

you can print the names, i try this before and it didn’t work so I’m must made something wrong.
now the thing is how to use this in doConstraint.
Somebody knows where its the information about how this woks because i have examples but i want to know how the methods interact between each others

I CANT FIND ANITHING
i cant use global to create a list of objects so i can use in doConstraint(…)
and i cant get the name or the object that handle the constraint to use in doTarget (…)something like Blender.link
I want to move the object that handle the constraint and depending the position, show or hide one of the targets the problem its that i cant connect the handle information with the targets information because what i can access in one method (doConstraint(…)) a cant access in the other (doTarget (…)).
:no: