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',
21 importlib
.reload(carver_utils
)
22 importlib
.reload(carver_profils
)
23 importlib
.reload(carver_draw
)
24 importlib
.reload(carver_operator
)
28 from bpy
.props
import (
33 from bpy
.types
import (AddonPreferences
, WorkSpaceTool
)
34 from bpy
.utils
.toolsystem
import ToolDef
43 # TODO : Create an icon for Carver MT
44 # Add an icon in the toolbar
45 # class CarverTool(WorkSpaceTool):
46 # bl_space_type='VIEW_3D'
47 # bl_context_mode='OBJECT'
48 # bl_idname = "carver.operator"
51 # "Multiple tools to carve \n"
52 # "or to create objects"
55 # #Icons : \blender-2.80\2.80\datafiles\icons
56 # #Todo: Create a new icon for Carver
57 # bl_icon = "ops.mesh.knife_tool"
60 # ("carver.operator", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None),
63 # def draw_settings(context, layout, tool):
64 # layout.prop(tool.operator_properties, "carver")
67 class CarverPreferences(AddonPreferences
):
71 Enable_Tab_01
: BoolProperty(
73 description
="Some general information and settings about the add-on",
76 Enable_Tab_02
: BoolProperty(
78 description
="List of the shortcuts used during carving",
81 Key_Create
: StringProperty(
82 name
="Object creation",
83 description
="Object creation",
87 Key_Update
: StringProperty(
88 name
="Auto Bevel Update",
89 description
="Auto Bevel Update",
93 Key_Bool
: StringProperty(
95 description
="Boolean operation type",
99 Key_Brush
: StringProperty(
101 description
="Brush Mode",
105 Key_Help
: StringProperty(
107 description
="Help display",
111 Key_Instant
: StringProperty(
113 description
="Instantiate object",
117 Key_Close
: StringProperty(
118 name
="Close polygonal shape",
119 description
="Close polygonal shape",
123 Key_Apply
: StringProperty(
124 name
="Apply operation",
125 description
="Apply operation",
129 Key_Scale
: StringProperty(
131 description
="Scale object",
135 Key_Gapy
: StringProperty(
137 description
="Scale gap between columns",
141 Key_Gapx
: StringProperty(
143 description
="Scale gap between columns",
147 Key_Depth
: StringProperty(
149 description
="Cursor depth or solidify pattern",
153 Key_BrushDepth
: StringProperty(
155 description
="Brush depth",
159 Key_Subadd
: StringProperty(
160 name
="Add subdivision",
161 description
="Add subdivision",
165 Key_Subrem
: StringProperty(
166 name
="Remove subdivision",
167 description
="Remove subdivision",
171 Key_Randrot
: StringProperty(
172 name
="Random rotation",
173 description
="Random rotation",
177 ProfilePrefix
: StringProperty(
178 name
="Profile prefix",
179 description
="Prefix to look for profiles with",
180 default
="Carver_Profile-",
182 LineWidth
: IntProperty(
184 description
="Thickness of the drawing lines",
187 Key_Snap
: StringProperty(
189 description
="Grid Snap",
194 def draw(self
, context
):
195 scene
= context
.scene
198 icon_1
= "TRIA_RIGHT" if not self
.Enable_Tab_01
else "TRIA_DOWN"
201 box
.prop(self
, "Enable_Tab_01", text
="Info and Settings", emboss
=False, icon
=icon_1
)
202 if self
.Enable_Tab_01
:
203 box
.label(text
="Carver Operator:", icon
="LAYER_ACTIVE")
204 box
.label(text
="Select a Mesh Object and press [CTRL]+[SHIFT]+[X] to carve",
206 box
.label(text
="To finish carving press [ESC] or [RIGHT CLICK]",
208 box
.prop(self
, "ProfilePrefix", text
="Profile prefix")
209 row
= box
.row(align
=True)
210 row
.label(text
="Line width:")
211 row
.prop(self
, "LineWidth", text
="")
213 icon_2
= "TRIA_RIGHT" if not self
.Enable_Tab_02
else "TRIA_DOWN"
215 box
.prop(self
, "Enable_Tab_02", text
="Keys", emboss
=False, icon
=icon_2
)
216 if self
.Enable_Tab_02
:
217 split
= box
.split(align
=True)
219 col
= box
.column(align
=True)
220 col
.label(text
="Object Creation:")
221 col
.prop(self
, "Key_Create", text
="")
222 col
.label(text
="Auto bevel update:")
223 col
.prop(self
, "Key_Update", text
="")
224 col
.label(text
="Boolean operation type:")
225 col
.prop(self
, "Key_Bool", text
="")
226 col
.label(text
="Brush Depth:")
227 col
.prop(self
, "Key_BrushDepth", text
="")
230 col
= box
.column(align
=True)
231 col
.label(text
="Brush Mode:")
232 col
.prop(self
, "Key_Brush", text
="")
233 col
.label(text
="Help display:")
234 col
.prop(self
, "Key_Help", text
="")
235 col
.label(text
="Instantiate object:")
236 col
.prop(self
, "Key_Instant", text
="")
237 col
.label(text
="Random rotation:")
238 col
.prop(self
, "Key_Randrot", text
="")
241 col
= box
.column(align
=True)
242 col
.label(text
="Close polygonal shape:")
243 col
.prop(self
, "Key_Close", text
="")
244 col
.label(text
="Apply operation:")
245 col
.prop(self
, "Key_Apply", text
="")
246 col
.label(text
="Scale object:")
247 col
.prop(self
, "Key_Scale", text
="")
248 col
.label(text
="Subdiv add:")
249 col
.prop(self
, "Key_Subadd", text
="")
252 col
= box
.column(align
=True)
253 col
.label(text
="Gap rows:")
254 col
.prop(self
, "Key_Gapy", text
="")
255 col
.label(text
="Gap columns:")
256 col
.prop(self
, "Key_Gapx", text
="")
257 col
.label(text
="Depth / Solidify:")
258 col
.prop(self
, "Key_Depth", text
="")
259 col
.label(text
="Subdiv Remove:")
260 col
.prop(self
, "Key_Subrem", text
="")
263 col
= box
.column(align
=True)
264 col
.label(text
="Grid Snap:")
265 col
.prop(self
, "Key_Snap", text
="")
270 # print("Registered Carver")
272 bpy
.utils
.register_class(CarverPreferences
)
273 # Todo : Add an icon in the toolbat
274 # bpy.utils.register_tool(CarverTool, separator=True, group=True)
275 carver_operator
.register()
278 kcfg
= bpy
.context
.window_manager
.keyconfigs
.addon
280 km
= kcfg
.keymaps
.new(name
='3D View', space_type
='VIEW_3D')
281 kmi
= km
.keymap_items
.new("carver.operator", 'X', 'PRESS', shift
=True, ctrl
=True)
282 addon_keymaps
.append((km
, kmi
))
285 # Todo : Add an icon in the toolbat
286 # bpy.utils.unregister_tool(CarverTool)
287 carver_operator
.unregister()
288 bpy
.utils
.unregister_class(CarverPreferences
)
290 # print("Unregistered Carver")
292 # remove keymap entry
293 for km
, kmi
in addon_keymaps
:
294 km
.keymap_items
.remove(kmi
)
295 addon_keymaps
.clear()
299 if __name__
== "__main__":