1
$\begingroup$

Ok, this is my first post here. So hi Blender Stack Exchange Community! I have a problem: I want to program an addon and need to get the informations of the bones. I found a post wich says me they would stay at Object("Cube").pose.bones. Now, if I try I get an error message wich says me that bones dosen't exist in None. After testing I saw that Object("Cube").pose was None. Here is my operator code:

import bpy
    
class Test_OT_Operator(bpy.types.Operator):
    bl_idname = "view3d.cursor_center"
    bl_label = "Simple operator"
    bl_description = "Center 3d cursor"

    def execute(self, context):
  
        ob = bpy.context.object

        #print(ob.pose.bones[0].matrix) # Would rise an error, I commented this line
        print(ob) # this here works
        print(ob.pose) # this here is None
        bpy.ops.view3d.snap_cursor_to_center()

        return {'FINISHED'}

Now, after I saw yesterday that it worked without any errors. I correctly assigned the bones to my Cube, and I can bend the Cube with the bones. So, I really don't understand why, why it dosen't work now. I really hope you, more experimented Community, could help me to understand. I am really new with python and started coding Lua 2 years ago and Typescript 3 months, so I knew how to program (by the way, sorry if I have a bad english, I am trying to improve it, too)

$\endgroup$

1 Answer 1

1
$\begingroup$

Ok, this is strange… I just changed print(ob.pose) to print(ob.parent.pose) and it seems to works. Idk why or how, but it seems to work and I am just happy about. But still, thanks if someone actually tried to help me.

$\endgroup$
2
  • $\begingroup$ I will mark this as solved in 2 days. Wow, my first post was actually weird… If someone needs help I could try to help you. $\endgroup$ Nov 14, 2020 at 20:35
  • 1
    $\begingroup$ objects have no pose. armatures have poses. ob.parent is the armature. docs.blender.org/api/current/… $\endgroup$
    – lemon
    Nov 15, 2020 at 8:41

You must log in to answer this question.

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