Fix: Node Wrangler: new reroutes offset when output hidden
[blender-addons.git] / object_carver / __init__.py
blob90328b0e7c8217f68caf836e0bc339df462d4430
1 # SPDX-License-Identifier: GPL-2.0-or-later
3 bl_info = {
4 "name": "Carver",
5 "author": "Pixivore, Cedric LEPILLER, Ted Milker, Clarkx",
6 "description": "Multiple tools to carve or to create objects",
7 "version": (1, 2, 2),
8 "blender": (3, 4, 0),
9 "location": "3D View > Ctrl/Shift/x",
10 "warning": "",
11 "doc_url": "{BLENDER_MANUAL_URL}/addons/object/carver.html",
12 "support": 'COMMUNITY',
13 "category": "Object"
16 import bpy
17 import imp
18 from bpy.props import (
19 BoolProperty,
20 StringProperty,
21 IntProperty
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"
41 # bl_label = "Carver"
42 # bl_description = (
43 # "Multiple tools to carve \n"
44 # "or to create objects"
45 # )
47 # #Icons : \blender-2.80\2.80\datafiles\icons
48 # #Todo: Create a new icon for Carver
49 # bl_icon = "ops.mesh.knife_tool"
50 # bl_widget = None
51 # bl_keymap = (
52 # ("carver.operator", {"type": 'LEFTMOUSE', "value": 'PRESS'}, None),
53 # )
55 # def draw_settings(context, layout, tool):
56 # layout.prop(tool.operator_properties, "carver")
59 class CarverPreferences(AddonPreferences):
60 bl_idname = __name__
63 Enable_Tab_01: BoolProperty(
64 name="Info",
65 description="Some general information and settings about the add-on",
66 default=False
68 Enable_Tab_02: BoolProperty(
69 name="Hotkeys",
70 description="List of the shortcuts used during carving",
71 default=False
73 Key_Create: StringProperty(
74 name="Object creation",
75 description="Object creation",
76 maxlen=1,
77 default="C"
79 Key_Update: StringProperty(
80 name="Auto Bevel Update",
81 description="Auto Bevel Update",
82 maxlen=1,
83 default="A",
85 Key_Bool: StringProperty(
86 name="Boolean type",
87 description="Boolean operation type",
88 maxlen=1,
89 default="T",
91 Key_Brush: StringProperty(
92 name="Brush Mode",
93 description="Brush Mode",
94 maxlen=1,
95 default="B",
97 Key_Help: StringProperty(
98 name="Help display",
99 description="Help display",
100 maxlen=1,
101 default="H",
103 Key_Instant: StringProperty(
104 name="Instantiate",
105 description="Instantiate object",
106 maxlen=1,
107 default="I",
109 Key_Close: StringProperty(
110 name="Close polygonal shape",
111 description="Close polygonal shape",
112 maxlen=1,
113 default="X",
115 Key_Apply: StringProperty(
116 name="Apply operation",
117 description="Apply operation",
118 maxlen=1,
119 default="Q",
121 Key_Scale: StringProperty(
122 name="Scale object",
123 description="Scale object",
124 maxlen=1,
125 default="S",
127 Key_Gapy: StringProperty(
128 name="Gap rows",
129 description="Scale gap between columns",
130 maxlen=1,
131 default="J",
133 Key_Gapx: StringProperty(
134 name="Gap columns",
135 description="Scale gap between columns",
136 maxlen=1,
137 default="U",
139 Key_Depth: StringProperty(
140 name="Depth",
141 description="Cursor depth or solidify pattern",
142 maxlen=1,
143 default="D",
145 Key_BrushDepth: StringProperty(
146 name="Brush Depth",
147 description="Brush depth",
148 maxlen=1,
149 default="C",
151 Key_Subadd: StringProperty(
152 name="Add subdivision",
153 description="Add subdivision",
154 maxlen=1,
155 default="X",
157 Key_Subrem: StringProperty(
158 name="Remove subdivision",
159 description="Remove subdivision",
160 maxlen=1,
161 default="W",
163 Key_Randrot: StringProperty(
164 name="Random rotation",
165 description="Random rotation",
166 maxlen=1,
167 default="R",
169 ProfilePrefix: StringProperty(
170 name="Profile prefix",
171 description="Prefix to look for profiles with",
172 default="Carver_Profile-",
174 LineWidth: IntProperty(
175 name="Line Width",
176 description="Thickness of the drawing lines",
177 default=1,
179 Key_Snap: StringProperty(
180 name="Grid Snap",
181 description="Grid Snap",
182 maxlen=1,
183 default="G",
186 def draw(self, context):
187 scene = context.scene
188 layout = self.layout
190 icon_1 = "TRIA_RIGHT" if not self.Enable_Tab_01 else "TRIA_DOWN"
191 box = layout.box()
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",
197 icon="LAYER_USED")
198 box.label(text="To finish carving press [ESC] or [RIGHT CLICK]",
199 icon="LAYER_USED")
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"
206 box = layout.box()
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)
210 box = split.box()
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="")
221 box = split.box()
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="")
232 box = split.box()
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="")
243 box = split.box()
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="")
254 box = split.box()
255 col = box.column(align=True)
256 col.label(text="Grid Snap:")
257 col.prop(self, "Key_Snap", text="")
259 addon_keymaps = []
261 def register():
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()
269 # add keymap entry
270 kcfg = bpy.context.window_manager.keyconfigs.addon
271 if kcfg:
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))
276 def unregister():
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__":
292 register()