1
$\begingroup$

I was following the scripting for artist tutorials on blender youtube channel. I pretty much copied what they did but i can't find the addon inside blender. The installation works fine, i can even call it in the console, but i need to find it so i can assign to a hotkey.

Im am using blender 2.90 latest build.

bl_info = {
    "name": "DC Mirror",
    "version": (1, 0),
    "blender": (2, 90, 0),
}

import bpy


class DCMirror(bpy.types.Operator):
    """Tooltip"""
    bl_idname = "object.dc_mirror"
    bl_label = "DC Mirror"

    def execute(self, context):

        bpy.ops.object.modifier_add(type='MIRROR')
        bpy.context.object.modifiers["Mirror"].show_on_cage = True
        bpy.context.object.modifiers["Mirror"].use_bisect_axis[0] = True
        bpy.context.object.modifiers["Mirror"].use_clip = True


        return {'FINISHED'}


def register():
    bpy.utils.register_class(DCMirror)


def unregister():
    bpy.utils.unregister_class(DCMirror)

$\endgroup$
3
  • $\begingroup$ docs.blender.org/manual/en/latest/advanced/scripting/… Also recommend giving bl_info and addon category. $\endgroup$
    – batFINGER
    Jun 10, 2020 at 3:55
  • $\begingroup$ @batFINGER I don't want to add a hotkey directly to it, i wanted to create an global keymap instead, like what the they did on the tutorial. $\endgroup$
    – Udjani
    Jun 10, 2020 at 4:07
  • $\begingroup$ Am unfamiliar with those tutorials. Recommend if you are going to reference "what they did on the tutorial" please edit links into question. Have answered based on comment above. $\endgroup$
    – batFINGER
    Jun 10, 2020 at 4:29

1 Answer 1

2
$\begingroup$

Addon requires a Category

enter image description here

Give an addon a category, for example sake and to match op name have given it the "Object" category, can use anything here, best to stick with those available if possible. IMO this is prob a mesh operator, that adds modifiers to mesh objects

bl_info = {
    "name": "DC Mirror",
    "version": (1, 0),
    "blender": (2, 90, 0),
    "category": "Object",
}

We assign keymaps to run operators or assign properties. In addon this is "object.dc_mirror", below I've added a keymap to the window such that ShiftCtrlT calls the op.

After assingning it to "object_dc_mirror" notice how the name becomes "DC Mirror", this is confirmation the operator is registered and known to blender

enter image description here

And when run with a mesh object as context. Tip: give the operator a poll method limiting it to only mesh objects.

enter image description here

Consult the docs re adding a keymap via code https://docs.blender.org/manual/en/latest/advanced/scripting/addon_tutorial.html#keymap

Common logic error

Worth mentioning that there is an issue with your addon if run again, it will add a new mirror modifier, but only ever alter the properties of the one having name "Mirror"

Recommend instead

def execute(self, context):
    ob = context.object
    mm = ob.modifiers.new(name="Mirror", type='MIRROR')

    mm.show_on_cage = True
    mm.use_bisect_axis[0] = True # x axis
    mm.use_clip = True


    return {'FINISHED'}
$\endgroup$

You must log in to answer this question.

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