Page Menu
Home
Search
Configure Global Search
Log In
Files
F7581392
ToolAddonTest.py
Shrinivas (Shrinivas)
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Authored By
Shrinivas (Shrinivas)
Jul 10 2019, 11:37 AM
Size
2 KB
Subscribers
None
ToolAddonTest.py
View Options
# This example adds an object mode tool to the toolbar.
# This is just the circle-select and lasso tools tool.
import
bpy
from
bpy.types
import
WorkSpaceTool
bl_info
=
{
"name"
:
"Tool Test"
,
"author"
:
"author"
,
"category"
:
"Object"
,
"blender"
:
(
2
,
80
,
0
),
}
class
MyTool
(
WorkSpaceTool
):
bl_space_type
=
'VIEW_3D'
bl_context_mode
=
'OBJECT'
# The prefix of the idname should be your add-on name.
bl_idname
=
"my_template.my_circle_select"
bl_label
=
"My Circle Select"
bl_description
=
(
"This is a tooltip
\n
"
"with multiple lines"
)
bl_icon
=
"ops.generic.select_circle"
bl_widget
=
None
bl_keymap
=
(
(
"view3d.select_circle"
,
{
"type"
:
'LEFTMOUSE'
,
"value"
:
'PRESS'
},
{
"properties"
:
[(
"wait_for_input"
,
False
)]}),
(
"view3d.select_circle"
,
{
"type"
:
'LEFTMOUSE'
,
"value"
:
'PRESS'
,
"ctrl"
:
True
},
{
"properties"
:
[(
"mode"
,
'SUB'
),
(
"wait_for_input"
,
False
)]}),
)
def
draw_settings
(
context
,
layout
,
tool
):
props
=
tool
.
operator_properties
(
"view3d.select_circle"
)
layout
.
prop
(
props
,
"mode"
)
layout
.
prop
(
props
,
"radius"
)
class
MyOtherTool
(
WorkSpaceTool
):
bl_space_type
=
'VIEW_3D'
bl_context_mode
=
'OBJECT'
bl_idname
=
"my_template.my_other_select"
bl_label
=
"My Lasso Tool Select"
bl_description
=
(
"This is a tooltip
\n
"
"with multiple lines"
)
bl_icon
=
"ops.generic.select_lasso"
bl_widget
=
None
bl_keymap
=
(
(
"view3d.select_lasso"
,
{
"type"
:
'LEFTMOUSE'
,
"value"
:
'PRESS'
},
None
),
(
"view3d.select_lasso"
,
{
"type"
:
'LEFTMOUSE'
,
"value"
:
'PRESS'
,
"ctrl"
:
True
},
{
"properties"
:
[(
"mode"
,
'SUB'
)]}),
)
def
draw_settings
(
context
,
layout
,
tool
):
props
=
tool
.
operator_properties
(
"view3d.select_lasso"
)
layout
.
prop
(
props
,
"mode"
)
def
register
():
bpy
.
utils
.
register_tool
(
MyTool
,
after
=
{
"builtin.scale_cage"
},
separator
=
True
,
group
=
True
)
bpy
.
utils
.
register_tool
(
MyOtherTool
,
after
=
{
MyTool
.
bl_idname
})
def
unregister
():
bpy
.
utils
.
unregister_tool
(
MyTool
)
bpy
.
utils
.
unregister_tool
(
MyOtherTool
)
if
__name__
==
"__main__"
:
register
()
File Metadata
Details
Attached
Mime Type
text/x-python
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
c5/a8/8ca7c0bef2ab93dd4f6669d9f743
Attached To
T66655: Add-on with WorkSpaceTool not working after Blender restart
Event Timeline
Log In to Comment