nodebpy 0.2.0__py3-none-any.whl → 0.3.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.
@@ -2,14 +2,12 @@ from typing import Literal
2
2
 
3
3
  import bpy
4
4
 
5
- from nodebpy.builder import NodeBuilder, SocketLinker
6
-
7
- from .types import (
5
+ from ..builder import NodeBuilder, SocketLinker
6
+ from ..types import (
8
7
  TYPE_INPUT_BOOLEAN,
9
- TYPE_INPUT_MATRIX,
10
8
  TYPE_INPUT_STRING,
11
9
  TYPE_INPUT_ROTATION,
12
- LINKABLE,
10
+ TYPE_INPUT_MATRIX,
13
11
  TYPE_INPUT_VALUE,
14
12
  TYPE_INPUT_VECTOR,
15
13
  )
@@ -18,18 +16,18 @@ from .types import (
18
16
  class DialGizmo(NodeBuilder):
19
17
  """Show a dial gizmo in the viewport for a value"""
20
18
 
21
- name = "GeometryNodeGizmoDial"
19
+ _bl_idname = "GeometryNodeGizmoDial"
22
20
  node: bpy.types.GeometryNodeGizmoDial
23
21
 
24
22
  def __init__(
25
23
  self,
26
24
  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),
25
+ position: TYPE_INPUT_VECTOR = None,
26
+ up: TYPE_INPUT_VECTOR = None,
29
27
  screen_space: TYPE_INPUT_BOOLEAN = True,
30
28
  radius: TYPE_INPUT_VALUE = 1.0,
29
+ *,
31
30
  color_id: Literal["PRIMARY", "SECONDARY", "X", "Y", "Z"] = "PRIMARY",
32
- pin_gizmo: bool = False,
33
31
  ):
34
32
  super().__init__()
35
33
  key_args = {
@@ -40,18 +38,8 @@ class DialGizmo(NodeBuilder):
40
38
  "Radius": radius,
41
39
  }
42
40
  self.color_id = color_id
43
- self.pin_gizmo = pin_gizmo
44
41
  self._establish_links(**key_args)
45
42
 
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
43
  @property
56
44
  def i_value(self) -> SocketLinker:
57
45
  """Input socket: Value"""
@@ -91,37 +79,239 @@ class DialGizmo(NodeBuilder):
91
79
  self.node.color_id = value
92
80
 
93
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
+
94
294
  class LinearGizmo(NodeBuilder):
95
295
  """Show a linear gizmo in the viewport for a value"""
96
296
 
97
- name = "GeometryNodeGizmoLinear"
297
+ _bl_idname = "GeometryNodeGizmoLinear"
98
298
  node: bpy.types.GeometryNodeGizmoLinear
99
299
 
100
300
  def __init__(
101
301
  self,
102
302
  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),
303
+ position: TYPE_INPUT_VECTOR = None,
304
+ direction: TYPE_INPUT_VECTOR = None,
305
+ *,
105
306
  color_id: Literal["PRIMARY", "SECONDARY", "X", "Y", "Z"] = "PRIMARY",
106
307
  draw_style: Literal["ARROW", "CROSS", "BOX"] = "ARROW",
107
- pin_gizmo: bool = False,
108
308
  ):
109
309
  super().__init__()
110
310
  key_args = {"Value": value, "Position": position, "Direction": direction}
111
311
  self.color_id = color_id
112
312
  self.draw_style = draw_style
113
- self.pin_gizmo = pin_gizmo
114
313
  self._establish_links(**key_args)
115
314
 
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
315
  @property
126
316
  def i_value(self) -> SocketLinker:
127
317
  """Input socket: Value"""
@@ -162,29 +352,27 @@ class LinearGizmo(NodeBuilder):
162
352
  class TransformGizmo(NodeBuilder):
163
353
  """Show a transform gizmo in the viewport"""
164
354
 
165
- name = "GeometryNodeGizmoTransform"
355
+ _bl_idname = "GeometryNodeGizmoTransform"
166
356
  node: bpy.types.GeometryNodeGizmoTransform
167
357
 
168
358
  def __init__(
169
359
  self,
170
360
  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),
361
+ position: TYPE_INPUT_VECTOR = None,
362
+ rotation: TYPE_INPUT_ROTATION = None,
173
363
  *,
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,
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,
184
373
  ):
185
374
  super().__init__()
186
375
  key_args = {"Value": value, "Position": position, "Rotation": rotation}
187
- self.pin_gizmo = pin_gizmo
188
376
  self.use_translation_x = use_translation_x
189
377
  self.use_translation_y = use_translation_y
190
378
  self.use_translation_z = use_translation_z
@@ -196,14 +384,6 @@ class TransformGizmo(NodeBuilder):
196
384
  self.use_scale_z = use_scale_z
197
385
  self._establish_links(**key_args)
198
386
 
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
387
  @property
208
388
  def i_value(self) -> SocketLinker:
209
389
  """Input socket: Value"""
@@ -297,71 +477,10 @@ class TransformGizmo(NodeBuilder):
297
477
  self.node.use_scale_z = value
298
478
 
299
479
 
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
480
  class Warning(NodeBuilder):
362
481
  """Create custom warnings in node groups"""
363
482
 
364
- name = "GeometryNodeWarning"
483
+ _bl_idname = "GeometryNodeWarning"
365
484
  node: bpy.types.GeometryNodeWarning
366
485
 
367
486
  def __init__(