0
$\begingroup$

I've downloaded a script for blender 2.8 that im trying to get to work in Blender 2.9.3 but it gives the following error:

Traceback (most recent call last):
  File "\monkeyrobot.py", line 64, in <module>
  File "\monkeyrobot.py", line 57, in register
NameError: name 'MonkeyRobotPanel' is not defined
Error: Python script failed, check the message in the system console

I'm still beginner at blenderscript so how much I look at the script I have no idea what is wrong. Any suggestions how I can find what is wrong? I assume something with bl_idname?

import bpy


def main(context):
    #body
    bpy.ops.mesh.primitive_cube_add()
    bpy.ops.transform.resize(value=(1.2, 0.8, 1.5))

    #head
    bpy.ops.mesh.primitive_monkey_add()
    bpy.ops.transform.translate(value=(0, -0.3, 2))

    #arms
    bpy.ops.mesh.primitive_cylinder_add()
    bpy.ops.transform.translate(value=(2, 0, 0))
    bpy.ops.transform.resize(value=(0.5, 0.5, 1.5))
    bpy.ops.transform.rotate(value=-0.523599, axis=(0, 1, 0))
    bpy.ops.mesh.primitive_cylinder_add()
    bpy.ops.transform.translate(value=(-2, 0, 0))
    bpy.ops.transform.resize(value=(0.5, 0.5, 1.5))
    bpy.ops.transform.rotate(value=0.523599, axis=(0, 1, 0))

    #legs
    bpy.ops.mesh.primitive_cylinder_add()
    bpy.ops.transform.translate(value=(0.7, 0, -3.5))
    bpy.ops.transform.resize(value=(0.5, 0.5, 2))
    bpy.ops.object.duplicate_move(TRANSFORM_OT_translate={"value":(-1.4, 0, 0)})


class MonkeyRobot(bpy.types.Operator):
    """Tooltip"""
    bl_idname = "myops.add_monkeyrobot"
    bl_label = "Add Monkey Robot"


    def execute(self, context):
        main(context)
        return {'FINISHED'}

class MonkeyRobotPanel(bpy.types.Panel):
    """Creates a Panel in the Tool Shelf"""
    bl_label = "Monkey Robot Panel"
    bl_idname = "OBJECT_PT_monkey"
    bl_space_type = 'VIEW_3D'
    bl_region_type = 'TOOLS'
    bl_category = "My Tab"

    def draw(self, context):
        layout = self.layout

        row = layout.row()
        row.operator("myops.add_monkeyrobot")

def register():
    bpy.utils.register_class(MonkeyRobot)
    bpy.utils.register_class(MonkeyRobotPanel)

def unregister():
    bpy.utils.unregister_class(MonkeyRobot)
    bpy.utils.unregister_class(MonkeyRobotPanel)

if __name__ == "__main__":
    register()

    # test call
    # bpy.ops.myops.add_monkeyrobot()
$\endgroup$
2
  • 1
    $\begingroup$ Don't get the error mentioned, Rather one complaining about bl_category For 2.8+ is fixed by putting panels on the RHS "N" panel ie bl_region_type = 'UI' $\endgroup$
    – batFINGER
    Aug 26, 2021 at 5:51
  • $\begingroup$ @batFINGER hmm thats odd, I have changed the region_type to UI but now im getting an additional error: ---Warning: 'view3d.origin_to_pie' does not contain 'MT' with prefix and suffix Traceback (most recent call last): File "\monkeyrobot.py", line 64, in <module> File "\monkeyrobot.py", line 57, in register NameError: name 'MonkeyRobotPanel' is not defined Error: Python script failed, check the message in the system console $\endgroup$ Aug 30, 2021 at 7:36

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.