I'm now debugging my code for 2 days and I can't find any solutions to my problem.

I am building an add-on for my company and I need to create a Panel to call the new operator.

The operator by himself works but when I call it with the Custom Panel it gives me an AttributeError : 'NoneType' object has no attribute 'data' on this function :

def parenting(parent,child):
    pbone = bpy.context.object.data.edit_bones['%s'%parent]
    cbone = bpy.context.object.data.edit_bones['%s'%child]

    pbone.select = True
    cbone.select = True


    cbone.parent = pbone

So I believe the class where I create the panel and call the operator has some issues

class LayoutDemoPanel(bpy.types.Panel):
    """Creates a Panel in the scene context of the properties editor"""
    bl_label = "Automation"
    bl_idname = "automation"
    bl_space_type = 'PROPERTIES'
    bl_region_type = 'WINDOW'
    bl_context = "world"

    def draw(self, context):
        layout = self.layout
        #scene = bpy.context.scene
        layout.prop(bpy.context.scene, 'MyWB')
        layout.prop(bpy.context.scene, 'MyT')
        layout.prop(bpy.context.scene, 'Myd')
        col = layout.column()
        col.prop(bpy.context.scene, 'Car_path')
        col.prop(bpy.context.scene, 'Wheel_path')
        row = layout.row()
        row.label(text = "Environment")
        row.operator(operator = "dh.autom")
        return {"FINISHED"}

def register():

def unregister():

#if __name__ == "__main__":

If any one has any idea?

  • $\begingroup$ I add another variable in the draw() to have 'draw(self, context):' It still doesn't work $\endgroup$ Jun 15, 2016 at 13:28

1 Answer 1


I resolved my problem finally, i'm just going to share the solution in case of someone has the same issue

the error was coming from the definition of the parent bone and the child one. Because I am in edit mode, I have to define them in the armature and not in the object.

So instead of

pbone = bpy.context.object.data.edit_bones['%s'%parent]

the correct code is

amt = bpy.data.armatures['PLATFORMAmt']    
pbone = amt.edit_bones['%s'%parent]
  • 4
    $\begingroup$ If the rig object is selected, ie has context, then context.object.data is amt. This is what the poll method is for, to disable operator or hide panel when certain context conditions aren't met. The above will be fine as long as there is an armature named "PLATFORMAmt" in the file, but may not be in same scene as context scene. $\endgroup$
    – batFINGER
    Jun 15, 2016 at 16:46

You must log in to answer this question.

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