nodebpy 0.1.1__py3-none-any.whl → 0.2.1__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,519 @@
1
+ from typing import Literal
2
+
3
+ import bpy
4
+
5
+ from ..builder import NodeBuilder, SocketLinker
6
+ from ..types import (
7
+ TYPE_INPUT_BOOLEAN,
8
+ TYPE_INPUT_STRING,
9
+ TYPE_INPUT_ROTATION,
10
+ TYPE_INPUT_MATRIX,
11
+ TYPE_INPUT_VALUE,
12
+ TYPE_INPUT_VECTOR,
13
+ )
14
+
15
+
16
+ class DialGizmo(NodeBuilder):
17
+ """Show a dial gizmo in the viewport for a value"""
18
+
19
+ _bl_idname = "GeometryNodeGizmoDial"
20
+ node: bpy.types.GeometryNodeGizmoDial
21
+
22
+ def __init__(
23
+ self,
24
+ value: TYPE_INPUT_VALUE = 0.0,
25
+ position: TYPE_INPUT_VECTOR = None,
26
+ up: TYPE_INPUT_VECTOR = None,
27
+ screen_space: TYPE_INPUT_BOOLEAN = True,
28
+ radius: TYPE_INPUT_VALUE = 1.0,
29
+ *,
30
+ color_id: Literal["PRIMARY", "SECONDARY", "X", "Y", "Z"] = "PRIMARY",
31
+ ):
32
+ super().__init__()
33
+ key_args = {
34
+ "Value": value,
35
+ "Position": position,
36
+ "Up": up,
37
+ "Screen Space": screen_space,
38
+ "Radius": radius,
39
+ }
40
+ self.color_id = color_id
41
+ self._establish_links(**key_args)
42
+
43
+ @property
44
+ def i_value(self) -> SocketLinker:
45
+ """Input socket: Value"""
46
+ return self._input("Value")
47
+
48
+ @property
49
+ def i_position(self) -> SocketLinker:
50
+ """Input socket: Position"""
51
+ return self._input("Position")
52
+
53
+ @property
54
+ def i_up(self) -> SocketLinker:
55
+ """Input socket: Up"""
56
+ return self._input("Up")
57
+
58
+ @property
59
+ def i_screen_space(self) -> SocketLinker:
60
+ """Input socket: Screen Space"""
61
+ return self._input("Screen Space")
62
+
63
+ @property
64
+ def i_radius(self) -> SocketLinker:
65
+ """Input socket: Radius"""
66
+ return self._input("Radius")
67
+
68
+ @property
69
+ def o_transform(self) -> SocketLinker:
70
+ """Output socket: Transform"""
71
+ return self._output("Transform")
72
+
73
+ @property
74
+ def color_id(self) -> Literal["PRIMARY", "SECONDARY", "X", "Y", "Z"]:
75
+ return self.node.color_id
76
+
77
+ @color_id.setter
78
+ def color_id(self, value: Literal["PRIMARY", "SECONDARY", "X", "Y", "Z"]):
79
+ self.node.color_id = value
80
+
81
+
82
+ class EnableOutput(NodeBuilder):
83
+ """Either pass through the input value or output the fallback value"""
84
+
85
+ _bl_idname = "NodeEnableOutput"
86
+ node: bpy.types.Node
87
+
88
+ def __init__(
89
+ self,
90
+ enable: TYPE_INPUT_BOOLEAN = False,
91
+ value: TYPE_INPUT_VALUE = 0.0,
92
+ *,
93
+ data_type: Literal[
94
+ "FLOAT",
95
+ "INT",
96
+ "BOOLEAN",
97
+ "VECTOR",
98
+ "RGBA",
99
+ "ROTATION",
100
+ "MATRIX",
101
+ "STRING",
102
+ "MENU",
103
+ "OBJECT",
104
+ "IMAGE",
105
+ "GEOMETRY",
106
+ "COLLECTION",
107
+ "MATERIAL",
108
+ "BUNDLE",
109
+ "CLOSURE",
110
+ ] = "FLOAT",
111
+ ):
112
+ super().__init__()
113
+ key_args = {"Enable": enable, "Value": value}
114
+ self.data_type = data_type
115
+ self._establish_links(**key_args)
116
+
117
+ @classmethod
118
+ def float(cls, enable: TYPE_INPUT_BOOLEAN = False) -> "EnableOutput":
119
+ """Create Enable Output with operation 'Float'."""
120
+ return cls(data_type="FLOAT", enable=enable)
121
+
122
+ @classmethod
123
+ def integer(cls, enable: TYPE_INPUT_BOOLEAN = False) -> "EnableOutput":
124
+ """Create Enable Output with operation 'Integer'."""
125
+ return cls(data_type="INT", enable=enable)
126
+
127
+ @classmethod
128
+ def boolean(cls, enable: TYPE_INPUT_BOOLEAN = False) -> "EnableOutput":
129
+ """Create Enable Output with operation 'Boolean'."""
130
+ return cls(data_type="BOOLEAN", enable=enable)
131
+
132
+ @classmethod
133
+ def vector(cls, enable: TYPE_INPUT_BOOLEAN = False) -> "EnableOutput":
134
+ """Create Enable Output with operation 'Vector'."""
135
+ return cls(data_type="VECTOR", enable=enable)
136
+
137
+ @classmethod
138
+ def color(cls, enable: TYPE_INPUT_BOOLEAN = False) -> "EnableOutput":
139
+ """Create Enable Output with operation 'Color'."""
140
+ return cls(data_type="RGBA", enable=enable)
141
+
142
+ @classmethod
143
+ def rotation(cls, enable: TYPE_INPUT_BOOLEAN = False) -> "EnableOutput":
144
+ """Create Enable Output with operation 'Rotation'."""
145
+ return cls(data_type="ROTATION", enable=enable)
146
+
147
+ @classmethod
148
+ def matrix(cls, enable: TYPE_INPUT_BOOLEAN = False) -> "EnableOutput":
149
+ """Create Enable Output with operation 'Matrix'."""
150
+ return cls(data_type="MATRIX", enable=enable)
151
+
152
+ @classmethod
153
+ def string(cls, enable: TYPE_INPUT_BOOLEAN = False) -> "EnableOutput":
154
+ """Create Enable Output with operation 'String'."""
155
+ return cls(data_type="STRING", enable=enable)
156
+
157
+ @classmethod
158
+ def menu(cls, enable: TYPE_INPUT_BOOLEAN = False) -> "EnableOutput":
159
+ """Create Enable Output with operation 'Menu'."""
160
+ return cls(data_type="MENU", enable=enable)
161
+
162
+ @classmethod
163
+ def object(cls, enable: TYPE_INPUT_BOOLEAN = False) -> "EnableOutput":
164
+ """Create Enable Output with operation 'Object'."""
165
+ return cls(data_type="OBJECT", enable=enable)
166
+
167
+ @classmethod
168
+ def image(cls, enable: TYPE_INPUT_BOOLEAN = False) -> "EnableOutput":
169
+ """Create Enable Output with operation 'Image'."""
170
+ return cls(data_type="IMAGE", enable=enable)
171
+
172
+ @classmethod
173
+ def geometry(cls, enable: TYPE_INPUT_BOOLEAN = False) -> "EnableOutput":
174
+ """Create Enable Output with operation 'Geometry'."""
175
+ return cls(data_type="GEOMETRY", enable=enable)
176
+
177
+ @classmethod
178
+ def collection(cls, enable: TYPE_INPUT_BOOLEAN = False) -> "EnableOutput":
179
+ """Create Enable Output with operation 'Collection'."""
180
+ return cls(data_type="COLLECTION", enable=enable)
181
+
182
+ @classmethod
183
+ def material(cls, enable: TYPE_INPUT_BOOLEAN = False) -> "EnableOutput":
184
+ """Create Enable Output with operation 'Material'."""
185
+ return cls(data_type="MATERIAL", enable=enable)
186
+
187
+ @classmethod
188
+ def bundle(cls, enable: TYPE_INPUT_BOOLEAN = False) -> "EnableOutput":
189
+ """Create Enable Output with operation 'Bundle'."""
190
+ return cls(data_type="BUNDLE", enable=enable)
191
+
192
+ @classmethod
193
+ def closure(cls, enable: TYPE_INPUT_BOOLEAN = False) -> "EnableOutput":
194
+ """Create Enable Output with operation 'Closure'."""
195
+ return cls(data_type="CLOSURE", enable=enable)
196
+
197
+ @property
198
+ def i_enable(self) -> SocketLinker:
199
+ """Input socket: Enable"""
200
+ return self._input("Enable")
201
+
202
+ @property
203
+ def i_value(self) -> SocketLinker:
204
+ """Input socket: Value"""
205
+ return self._input("Value")
206
+
207
+ @property
208
+ def o_value(self) -> SocketLinker:
209
+ """Output socket: Value"""
210
+ return self._output("Value")
211
+
212
+ @property
213
+ def data_type(
214
+ self,
215
+ ) -> Literal[
216
+ "FLOAT",
217
+ "INT",
218
+ "BOOLEAN",
219
+ "VECTOR",
220
+ "RGBA",
221
+ "ROTATION",
222
+ "MATRIX",
223
+ "STRING",
224
+ "MENU",
225
+ "OBJECT",
226
+ "IMAGE",
227
+ "GEOMETRY",
228
+ "COLLECTION",
229
+ "MATERIAL",
230
+ "BUNDLE",
231
+ "CLOSURE",
232
+ ]:
233
+ return self.node.data_type
234
+
235
+ @data_type.setter
236
+ def data_type(
237
+ self,
238
+ value: Literal[
239
+ "FLOAT",
240
+ "INT",
241
+ "BOOLEAN",
242
+ "VECTOR",
243
+ "RGBA",
244
+ "ROTATION",
245
+ "MATRIX",
246
+ "STRING",
247
+ "MENU",
248
+ "OBJECT",
249
+ "IMAGE",
250
+ "GEOMETRY",
251
+ "COLLECTION",
252
+ "MATERIAL",
253
+ "BUNDLE",
254
+ "CLOSURE",
255
+ ],
256
+ ):
257
+ self.node.data_type = value
258
+
259
+
260
+ class GroupInput(NodeBuilder):
261
+ """Expose connected data from inside a node group as inputs to its interface"""
262
+
263
+ _bl_idname = "NodeGroupInput"
264
+ node: bpy.types.Node
265
+
266
+ def __init__(self):
267
+ super().__init__()
268
+ key_args = {}
269
+
270
+ self._establish_links(**key_args)
271
+
272
+
273
+ class GroupOutput(NodeBuilder):
274
+ """Output data from inside of a node group"""
275
+
276
+ _bl_idname = "NodeGroupOutput"
277
+ node: bpy.types.Node
278
+
279
+ def __init__(self, is_active_output: bool = False):
280
+ super().__init__()
281
+ key_args = {}
282
+ self.is_active_output = is_active_output
283
+ self._establish_links(**key_args)
284
+
285
+ @property
286
+ def is_active_output(self) -> bool:
287
+ return self.node.is_active_output
288
+
289
+ @is_active_output.setter
290
+ def is_active_output(self, value: bool):
291
+ self.node.is_active_output = value
292
+
293
+
294
+ class LinearGizmo(NodeBuilder):
295
+ """Show a linear gizmo in the viewport for a value"""
296
+
297
+ _bl_idname = "GeometryNodeGizmoLinear"
298
+ node: bpy.types.GeometryNodeGizmoLinear
299
+
300
+ def __init__(
301
+ self,
302
+ value: TYPE_INPUT_VALUE = 0.0,
303
+ position: TYPE_INPUT_VECTOR = None,
304
+ direction: TYPE_INPUT_VECTOR = None,
305
+ *,
306
+ color_id: Literal["PRIMARY", "SECONDARY", "X", "Y", "Z"] = "PRIMARY",
307
+ draw_style: Literal["ARROW", "CROSS", "BOX"] = "ARROW",
308
+ ):
309
+ super().__init__()
310
+ key_args = {"Value": value, "Position": position, "Direction": direction}
311
+ self.color_id = color_id
312
+ self.draw_style = draw_style
313
+ self._establish_links(**key_args)
314
+
315
+ @property
316
+ def i_value(self) -> SocketLinker:
317
+ """Input socket: Value"""
318
+ return self._input("Value")
319
+
320
+ @property
321
+ def i_position(self) -> SocketLinker:
322
+ """Input socket: Position"""
323
+ return self._input("Position")
324
+
325
+ @property
326
+ def i_direction(self) -> SocketLinker:
327
+ """Input socket: Direction"""
328
+ return self._input("Direction")
329
+
330
+ @property
331
+ def o_transform(self) -> SocketLinker:
332
+ """Output socket: Transform"""
333
+ return self._output("Transform")
334
+
335
+ @property
336
+ def color_id(self) -> Literal["PRIMARY", "SECONDARY", "X", "Y", "Z"]:
337
+ return self.node.color_id
338
+
339
+ @color_id.setter
340
+ def color_id(self, value: Literal["PRIMARY", "SECONDARY", "X", "Y", "Z"]):
341
+ self.node.color_id = value
342
+
343
+ @property
344
+ def draw_style(self) -> Literal["ARROW", "CROSS", "BOX"]:
345
+ return self.node.draw_style
346
+
347
+ @draw_style.setter
348
+ def draw_style(self, value: Literal["ARROW", "CROSS", "BOX"]):
349
+ self.node.draw_style = value
350
+
351
+
352
+ class TransformGizmo(NodeBuilder):
353
+ """Show a transform gizmo in the viewport"""
354
+
355
+ _bl_idname = "GeometryNodeGizmoTransform"
356
+ node: bpy.types.GeometryNodeGizmoTransform
357
+
358
+ def __init__(
359
+ self,
360
+ value: TYPE_INPUT_MATRIX = None,
361
+ position: TYPE_INPUT_VECTOR = None,
362
+ rotation: TYPE_INPUT_ROTATION = None,
363
+ *,
364
+ use_translation_x: bool = False,
365
+ use_translation_y: bool = False,
366
+ use_translation_z: bool = False,
367
+ use_rotation_x: bool = False,
368
+ use_rotation_y: bool = False,
369
+ use_rotation_z: bool = False,
370
+ use_scale_x: bool = False,
371
+ use_scale_y: bool = False,
372
+ use_scale_z: bool = False,
373
+ ):
374
+ super().__init__()
375
+ key_args = {"Value": value, "Position": position, "Rotation": rotation}
376
+ self.use_translation_x = use_translation_x
377
+ self.use_translation_y = use_translation_y
378
+ self.use_translation_z = use_translation_z
379
+ self.use_rotation_x = use_rotation_x
380
+ self.use_rotation_y = use_rotation_y
381
+ self.use_rotation_z = use_rotation_z
382
+ self.use_scale_x = use_scale_x
383
+ self.use_scale_y = use_scale_y
384
+ self.use_scale_z = use_scale_z
385
+ self._establish_links(**key_args)
386
+
387
+ @property
388
+ def i_value(self) -> SocketLinker:
389
+ """Input socket: Value"""
390
+ return self._input("Value")
391
+
392
+ @property
393
+ def i_position(self) -> SocketLinker:
394
+ """Input socket: Position"""
395
+ return self._input("Position")
396
+
397
+ @property
398
+ def i_rotation(self) -> SocketLinker:
399
+ """Input socket: Rotation"""
400
+ return self._input("Rotation")
401
+
402
+ @property
403
+ def o_transform(self) -> SocketLinker:
404
+ """Output socket: Transform"""
405
+ return self._output("Transform")
406
+
407
+ @property
408
+ def use_translation_x(self) -> bool:
409
+ return self.node.use_translation_x
410
+
411
+ @use_translation_x.setter
412
+ def use_translation_x(self, value: bool):
413
+ self.node.use_translation_x = value
414
+
415
+ @property
416
+ def use_translation_y(self) -> bool:
417
+ return self.node.use_translation_y
418
+
419
+ @use_translation_y.setter
420
+ def use_translation_y(self, value: bool):
421
+ self.node.use_translation_y = value
422
+
423
+ @property
424
+ def use_translation_z(self) -> bool:
425
+ return self.node.use_translation_z
426
+
427
+ @use_translation_z.setter
428
+ def use_translation_z(self, value: bool):
429
+ self.node.use_translation_z = value
430
+
431
+ @property
432
+ def use_rotation_x(self) -> bool:
433
+ return self.node.use_rotation_x
434
+
435
+ @use_rotation_x.setter
436
+ def use_rotation_x(self, value: bool):
437
+ self.node.use_rotation_x = value
438
+
439
+ @property
440
+ def use_rotation_y(self) -> bool:
441
+ return self.node.use_rotation_y
442
+
443
+ @use_rotation_y.setter
444
+ def use_rotation_y(self, value: bool):
445
+ self.node.use_rotation_y = value
446
+
447
+ @property
448
+ def use_rotation_z(self) -> bool:
449
+ return self.node.use_rotation_z
450
+
451
+ @use_rotation_z.setter
452
+ def use_rotation_z(self, value: bool):
453
+ self.node.use_rotation_z = value
454
+
455
+ @property
456
+ def use_scale_x(self) -> bool:
457
+ return self.node.use_scale_x
458
+
459
+ @use_scale_x.setter
460
+ def use_scale_x(self, value: bool):
461
+ self.node.use_scale_x = value
462
+
463
+ @property
464
+ def use_scale_y(self) -> bool:
465
+ return self.node.use_scale_y
466
+
467
+ @use_scale_y.setter
468
+ def use_scale_y(self, value: bool):
469
+ self.node.use_scale_y = value
470
+
471
+ @property
472
+ def use_scale_z(self) -> bool:
473
+ return self.node.use_scale_z
474
+
475
+ @use_scale_z.setter
476
+ def use_scale_z(self, value: bool):
477
+ self.node.use_scale_z = value
478
+
479
+
480
+ class Warning(NodeBuilder):
481
+ """Create custom warnings in node groups"""
482
+
483
+ _bl_idname = "GeometryNodeWarning"
484
+ node: bpy.types.GeometryNodeWarning
485
+
486
+ def __init__(
487
+ self,
488
+ show: TYPE_INPUT_BOOLEAN = True,
489
+ message: TYPE_INPUT_STRING = "",
490
+ *,
491
+ warning_type: Literal["ERROR", "WARNING", "INFO"] = "ERROR",
492
+ ):
493
+ super().__init__()
494
+ key_args = {"Show": show, "Message": message}
495
+ self.warning_type = warning_type
496
+ self._establish_links(**key_args)
497
+
498
+ @property
499
+ def i_show(self) -> SocketLinker:
500
+ """Input socket: Show"""
501
+ return self._input("Show")
502
+
503
+ @property
504
+ def i_message(self) -> SocketLinker:
505
+ """Input socket: Message"""
506
+ return self._input("Message")
507
+
508
+ @property
509
+ def o_show(self) -> SocketLinker:
510
+ """Output socket: Show"""
511
+ return self._output("Show")
512
+
513
+ @property
514
+ def warning_type(self) -> Literal["ERROR", "WARNING", "INFO"]:
515
+ return self.node.warning_type
516
+
517
+ @warning_type.setter
518
+ def warning_type(self, value: Literal["ERROR", "WARNING", "INFO"]):
519
+ self.node.warning_type = value