nodebpy 0.1.1__py3-none-any.whl → 0.2.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,400 @@
1
+ from typing import Literal
2
+
3
+ import bpy
4
+
5
+ from nodebpy.builder import NodeBuilder, SocketLinker
6
+
7
+ from .types import (
8
+ TYPE_INPUT_BOOLEAN,
9
+ TYPE_INPUT_MATRIX,
10
+ TYPE_INPUT_STRING,
11
+ TYPE_INPUT_ROTATION,
12
+ LINKABLE,
13
+ TYPE_INPUT_VALUE,
14
+ TYPE_INPUT_VECTOR,
15
+ )
16
+
17
+
18
+ class DialGizmo(NodeBuilder):
19
+ """Show a dial gizmo in the viewport for a value"""
20
+
21
+ name = "GeometryNodeGizmoDial"
22
+ node: bpy.types.GeometryNodeGizmoDial
23
+
24
+ def __init__(
25
+ self,
26
+ value: TYPE_INPUT_VALUE = 0.0,
27
+ position: TYPE_INPUT_VECTOR = (0.0, 0.0, 0.0),
28
+ up: TYPE_INPUT_VECTOR = (0.0, 0.0, 1.0),
29
+ screen_space: TYPE_INPUT_BOOLEAN = True,
30
+ radius: TYPE_INPUT_VALUE = 1.0,
31
+ color_id: Literal["PRIMARY", "SECONDARY", "X", "Y", "Z"] = "PRIMARY",
32
+ pin_gizmo: bool = False,
33
+ ):
34
+ super().__init__()
35
+ key_args = {
36
+ "Value": value,
37
+ "Position": position,
38
+ "Up": up,
39
+ "Screen Space": screen_space,
40
+ "Radius": radius,
41
+ }
42
+ self.color_id = color_id
43
+ self.pin_gizmo = pin_gizmo
44
+ self._establish_links(**key_args)
45
+
46
+ @property
47
+ def pin_gizmo(self) -> bool:
48
+ """Pin the gizmo to the viewport"""
49
+ return self.node.inputs[0].pin_gizmo
50
+
51
+ @pin_gizmo.setter
52
+ def pin_gizmo(self, value: bool):
53
+ self.node.inputs[0].pin_gizmo = value
54
+
55
+ @property
56
+ def i_value(self) -> SocketLinker:
57
+ """Input socket: Value"""
58
+ return self._input("Value")
59
+
60
+ @property
61
+ def i_position(self) -> SocketLinker:
62
+ """Input socket: Position"""
63
+ return self._input("Position")
64
+
65
+ @property
66
+ def i_up(self) -> SocketLinker:
67
+ """Input socket: Up"""
68
+ return self._input("Up")
69
+
70
+ @property
71
+ def i_screen_space(self) -> SocketLinker:
72
+ """Input socket: Screen Space"""
73
+ return self._input("Screen Space")
74
+
75
+ @property
76
+ def i_radius(self) -> SocketLinker:
77
+ """Input socket: Radius"""
78
+ return self._input("Radius")
79
+
80
+ @property
81
+ def o_transform(self) -> SocketLinker:
82
+ """Output socket: Transform"""
83
+ return self._output("Transform")
84
+
85
+ @property
86
+ def color_id(self) -> Literal["PRIMARY", "SECONDARY", "X", "Y", "Z"]:
87
+ return self.node.color_id
88
+
89
+ @color_id.setter
90
+ def color_id(self, value: Literal["PRIMARY", "SECONDARY", "X", "Y", "Z"]):
91
+ self.node.color_id = value
92
+
93
+
94
+ class LinearGizmo(NodeBuilder):
95
+ """Show a linear gizmo in the viewport for a value"""
96
+
97
+ name = "GeometryNodeGizmoLinear"
98
+ node: bpy.types.GeometryNodeGizmoLinear
99
+
100
+ def __init__(
101
+ self,
102
+ value: TYPE_INPUT_VALUE = 0.0,
103
+ position: TYPE_INPUT_VECTOR = (0.0, 0.0, 0.0),
104
+ direction: TYPE_INPUT_VECTOR = (0.0, 0.0, 1.0),
105
+ color_id: Literal["PRIMARY", "SECONDARY", "X", "Y", "Z"] = "PRIMARY",
106
+ draw_style: Literal["ARROW", "CROSS", "BOX"] = "ARROW",
107
+ pin_gizmo: bool = False,
108
+ ):
109
+ super().__init__()
110
+ key_args = {"Value": value, "Position": position, "Direction": direction}
111
+ self.color_id = color_id
112
+ self.draw_style = draw_style
113
+ self.pin_gizmo = pin_gizmo
114
+ self._establish_links(**key_args)
115
+
116
+ @property
117
+ def pin_gizmo(self) -> bool:
118
+ """Input socket: Pin Gizmo"""
119
+ return self.node.inputs[0].pin_gizmo
120
+
121
+ @pin_gizmo.setter
122
+ def pin_gizmo(self, value: bool):
123
+ self.node.inputs[0].pin_gizmo = value
124
+
125
+ @property
126
+ def i_value(self) -> SocketLinker:
127
+ """Input socket: Value"""
128
+ return self._input("Value")
129
+
130
+ @property
131
+ def i_position(self) -> SocketLinker:
132
+ """Input socket: Position"""
133
+ return self._input("Position")
134
+
135
+ @property
136
+ def i_direction(self) -> SocketLinker:
137
+ """Input socket: Direction"""
138
+ return self._input("Direction")
139
+
140
+ @property
141
+ def o_transform(self) -> SocketLinker:
142
+ """Output socket: Transform"""
143
+ return self._output("Transform")
144
+
145
+ @property
146
+ def color_id(self) -> Literal["PRIMARY", "SECONDARY", "X", "Y", "Z"]:
147
+ return self.node.color_id
148
+
149
+ @color_id.setter
150
+ def color_id(self, value: Literal["PRIMARY", "SECONDARY", "X", "Y", "Z"]):
151
+ self.node.color_id = value
152
+
153
+ @property
154
+ def draw_style(self) -> Literal["ARROW", "CROSS", "BOX"]:
155
+ return self.node.draw_style
156
+
157
+ @draw_style.setter
158
+ def draw_style(self, value: Literal["ARROW", "CROSS", "BOX"]):
159
+ self.node.draw_style = value
160
+
161
+
162
+ class TransformGizmo(NodeBuilder):
163
+ """Show a transform gizmo in the viewport"""
164
+
165
+ name = "GeometryNodeGizmoTransform"
166
+ node: bpy.types.GeometryNodeGizmoTransform
167
+
168
+ def __init__(
169
+ self,
170
+ value: TYPE_INPUT_MATRIX = None,
171
+ position: TYPE_INPUT_VECTOR = (0.0, 0.0, 0.0),
172
+ rotation: TYPE_INPUT_ROTATION = (0.0, 0.0, 0.0),
173
+ *,
174
+ pin_gizmo: bool = False,
175
+ use_translation_x: bool = True,
176
+ use_translation_y: bool = True,
177
+ use_translation_z: bool = True,
178
+ use_rotation_x: bool = True,
179
+ use_rotation_y: bool = True,
180
+ use_rotation_z: bool = True,
181
+ use_scale_x: bool = True,
182
+ use_scale_y: bool = True,
183
+ use_scale_z: bool = True,
184
+ ):
185
+ super().__init__()
186
+ key_args = {"Value": value, "Position": position, "Rotation": rotation}
187
+ self.pin_gizmo = pin_gizmo
188
+ self.use_translation_x = use_translation_x
189
+ self.use_translation_y = use_translation_y
190
+ self.use_translation_z = use_translation_z
191
+ self.use_rotation_x = use_rotation_x
192
+ self.use_rotation_y = use_rotation_y
193
+ self.use_rotation_z = use_rotation_z
194
+ self.use_scale_x = use_scale_x
195
+ self.use_scale_y = use_scale_y
196
+ self.use_scale_z = use_scale_z
197
+ self._establish_links(**key_args)
198
+
199
+ @property
200
+ def pin_gizmo(self) -> bool:
201
+ return self.node.inputs[0].pin_gizmo
202
+
203
+ @pin_gizmo.setter
204
+ def pin_gizmo(self, value: bool):
205
+ self.node.inputs[0].pin_gizmo = value
206
+
207
+ @property
208
+ def i_value(self) -> SocketLinker:
209
+ """Input socket: Value"""
210
+ return self._input("Value")
211
+
212
+ @property
213
+ def i_position(self) -> SocketLinker:
214
+ """Input socket: Position"""
215
+ return self._input("Position")
216
+
217
+ @property
218
+ def i_rotation(self) -> SocketLinker:
219
+ """Input socket: Rotation"""
220
+ return self._input("Rotation")
221
+
222
+ @property
223
+ def o_transform(self) -> SocketLinker:
224
+ """Output socket: Transform"""
225
+ return self._output("Transform")
226
+
227
+ @property
228
+ def use_translation_x(self) -> bool:
229
+ return self.node.use_translation_x
230
+
231
+ @use_translation_x.setter
232
+ def use_translation_x(self, value: bool):
233
+ self.node.use_translation_x = value
234
+
235
+ @property
236
+ def use_translation_y(self) -> bool:
237
+ return self.node.use_translation_y
238
+
239
+ @use_translation_y.setter
240
+ def use_translation_y(self, value: bool):
241
+ self.node.use_translation_y = value
242
+
243
+ @property
244
+ def use_translation_z(self) -> bool:
245
+ return self.node.use_translation_z
246
+
247
+ @use_translation_z.setter
248
+ def use_translation_z(self, value: bool):
249
+ self.node.use_translation_z = value
250
+
251
+ @property
252
+ def use_rotation_x(self) -> bool:
253
+ return self.node.use_rotation_x
254
+
255
+ @use_rotation_x.setter
256
+ def use_rotation_x(self, value: bool):
257
+ self.node.use_rotation_x = value
258
+
259
+ @property
260
+ def use_rotation_y(self) -> bool:
261
+ return self.node.use_rotation_y
262
+
263
+ @use_rotation_y.setter
264
+ def use_rotation_y(self, value: bool):
265
+ self.node.use_rotation_y = value
266
+
267
+ @property
268
+ def use_rotation_z(self) -> bool:
269
+ return self.node.use_rotation_z
270
+
271
+ @use_rotation_z.setter
272
+ def use_rotation_z(self, value: bool):
273
+ self.node.use_rotation_z = value
274
+
275
+ @property
276
+ def use_scale_x(self) -> bool:
277
+ return self.node.use_scale_x
278
+
279
+ @use_scale_x.setter
280
+ def use_scale_x(self, value: bool):
281
+ self.node.use_scale_x = value
282
+
283
+ @property
284
+ def use_scale_y(self) -> bool:
285
+ return self.node.use_scale_y
286
+
287
+ @use_scale_y.setter
288
+ def use_scale_y(self, value: bool):
289
+ self.node.use_scale_y = value
290
+
291
+ @property
292
+ def use_scale_z(self) -> bool:
293
+ return self.node.use_scale_z
294
+
295
+ @use_scale_z.setter
296
+ def use_scale_z(self, value: bool):
297
+ self.node.use_scale_z = value
298
+
299
+
300
+ class Viewer(NodeBuilder):
301
+ """Display the input data in the Spreadsheet Editor"""
302
+
303
+ name = "GeometryNodeViewer"
304
+ node: bpy.types.GeometryNodeViewer
305
+
306
+ def __init__(
307
+ self,
308
+ extend: LINKABLE | None = None,
309
+ ui_shortcut: int = 0,
310
+ active_index: int = 0,
311
+ domain: Literal[
312
+ "AUTO", "POINT", "EDGE", "FACE", "CORNER", "CURVE", "INSTANCE", "LAYER"
313
+ ] = "AUTO",
314
+ ):
315
+ super().__init__()
316
+ key_args = {"__extend__": extend}
317
+ self.ui_shortcut = ui_shortcut
318
+ self.active_index = active_index
319
+ self.domain = domain
320
+ self._establish_links(**key_args)
321
+
322
+ @property
323
+ def i_input_socket(self) -> SocketLinker:
324
+ """Input socket:"""
325
+ return self._input("__extend__")
326
+
327
+ @property
328
+ def ui_shortcut(self) -> int:
329
+ return self.node.ui_shortcut
330
+
331
+ @ui_shortcut.setter
332
+ def ui_shortcut(self, value: int):
333
+ self.node.ui_shortcut = value
334
+
335
+ @property
336
+ def active_index(self) -> int:
337
+ return self.node.active_index # type: ignore
338
+
339
+ @active_index.setter
340
+ def active_index(self, value: int):
341
+ self.node.active_index = value
342
+
343
+ @property
344
+ def domain(
345
+ self,
346
+ ) -> Literal[
347
+ "AUTO", "POINT", "EDGE", "FACE", "CORNER", "CURVE", "INSTANCE", "LAYER"
348
+ ]:
349
+ return self.node.domain
350
+
351
+ @domain.setter
352
+ def domain(
353
+ self,
354
+ value: Literal[
355
+ "AUTO", "POINT", "EDGE", "FACE", "CORNER", "CURVE", "INSTANCE", "LAYER"
356
+ ],
357
+ ):
358
+ self.node.domain = value
359
+
360
+
361
+ class Warning(NodeBuilder):
362
+ """Create custom warnings in node groups"""
363
+
364
+ name = "GeometryNodeWarning"
365
+ node: bpy.types.GeometryNodeWarning
366
+
367
+ def __init__(
368
+ self,
369
+ show: TYPE_INPUT_BOOLEAN = True,
370
+ message: TYPE_INPUT_STRING = "",
371
+ *,
372
+ warning_type: Literal["ERROR", "WARNING", "INFO"] = "ERROR",
373
+ ):
374
+ super().__init__()
375
+ key_args = {"Show": show, "Message": message}
376
+ self.warning_type = warning_type
377
+ self._establish_links(**key_args)
378
+
379
+ @property
380
+ def i_show(self) -> SocketLinker:
381
+ """Input socket: Show"""
382
+ return self._input("Show")
383
+
384
+ @property
385
+ def i_message(self) -> SocketLinker:
386
+ """Input socket: Message"""
387
+ return self._input("Message")
388
+
389
+ @property
390
+ def o_show(self) -> SocketLinker:
391
+ """Output socket: Show"""
392
+ return self._output("Show")
393
+
394
+ @property
395
+ def warning_type(self) -> Literal["ERROR", "WARNING", "INFO"]:
396
+ return self.node.warning_type
397
+
398
+ @warning_type.setter
399
+ def warning_type(self, value: Literal["ERROR", "WARNING", "INFO"]):
400
+ self.node.warning_type = value