0
$\begingroup$

What I'm making is a script that assigns values to each face, I have a GUI that has fields for each value assigned to each face. So when I click a face I the GUI element to be set to whatever the values are for that face.

So what I am looking for is a way to have an event handler for when a face is selected in edit mode. So when I select this face, this function is called.

$\endgroup$
0
$\begingroup$

I couldn't find a way to do this. So I presume there isn't an easy way. But the next best thing is to do add a keymap that triggers when MOUSESELECT is pressed. Here is an example of that.

# store keymaps here to access after registration
addon_keymaps = []

def register():

    # handle the keymap
    wm = bpy.context.window_manager
    km = wm.keyconfigs.addon.keymaps.new(name='Object Mode', space_type='EMPTY')

    kmi = km.keymap_items.new(ObjectCursorArray.bl_idname, 'SPACE', 'PRESS', ctrl=True, shift=True)
    kmi.properties.total = 4

    addon_keymaps.append(km)


def unregister():

    # handle the keymap
    wm = bpy.context.window_manager
    for km in addon_keymaps:
        wm.keyconfigs.addon.keymaps.remove(km)
    # clear the list
    addon_keymaps.clear()`
$\endgroup$

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.