Edit context mode possibility

I’ve already read that it’s disabled to add custom icons (for new actions) with scripts to the new tool shelf (2.8). The thing holding back seems to be in internal Blender C module. Whenever we try to add icon to edit mode bl_context_mode=‘EDIT’. As a result we get something like that:

Traceback (most recent call last):
File “\ui_tool_simple.py”, line 29, in
File “\ui_tool_simple.py”, line 23, in register
File “C:\Users\Damian\Desktop\nowy folder\nowy folder\blender-2.80.0-git.ffa29194bbe7-windows64\2.80\scripts\modules\bpy\utils_init_.py”, line 750, in register_tool
tools = cls._tools[context_mode]
KeyError: ‘EDIT’
Error: Python script failed, check the message in the system console

Currently it only seems to work for bl_context_mode=‘OBJECT’.
That’s where we get to my question, when we will be enabled to add custom icons into the toolshelf in edit mode?

There is no context mode ‘EDIT’. There are however context modes ‘EDIT_MESH’, ‘EDIT_CURVE’ etc,

‘EDIT’ is only used for object modes.


You’re right, it works now! Thanks a lot :smiley:

I’ve narrowed my code to
class MyTool(WorkSpaceTool):

# The prefix of the idname should be your add-on name.
bl_idname = "ui_plus.circularize"
bl_label = "Circularize"
bl_options = {'REGISTER', 'UNDO'}
bl_description = (
"Move selected vertices into a circle shape"
bl_icon = "ops.generic.select_circle"
bl_widget = None
bl_keymap = (
    ("mesh.looptools_circle", {"type": 'LEFTMOUSE', "value": 'PRESS'}, 
    {"properties": [False, "best", True, 100, False, False, False, 1, True]})

Although it doesn’t do nothing. When I press my circularize button really nothing happens, when I press and drag in viewport I’mmoving selected faces around. I wish to make it like that - press button working like a hotkey meaning it immeadieatly circularizes selection and lets me tweak it with modal (which opens up after pressing a hotkey by default).

I really wish someone could help me.

Do you know how to use multiple bl_context_modes so that I do not have to duplicate the same code? I am trying to use it something like bl_context_mode="OBJECT, EDIT_MESH'

Can you go into some more detail? Where would you have dublicate code?

edit: Oh, is this for tool definitions? I haven’t worked with the tool system yet, I’m sorry.
If WorkSpaceTool classes require declaring bl_context_mode, than that’s probalby just how it is. A tool that works in multiple modes would likely need multiple classes. But you can always cut down on dublicate code by re-using functions.

Thanks for the speedy reply. That makes sense.

Let us know if you can get this to work. I haven’t been able to trick the tool system into just executing an operator. It seems to have been locked out by the devs. You can invoke modals, but only after the user clicks. I hope there is a way around this, but I don’t believe there is.