1 # SPDX-License-Identifier: GPL-2.0-or-later
5 "author": "Pixivore, Cedric LEPILLER, Ted Milker, Clarkx",
6 "description": "Multiple tools to carve or to create objects",
9 "location": "3D View > Ctrl/Shift/x",
11 "doc_url": "{BLENDER_MANUAL_URL}/addons/object/carver.html",
12 "support": 'COMMUNITY',
18 from bpy
.props
import (
23 from bpy
.types
import (AddonPreferences
, WorkSpaceTool
)
24 from bpy
.utils
.toolsystem
import ToolDef
26 from . import carver_utils
27 imp
.reload(carver_utils
)
28 from . import carver_profils
29 imp
.reload(carver_profils
)
30 from . import carver_draw
31 imp
.reload(carver_draw
)
32 from . import carver_operator
33 imp
.reload(carver_operator
)
35 # TODO : Create an icon for Carver MT
36 # Add an icon in the toolbar
37 # class CarverTool(WorkSpaceTool):
38 # bl_space_type='VIEW_3D'
39 # bl_context_mode='OBJECT'
40 # bl_idname = "carver.operator"
43 # "Multiple tools to carve \n"
44 # "or to create objects"
47 # #Icons : \blender-2.80\2.80\datafiles\icons
48 # #Todo: Create a new icon for Carver
49 # bl_icon = "ops.mesh.knife_tool"
52 # ("carver.operator", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None),
55 # def draw_settings(context, layout, tool):
56 # layout.prop(tool.operator_properties, "carver")
59 class CarverPreferences(AddonPreferences
):
63 Enable_Tab_01
: BoolProperty(
65 description
="Some general information and settings about the add-on",
68 Enable_Tab_02
: BoolProperty(
70 description
="List of the shortcuts used during carving",
73 Key_Create
: StringProperty(
74 name
="Object creation",
75 description
="Object creation",
79 Key_Update
: StringProperty(
80 name
="Auto Bevel Update",
81 description
="Auto Bevel Update",
85 Key_Bool
: StringProperty(
87 description
="Boolean operation type",
91 Key_Brush
: StringProperty(
93 description
="Brush Mode",
97 Key_Help
: StringProperty(
99 description
="Help display",
103 Key_Instant
: StringProperty(
105 description
="Instantiate object",
109 Key_Close
: StringProperty(
110 name
="Close polygonal shape",
111 description
="Close polygonal shape",
115 Key_Apply
: StringProperty(
116 name
="Apply operation",
117 description
="Apply operation",
121 Key_Scale
: StringProperty(
123 description
="Scale object",
127 Key_Gapy
: StringProperty(
129 description
="Scale gap between columns",
133 Key_Gapx
: StringProperty(
135 description
="Scale gap between columns",
139 Key_Depth
: StringProperty(
141 description
="Cursor depth or solidify pattern",
145 Key_BrushDepth
: StringProperty(
147 description
="Brush depth",
151 Key_Subadd
: StringProperty(
152 name
="Add subdivision",
153 description
="Add subdivision",
157 Key_Subrem
: StringProperty(
158 name
="Remove subdivision",
159 description
="Remove subdivision",
163 Key_Randrot
: StringProperty(
164 name
="Random rotation",
165 description
="Random rotation",
169 ProfilePrefix
: StringProperty(
170 name
="Profile prefix",
171 description
="Prefix to look for profiles with",
172 default
="Carver_Profile-",
174 LineWidth
: IntProperty(
176 description
="Thickness of the drawing lines",
179 Key_Snap
: StringProperty(
181 description
="Grid Snap",
186 def draw(self
, context
):
187 scene
= context
.scene
190 icon_1
= "TRIA_RIGHT" if not self
.Enable_Tab_01
else "TRIA_DOWN"
193 box
.prop(self
, "Enable_Tab_01", text
="Info and Settings", emboss
=False, icon
=icon_1
)
194 if self
.Enable_Tab_01
:
195 box
.label(text
="Carver Operator:", icon
="LAYER_ACTIVE")
196 box
.label(text
="Select a Mesh Object and press [CTRL]+[SHIFT]+[X] to carve",
198 box
.label(text
="To finish carving press [ESC] or [RIGHT CLICK]",
200 box
.prop(self
, "ProfilePrefix", text
="Profile prefix")
201 row
= box
.row(align
=True)
202 row
.label(text
="Line width:")
203 row
.prop(self
, "LineWidth", text
="")
205 icon_2
= "TRIA_RIGHT" if not self
.Enable_Tab_02
else "TRIA_DOWN"
207 box
.prop(self
, "Enable_Tab_02", text
="Keys", emboss
=False, icon
=icon_2
)
208 if self
.Enable_Tab_02
:
209 split
= box
.split(align
=True)
211 col
= box
.column(align
=True)
212 col
.label(text
="Object Creation:")
213 col
.prop(self
, "Key_Create", text
="")
214 col
.label(text
="Auto bevel update:")
215 col
.prop(self
, "Key_Update", text
="")
216 col
.label(text
="Boolean operation type:")
217 col
.prop(self
, "Key_Bool", text
="")
218 col
.label(text
="Brush Depth:")
219 col
.prop(self
, "Key_BrushDepth", text
="")
222 col
= box
.column(align
=True)
223 col
.label(text
="Brush Mode:")
224 col
.prop(self
, "Key_Brush", text
="")
225 col
.label(text
="Help display:")
226 col
.prop(self
, "Key_Help", text
="")
227 col
.label(text
="Instantiate object:")
228 col
.prop(self
, "Key_Instant", text
="")
229 col
.label(text
="Random rotation:")
230 col
.prop(self
, "Key_Randrot", text
="")
233 col
= box
.column(align
=True)
234 col
.label(text
="Close polygonal shape:")
235 col
.prop(self
, "Key_Close", text
="")
236 col
.label(text
="Apply operation:")
237 col
.prop(self
, "Key_Apply", text
="")
238 col
.label(text
="Scale object:")
239 col
.prop(self
, "Key_Scale", text
="")
240 col
.label(text
="Subdiv add:")
241 col
.prop(self
, "Key_Subadd", text
="")
244 col
= box
.column(align
=True)
245 col
.label(text
="Gap rows:")
246 col
.prop(self
, "Key_Gapy", text
="")
247 col
.label(text
="Gap columns:")
248 col
.prop(self
, "Key_Gapx", text
="")
249 col
.label(text
="Depth / Solidify:")
250 col
.prop(self
, "Key_Depth", text
="")
251 col
.label(text
="Subdiv Remove:")
252 col
.prop(self
, "Key_Subrem", text
="")
255 col
= box
.column(align
=True)
256 col
.label(text
="Grid Snap:")
257 col
.prop(self
, "Key_Snap", text
="")
262 # print("Registered Carver")
264 bpy
.utils
.register_class(CarverPreferences
)
265 # Todo : Add an icon in the toolbat
266 # bpy.utils.register_tool(CarverTool, separator=True, group=True)
267 carver_operator
.register()
270 kcfg
= bpy
.context
.window_manager
.keyconfigs
.addon
272 km
= kcfg
.keymaps
.new(name
='3D View', space_type
='VIEW_3D')
273 kmi
= km
.keymap_items
.new("carver.operator", 'X', 'PRESS', shift
=True, ctrl
=True)
274 addon_keymaps
.append((km
, kmi
))
277 # Todo : Add an icon in the toolbat
278 # bpy.utils.unregister_tool(CarverTool)
279 carver_operator
.unregister()
280 bpy
.utils
.unregister_class(CarverPreferences
)
282 # print("Unregistered Carver")
284 # remove keymap entry
285 for km
, kmi
in addon_keymaps
:
286 km
.keymap_items
.remove(kmi
)
287 addon_keymaps
.clear()
291 if __name__
== "__main__":