1 # SPDX-FileCopyrightText: 2019-2023 Blender Foundation
3 # SPDX-License-Identifier: GPL-2.0-or-later
7 "author": "Pixivore, Cedric LEPILLER, Ted Milker, Clarkx",
8 "description": "Multiple tools to carve or to create objects",
11 "location": "3D View > Ctrl/Shift/x",
13 "doc_url": "{BLENDER_MANUAL_URL}/addons/object/carver.html",
14 "support": 'COMMUNITY',
20 from bpy
.props
import (
25 from bpy
.types
import (AddonPreferences
, WorkSpaceTool
)
26 from bpy
.utils
.toolsystem
import ToolDef
28 from . import carver_utils
29 imp
.reload(carver_utils
)
30 from . import carver_profils
31 imp
.reload(carver_profils
)
32 from . import carver_draw
33 imp
.reload(carver_draw
)
34 from . import carver_operator
35 imp
.reload(carver_operator
)
37 # TODO : Create an icon for Carver MT
38 # Add an icon in the toolbar
39 # class CarverTool(WorkSpaceTool):
40 # bl_space_type='VIEW_3D'
41 # bl_context_mode='OBJECT'
42 # bl_idname = "carver.operator"
45 # "Multiple tools to carve \n"
46 # "or to create objects"
49 # #Icons : \blender-2.80\2.80\datafiles\icons
50 # #Todo: Create a new icon for Carver
51 # bl_icon = "ops.mesh.knife_tool"
54 # ("carver.operator", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None),
57 # def draw_settings(context, layout, tool):
58 # layout.prop(tool.operator_properties, "carver")
61 class CarverPreferences(AddonPreferences
):
65 Enable_Tab_01
: BoolProperty(
67 description
="Some general information and settings about the add-on",
70 Enable_Tab_02
: BoolProperty(
72 description
="List of the shortcuts used during carving",
75 Key_Create
: StringProperty(
76 name
="Object creation",
77 description
="Object creation",
81 Key_Update
: StringProperty(
82 name
="Auto Bevel Update",
83 description
="Auto Bevel Update",
87 Key_Bool
: StringProperty(
89 description
="Boolean operation type",
93 Key_Brush
: StringProperty(
95 description
="Brush Mode",
99 Key_Help
: StringProperty(
101 description
="Help display",
105 Key_Instant
: StringProperty(
107 description
="Instantiate object",
111 Key_Close
: StringProperty(
112 name
="Close polygonal shape",
113 description
="Close polygonal shape",
117 Key_Apply
: StringProperty(
118 name
="Apply operation",
119 description
="Apply operation",
123 Key_Scale
: StringProperty(
125 description
="Scale object",
129 Key_Gapy
: StringProperty(
131 description
="Scale gap between columns",
135 Key_Gapx
: StringProperty(
137 description
="Scale gap between columns",
141 Key_Depth
: StringProperty(
143 description
="Cursor depth or solidify pattern",
147 Key_BrushDepth
: StringProperty(
149 description
="Brush depth",
153 Key_Subadd
: StringProperty(
154 name
="Add subdivision",
155 description
="Add subdivision",
159 Key_Subrem
: StringProperty(
160 name
="Remove subdivision",
161 description
="Remove subdivision",
165 Key_Randrot
: StringProperty(
166 name
="Random rotation",
167 description
="Random rotation",
171 ProfilePrefix
: StringProperty(
172 name
="Profile prefix",
173 description
="Prefix to look for profiles with",
174 default
="Carver_Profile-",
176 LineWidth
: IntProperty(
178 description
="Thickness of the drawing lines",
181 Key_Snap
: StringProperty(
183 description
="Grid Snap",
188 def draw(self
, context
):
189 scene
= context
.scene
192 icon_1
= "TRIA_RIGHT" if not self
.Enable_Tab_01
else "TRIA_DOWN"
195 box
.prop(self
, "Enable_Tab_01", text
="Info and Settings", emboss
=False, icon
=icon_1
)
196 if self
.Enable_Tab_01
:
197 box
.label(text
="Carver Operator:", icon
="LAYER_ACTIVE")
198 box
.label(text
="Select a Mesh Object and press [CTRL]+[SHIFT]+[X] to carve",
200 box
.label(text
="To finish carving press [ESC] or [RIGHT CLICK]",
202 box
.prop(self
, "ProfilePrefix", text
="Profile prefix")
203 row
= box
.row(align
=True)
204 row
.label(text
="Line width:")
205 row
.prop(self
, "LineWidth", text
="")
207 icon_2
= "TRIA_RIGHT" if not self
.Enable_Tab_02
else "TRIA_DOWN"
209 box
.prop(self
, "Enable_Tab_02", text
="Keys", emboss
=False, icon
=icon_2
)
210 if self
.Enable_Tab_02
:
211 split
= box
.split(align
=True)
213 col
= box
.column(align
=True)
214 col
.label(text
="Object Creation:")
215 col
.prop(self
, "Key_Create", text
="")
216 col
.label(text
="Auto bevel update:")
217 col
.prop(self
, "Key_Update", text
="")
218 col
.label(text
="Boolean operation type:")
219 col
.prop(self
, "Key_Bool", text
="")
220 col
.label(text
="Brush Depth:")
221 col
.prop(self
, "Key_BrushDepth", text
="")
224 col
= box
.column(align
=True)
225 col
.label(text
="Brush Mode:")
226 col
.prop(self
, "Key_Brush", text
="")
227 col
.label(text
="Help display:")
228 col
.prop(self
, "Key_Help", text
="")
229 col
.label(text
="Instantiate object:")
230 col
.prop(self
, "Key_Instant", text
="")
231 col
.label(text
="Random rotation:")
232 col
.prop(self
, "Key_Randrot", text
="")
235 col
= box
.column(align
=True)
236 col
.label(text
="Close polygonal shape:")
237 col
.prop(self
, "Key_Close", text
="")
238 col
.label(text
="Apply operation:")
239 col
.prop(self
, "Key_Apply", text
="")
240 col
.label(text
="Scale object:")
241 col
.prop(self
, "Key_Scale", text
="")
242 col
.label(text
="Subdiv add:")
243 col
.prop(self
, "Key_Subadd", text
="")
246 col
= box
.column(align
=True)
247 col
.label(text
="Gap rows:")
248 col
.prop(self
, "Key_Gapy", text
="")
249 col
.label(text
="Gap columns:")
250 col
.prop(self
, "Key_Gapx", text
="")
251 col
.label(text
="Depth / Solidify:")
252 col
.prop(self
, "Key_Depth", text
="")
253 col
.label(text
="Subdiv Remove:")
254 col
.prop(self
, "Key_Subrem", text
="")
257 col
= box
.column(align
=True)
258 col
.label(text
="Grid Snap:")
259 col
.prop(self
, "Key_Snap", text
="")
264 # print("Registered Carver")
266 bpy
.utils
.register_class(CarverPreferences
)
267 # Todo : Add an icon in the toolbat
268 # bpy.utils.register_tool(CarverTool, separator=True, group=True)
269 carver_operator
.register()
272 kcfg
= bpy
.context
.window_manager
.keyconfigs
.addon
274 km
= kcfg
.keymaps
.new(name
='3D View', space_type
='VIEW_3D')
275 kmi
= km
.keymap_items
.new("carver.operator", 'X', 'PRESS', shift
=True, ctrl
=True)
276 addon_keymaps
.append((km
, kmi
))
279 # Todo : Add an icon in the toolbat
280 # bpy.utils.unregister_tool(CarverTool)
281 carver_operator
.unregister()
282 bpy
.utils
.unregister_class(CarverPreferences
)
284 # print("Unregistered Carver")
286 # remove keymap entry
287 for km
, kmi
in addon_keymaps
:
288 km
.keymap_items
.remove(kmi
)
289 addon_keymaps
.clear()
293 if __name__
== "__main__":