I have a problem with adding a workspace tool to particles.
import bpy
from bpy.types import WorkSpaceTool
bl_info = {
"name" : "ToolX",
"author" : "Author",
"description" : "",
"blender" : (2, 80, 0),
"location" : "",
"warning" : "",
"category" : "Generic"
}
class MyTool(WorkSpaceTool):
bl_space_type='VIEW_3D'
bl_context_mode='PARTICLE'
# The prefix of the idname should be your add-on name.
bl_idname = "my_template.my_circle_select"
bl_label = "My Circle Select2"
bl_description = (
"This is a tooltip\n"
"with multiple lines"
)
bl_icon = "ops.generic.select_circle"
def register():
bpy.utils.register_tool(MyTool)
def unregister():
bpy.utils.unregister_tool(MyTool)
if __name__ == "__main__":
register()
I get the following error:
RuntimeError: Error: Traceback (most recent call last):
File "/home/janez/Software/blender/2.80/scripts/modules/addon_utils.py", line 384, in enable
mod.register()
File "/home/janez/.config/blender/2.80/scripts/addons/temp_scripts/__init__.py", line 63, in register
bpy.utils.register_tool(MyTool)
File "/home/janez/Software/blender/2.80/scripts/modules/bpy/utils/__init__.py", line 755, in register_tool
item.idname for item in ToolSelectPanelHelper._tools_flatten(tools)
File "/home/janez/Software/blender/2.80/scripts/modules/bpy/utils/__init__.py", line 754, in <setcomp>
tools_id = {
File "/home/janez/Software/blender/2.80/scripts/startup/bl_ui/space_toolsystem_common.py", line 219, in _tools_flatten
yield from item(context)
NameError: name 'context' is not defined
This code works fine if I change bl_context_mode with "OBJECT" or "EDIT_MESH", but this is not the result I want. However it fails for "PARTICLE" and "SCULPT".
Am I supposed to call things differently?
The goal here is to add a button into "T" side menu in "PARTICLE" mode.
I am using the latest version of blender 2.80