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 2
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, write to the Free Software Foundation,
15 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 # ##### END GPL LICENSE BLOCK #####
21 "author": "Pixivore, Cedric LEPILLER, Ted Milker, Clarkx",
22 "description": "Multiple tools to carve or to create objects",
24 "blender": (2, 80, 0),
25 "location": "3D View > Ctrl/Shift/x",
27 "doc_url": "{BLENDER_MANUAL_URL}/addons/object/carver.html",
28 "support": 'COMMUNITY',
34 from bpy
.props
import (
39 from bpy
.types
import (AddonPreferences
, WorkSpaceTool
)
40 from bpy
.utils
.toolsystem
import ToolDef
42 from . import carver_utils
43 imp
.reload(carver_utils
)
44 from . import carver_profils
45 imp
.reload(carver_profils
)
46 from . import carver_draw
47 imp
.reload(carver_draw
)
48 from . import carver_operator
49 imp
.reload(carver_operator
)
51 # TODO : Create an icon for Carver MT
52 # Add an icon in the toolbar
53 # class CarverTool(WorkSpaceTool):
54 # bl_space_type='VIEW_3D'
55 # bl_context_mode='OBJECT'
56 # bl_idname = "carver.operator"
59 # "Multiple tools to carve \n"
60 # "or to create objects"
63 # #Icons : \blender-2.80\2.80\datafiles\icons
64 # #Todo: Create a new icon for Carver
65 # bl_icon = "ops.mesh.knife_tool"
68 # ("carver.operator", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None),
71 # def draw_settings(context, layout, tool):
72 # layout.prop(tool.operator_properties, "carver")
75 class CarverPreferences(AddonPreferences
):
79 Enable_Tab_01
: BoolProperty(
81 description
="Some general information and settings about the add-on",
84 Enable_Tab_02
: BoolProperty(
86 description
="List of the shortcuts used during carving",
89 Key_Create
: StringProperty(
90 name
="Object creation",
91 description
="Object creation",
95 Key_Update
: StringProperty(
96 name
="Auto Bevel Update",
97 description
="Auto Bevel Update",
101 Key_Bool
: StringProperty(
103 description
="Boolean operation type",
107 Key_Brush
: StringProperty(
109 description
="Brush Mode",
113 Key_Help
: StringProperty(
115 description
="Help display",
119 Key_Instant
: StringProperty(
121 description
="Instantiate object",
125 Key_Close
: StringProperty(
126 name
="Close polygonal shape",
127 description
="Close polygonal shape",
131 Key_Apply
: StringProperty(
132 name
="Apply operation",
133 description
="Apply operation",
137 Key_Scale
: StringProperty(
139 description
="Scale object",
143 Key_Gapy
: StringProperty(
145 description
="Scale gap between columns",
149 Key_Gapx
: StringProperty(
151 description
="Scale gap between columns",
155 Key_Depth
: StringProperty(
157 description
="Cursor depth or solidify pattern",
161 Key_BrushDepth
: StringProperty(
163 description
="Brush depth",
167 Key_Subadd
: StringProperty(
168 name
="Add subdivision",
169 description
="Add subdivision",
173 Key_Subrem
: StringProperty(
174 name
="Remove subdivision",
175 description
="Remove subdivision",
179 Key_Randrot
: StringProperty(
180 name
="Random rotation",
181 description
="Random rotation",
185 ProfilePrefix
: StringProperty(
186 name
="Profile prefix",
187 description
="Prefix to look for profiles with",
188 default
="Carver_Profile-",
190 LineWidth
: IntProperty(
192 description
="Thickness of the drawing lines",
195 Key_Snap
: StringProperty(
197 description
="Grid Snap",
202 def draw(self
, context
):
203 scene
= context
.scene
206 icon_1
= "TRIA_RIGHT" if not self
.Enable_Tab_01
else "TRIA_DOWN"
209 box
.prop(self
, "Enable_Tab_01", text
="Info and Settings", emboss
=False, icon
=icon_1
)
210 if self
.Enable_Tab_01
:
211 box
.label(text
="Carver Operator:", icon
="LAYER_ACTIVE")
212 box
.label(text
="Select a Mesh Object and press [CTRL]+[SHIFT]+[X] to carve",
214 box
.label(text
="To finish carving press [ESC] or [RIGHT CLICK]",
216 box
.prop(self
, "ProfilePrefix", text
="Profile prefix")
217 row
= box
.row(align
=True)
218 row
.label(text
="Line width:")
219 row
.prop(self
, "LineWidth", text
="")
221 icon_2
= "TRIA_RIGHT" if not self
.Enable_Tab_02
else "TRIA_DOWN"
223 box
.prop(self
, "Enable_Tab_02", text
="Keys", emboss
=False, icon
=icon_2
)
224 if self
.Enable_Tab_02
:
225 split
= box
.split(align
=True)
227 col
= box
.column(align
=True)
228 col
.label(text
="Object Creation:")
229 col
.prop(self
, "Key_Create", text
="")
230 col
.label(text
="Auto bevel update:")
231 col
.prop(self
, "Key_Update", text
="")
232 col
.label(text
="Boolean operation type:")
233 col
.prop(self
, "Key_Bool", text
="")
234 col
.label(text
="Brush Depth:")
235 col
.prop(self
, "Key_BrushDepth", text
="")
238 col
= box
.column(align
=True)
239 col
.label(text
="Brush Mode:")
240 col
.prop(self
, "Key_Brush", text
="")
241 col
.label(text
="Help display:")
242 col
.prop(self
, "Key_Help", text
="")
243 col
.label(text
="Instantiate object:")
244 col
.prop(self
, "Key_Instant", text
="")
245 col
.label(text
="Random rotation:")
246 col
.prop(self
, "Key_Randrot", text
="")
249 col
= box
.column(align
=True)
250 col
.label(text
="Close polygonal shape:")
251 col
.prop(self
, "Key_Close", text
="")
252 col
.label(text
="Apply operation:")
253 col
.prop(self
, "Key_Apply", text
="")
254 col
.label(text
="Scale object:")
255 col
.prop(self
, "Key_Scale", text
="")
256 col
.label(text
="Subdiv add:")
257 col
.prop(self
, "Key_Subadd", text
="")
260 col
= box
.column(align
=True)
261 col
.label(text
="Gap rows:")
262 col
.prop(self
, "Key_Gapy", text
="")
263 col
.label(text
="Gap columns:")
264 col
.prop(self
, "Key_Gapx", text
="")
265 col
.label(text
="Depth / Solidify:")
266 col
.prop(self
, "Key_Depth", text
="")
267 col
.label(text
="Subdiv Remove:")
268 col
.prop(self
, "Key_Subrem", text
="")
271 col
= box
.column(align
=True)
272 col
.label(text
="Grid Snap:")
273 col
.prop(self
, "Key_Snap", text
="")
278 # print("Registered Carver")
280 bpy
.utils
.register_class(CarverPreferences
)
281 # Todo : Add an icon in the toolbat
282 # bpy.utils.register_tool(CarverTool, separator=True, group=True)
283 carver_operator
.register()
286 kcfg
= bpy
.context
.window_manager
.keyconfigs
.addon
288 km
= kcfg
.keymaps
.new(name
='3D View', space_type
='VIEW_3D')
289 kmi
= km
.keymap_items
.new("carver.operator", 'X', 'PRESS', shift
=True, ctrl
=True)
290 addon_keymaps
.append((km
, kmi
))
293 # Todo : Add an icon in the toolbat
294 # bpy.utils.unregister_tool(CarverTool)
295 carver_operator
.unregister()
296 bpy
.utils
.unregister_class(CarverPreferences
)
298 # print("Unregistered Carver")
300 # remove keymap entry
301 for km
, kmi
in addon_keymaps
:
302 km
.keymap_items
.remove(kmi
)
303 addon_keymaps
.clear()
307 if __name__
== "__main__":