Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
blender-addons
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
blender
blender-addons
Commits
ce4fead3
Commit
ce4fead3
authored
6 years ago
by
mano-wii
Browse files
Options
Downloads
Patches
Plain Diff
mesh_snap_utilities_line: workaround for tool registration
parent
9c914cb3
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
mesh_snap_utilities_line/__init__.py
+68
-23
68 additions, 23 deletions
mesh_snap_utilities_line/__init__.py
with
68 additions
and
23 deletions
mesh_snap_utilities_line/__init__.py
+
68
−
23
View file @
ce4fead3
...
@@ -22,8 +22,8 @@
...
@@ -22,8 +22,8 @@
bl_info
=
{
bl_info
=
{
"
name
"
:
"
Snap_Utilities_Line
"
,
"
name
"
:
"
Snap_Utilities_Line
"
,
"
author
"
:
"
Germano Cavalcante
"
,
"
author
"
:
"
Germano Cavalcante
"
,
"
version
"
:
(
5
,
8
,
2
4
),
"
version
"
:
(
5
,
8
,
2
5
),
"
blender
"
:
(
0
,
0
,
0
),
"
blender
"
:
(
2
,
8
0
,
0
),
"
location
"
:
"
View3D > TOOLS > Make Line
"
,
"
location
"
:
"
View3D > TOOLS > Make Line
"
,
"
description
"
:
"
Extends Blender Snap controls
"
,
"
description
"
:
"
Extends Blender Snap controls
"
,
#"wiki_url" : "http://blenderartists.org/forum/showthread.php?363859-Addon-CAD-Snap-Utilities",
#"wiki_url" : "http://blenderartists.org/forum/showthread.php?363859-Addon-CAD-Snap-Utilities",
...
@@ -65,47 +65,92 @@ def tool_make_line():
...
@@ -65,47 +65,92 @@ def tool_make_line():
"
Connect them to split faces
"
"
Connect them to split faces
"
),
),
icon
=
os
.
path
.
join
(
icons_dir
,
"
ops.mesh.make_line
"
),
icon
=
os
.
path
.
join
(
icons_dir
,
"
ops.mesh.make_line
"
),
#
widget="MESH_GGT_mouse_point",
#
widget="MESH_GGT_mouse_point",
operator
=
"
mesh.make_line
"
,
operator
=
"
mesh.make_line
"
,
keymap
=
(
keymap
=
"
3D View Tool: Edit Mesh, Make Line
"
,
(
"
mesh.make_line
"
,
dict
(
type
=
'
LEFTMOUSE
'
,
value
=
'
PRESS
'
),
None
),
),
draw_settings
=
draw_settings
,
draw_settings
=
draw_settings
,
)
)
def
register
():
# -----------------------------------------------------------------------------
def
get_tool_list
(
space_type
,
context_mode
):
# Tool Registraion
from
bl_ui.space_toolsystem_common
import
ToolSelectPanelHelper
cls
=
ToolSelectPanelHelper
.
_tool_class_from_space_type
(
space_type
)
def
km_3d_view_tool_make_line
(
tool_mouse
=
'
LEFTMOUSE
'
):
return
cls
.
_tools
[
context_mode
]
return
[(
"
3D View Tool: Edit Mesh, Make Line
"
,
{
"
space_type
"
:
'
VIEW_3D
'
,
"
region_type
"
:
'
WINDOW
'
},
{
"
items
"
:
[
(
"
mesh.make_line
"
,
{
"
type
"
:
tool_mouse
,
"
value
"
:
'
CLICK
'
},
None
),
]},
)]
def
get_tool_list
(
space_type
,
context_mode
):
from
bl_ui.space_toolsystem_common
import
ToolSelectPanelHelper
cls
=
ToolSelectPanelHelper
.
_tool_class_from_space_type
(
space_type
)
return
cls
.
_tools
[
context_mode
]
def
register_make_line_tool
():
tools
=
get_tool_list
(
'
VIEW_3D
'
,
'
EDIT_MESH
'
)
for
index
,
tool
in
enumerate
(
tools
,
1
):
if
isinstance
(
tool
,
ToolDef
)
and
tool
.
text
==
"
Add Cube
"
:
break
tools
.
insert
(
index
,
tool_make_line
)
keyconfigs
=
bpy
.
context
.
window_manager
.
keyconfigs
kc_defaultconf
=
keyconfigs
.
get
(
"
blender
"
)
kc_addonconf
=
keyconfigs
.
get
(
"
blender addon
"
)
# TODO: find the user defined tool_mouse.
keyconfig_data
=
km_3d_view_tool_make_line
()
from
bl_keymap_utils.io
import
keyconfig_init_from_data
keyconfig_init_from_data
(
kc_defaultconf
,
keyconfig_data
)
keyconfig_init_from_data
(
kc_addonconf
,
keyconfig_data
)
def
unregister_make_line_tool
():
tools
=
get_tool_list
(
'
VIEW_3D
'
,
'
EDIT_MESH
'
)
tools
.
remove
(
tool_make_line
)
km_name
,
km_args
,
km_content
=
km_3d_view_tool_make_line
()[
0
]
keyconfigs
=
bpy
.
context
.
window_manager
.
keyconfigs
defaultmap
=
keyconfigs
.
get
(
"
blender
"
).
keymaps
addonmap
=
keyconfigs
.
get
(
"
blender addon
"
).
keymaps
addonmap
.
remove
(
addonmap
.
find
(
km_name
,
**
km_args
))
defaultmap
.
remove
(
defaultmap
.
find
(
km_name
,
**
km_args
))
# -----------------------------------------------------------------------------
# Addon Registraion
def
register
():
bpy
.
utils
.
register_class
(
preferences
.
SnapUtilitiesLinePreferences
)
bpy
.
utils
.
register_class
(
preferences
.
SnapUtilitiesLinePreferences
)
bpy
.
utils
.
register_class
(
common_classes
.
VIEW3D_OT_rotate_custom_pivot
)
bpy
.
utils
.
register_class
(
common_classes
.
VIEW3D_OT_rotate_custom_pivot
)
bpy
.
utils
.
register_class
(
common_classes
.
VIEW3D_OT_zoom_custom_target
)
bpy
.
utils
.
register_class
(
common_classes
.
VIEW3D_OT_zoom_custom_target
)
bpy
.
utils
.
register_class
(
ops_line
.
SnapUtilitiesLine
)
bpy
.
utils
.
register_class
(
ops_line
.
SnapUtilitiesLine
)
#
bpy.utils.register_class(common_classes.MousePointWidget)
#
bpy.utils.register_class(common_classes.MousePointWidget)
#
bpy.utils.register_class(common_classes.MousePointWidgetGroup)
#
bpy.utils.register_class(common_classes.MousePointWidgetGroup)
bpy
.
utils
.
register_tool
(
'
VIEW_3D
'
,
'
EDIT_MESH
'
,
tool
_make_line
)
register
_make_line
_tool
(
)
# Move tool to after 'Add Cube'
tools
=
get_tool_list
(
'
VIEW_3D
'
,
'
EDIT_MESH
'
)
for
index
,
tool
in
enumerate
(
tools
):
if
isinstance
(
tool
,
ToolDef
)
and
tool
.
text
==
"
Add Cube
"
:
break
tools
.
insert
(
index
+
1
,
tools
.
pop
(
-
1
))
def
unregister
():
def
unregister
():
bpy
.
utils
.
unregister_
tool
(
'
VIEW_3D
'
,
'
EDIT_MESH
'
,
tool_
make_line
)
unregister_make_line
_tool
(
)
#
bpy.utils.unregister_class(common_classes.MousePointWidgetGroup)
#
bpy.utils.unregister_class(common_classes.MousePointWidgetGroup)
#
bpy.utils.unregister_class(common_classes.MousePointWidget)
#
bpy.utils.unregister_class(common_classes.MousePointWidget)
bpy
.
utils
.
unregister_class
(
ops_line
.
SnapUtilitiesLine
)
bpy
.
utils
.
unregister_class
(
ops_line
.
SnapUtilitiesLine
)
bpy
.
utils
.
unregister_class
(
common_classes
.
VIEW3D_OT_zoom_custom_target
)
bpy
.
utils
.
unregister_class
(
common_classes
.
VIEW3D_OT_zoom_custom_target
)
bpy
.
utils
.
unregister_class
(
common_classes
.
VIEW3D_OT_rotate_custom_pivot
)
bpy
.
utils
.
unregister_class
(
common_classes
.
VIEW3D_OT_rotate_custom_pivot
)
bpy
.
utils
.
unregister_class
(
preferences
.
SnapUtilitiesLinePreferences
)
bpy
.
utils
.
unregister_class
(
preferences
.
SnapUtilitiesLinePreferences
)
if
__name__
==
"
__main__
"
:
if
__name__
==
"
__main__
"
:
__name__
=
"
mesh_snap_utilities_line
"
__name__
=
"
mesh_snap_utilities_line
"
__package__
=
"
mesh_snap_utilities_line
"
__package__
=
"
mesh_snap_utilities_line
"
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment