1 ### BEGIN GPL LICENSE BLOCK #####
3 # This program is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU General Public License
5 # as published by the Free Software Foundation; either version 3
6 # of the License, or (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 # ##### END GPL LICENSE BLOCK #####
18 # Contact for more information about the Addon:
19 # Email: germano.costa@ig.com.br
20 # Twitter: wii_mano @mano_wii
22 "name": "Snap_Utilities_Line",
23 "author": "Germano Cavalcante",
24 "version": (6, 9, 20),
25 "blender": (2, 93, 0),
26 "location": "View3D > TOOLS > Line Tool",
27 "description": "Extends Blender Snap controls",
28 "doc_url" : "https://blenderartists.org/t/cad-snap-utilities",
34 importlib
.reload(navigation_ops
)
35 importlib
.reload(widgets
)
36 importlib
.reload(preferences
)
37 importlib
.reload(op_line
)
38 importlib
.reload(keys
)
40 from . import navigation_ops
42 from . import preferences
47 from bpy
.utils
.toolsystem
import ToolDef
50 __package__
= "mesh_snap_utilities_line"
55 def draw_settings(context
, layout
, tool
):
56 addon_prefs
= context
.preferences
.addons
[__package__
].preferences
58 layout
.prop(addon_prefs
, "incremental")
59 layout
.prop(addon_prefs
, "increments_grid")
60 layout
.prop(addon_prefs
, "intersect")
61 layout
.prop(addon_prefs
, "create_face")
62 if context
.mode
== 'EDIT_MESH':
63 layout
.prop(addon_prefs
, "outer_verts")
64 #props = tool.operator_properties("mesh.snap_utilities_line")
65 #layout.prop(props, "radius")
67 icons_dir
= os
.path
.join(os
.path
.dirname(__file__
), "icons")
70 idname
="snap_utilities.line",
74 "Connect them to split faces"
76 icon
=os
.path
.join(icons_dir
, "ops.mesh.snap_utilities_line"),
77 widget
="MESH_GGT_snap_point",
78 #operator="mesh.snap_utilities_line",
79 keymap
=keys
.km_tool_snap_utilities_line
,
80 draw_settings
=draw_settings
,
84 # -----------------------------------------------------------------------------
88 def get_tool_list(space_type
, context_mode
):
89 from bl_ui
.space_toolsystem_common
import ToolSelectPanelHelper
90 cls
= ToolSelectPanelHelper
._tool
_class
_from
_space
_type
(space_type
)
91 return cls
._tools
[context_mode
]
94 def register_snap_tools():
95 tools
= get_tool_list('VIEW_3D', 'EDIT_MESH')
97 for index
, tool
in enumerate(tools
, 1):
98 if isinstance(tool
, ToolDef
) and tool
.label
== "Measure":
101 tools
[:index
] += None, tool_line
106 def unregister_snap_tools():
107 tools
= get_tool_list('VIEW_3D', 'EDIT_MESH')
109 index
= tools
.index(tool_line
) - 1 #None
111 tools
.remove(tool_line
)
117 def register_keymaps():
118 keyconfigs
= bpy
.context
.window_manager
.keyconfigs
119 kc_defaultconf
= keyconfigs
.default
120 kc_addonconf
= keyconfigs
.addon
121 # In background mode.
122 if kc_defaultconf
is None or kc_addonconf
is None:
125 # TODO: find the user defined tool_mouse.
126 from bl_keymap_utils
.io
import keyconfig_init_from_data
127 keyconfig_init_from_data(kc_defaultconf
, keys
.generate_empty_snap_utilities_tools_keymaps())
128 keyconfig_init_from_data(kc_addonconf
, keys
.generate_snap_utilities_keymaps())
130 #snap_modalkeymap = kc_addonconf.keymaps.find(keys.km_snap_utilities_modal_keymap)
131 #snap_modalkeymap.assign("MESH_OT_snap_utilities_line")
132 def unregister_keymaps():
133 keyconfigs
= bpy
.context
.window_manager
.keyconfigs
134 defaultmap
= getattr(keyconfigs
.get("Blender"), "keymaps", None)
135 addonmap
= getattr(keyconfigs
.get("Blender addon"), "keymaps", None)
136 # In background mode.
137 if defaultmap
is None or addonmap
is None:
140 for keyconfig_data
in keys
.generate_snap_utilities_global_keymaps():
141 km_name
, km_args
, km_content
= keyconfig_data
142 keymap
= addonmap
.find(km_name
, **km_args
)
143 keymap_items
= keymap
.keymap_items
144 for item
in km_content
['items']:
145 item_id
= keymap_items
.find(item
[0])
147 keymap_items
.remove(keymap_items
[item_id
])
149 for keyconfig_data
in keys
.generate_snap_utilities_tools_keymaps():
150 km_name
, km_args
, km_content
= keyconfig_data
151 addonmap
.remove(addonmap
.find(km_name
, **km_args
))
153 for keyconfig_data
in keys
.generate_empty_snap_utilities_tools_keymaps():
154 km_name
, km_args
, km_content
= keyconfig_data
155 defaultmap
.remove(defaultmap
.find(km_name
, **km_args
))
158 # -----------------------------------------------------------------------------
162 preferences
.SnapUtilitiesPreferences
,
163 op_line
.SnapUtilitiesLine
,
164 navigation_ops
.VIEW3D_OT_rotate_custom_pivot
,
165 navigation_ops
.VIEW3D_OT_zoom_custom_target
,
166 widgets
.SnapPointWidget
,
167 widgets
.SnapPointWidgetGroup
,
172 bpy
.utils
.register_class(cls
)
174 register_snap_tools()
180 unregister_snap_tools()
182 for cls
in reversed(classes
):
183 bpy
.utils
.unregister_class(cls
)
186 if __name__
== "__main__":