Skip to content

Commit b1f1edb

Browse files
committed
Add sugar for Capture Attribute
1 parent 48929ce commit b1f1edb

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

api/types.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@
66
def map_case_name(i):
77
return ('_' if not i.identifier[0].isalpha() else '') + i.identifier.replace(' ', '_').upper()
88

9+
def socket_type_to_data_type(socket_type):
10+
match socket_type:
11+
case 'VECTOR':
12+
return 'FLOAT_VECTOR'
13+
case 'COLOR':
14+
return 'FLOAT_COLOR'
15+
case _:
16+
return socket_type
17+
918
# The base class all exposed socket types conform to.
1019
class Type:
1120
socket_type: str
@@ -124,6 +133,11 @@ def y(self):
124133
@property
125134
def z(self):
126135
return self._get_xyz_component(2)
136+
137+
def capture(self, value):
138+
data_type = socket_type_to_data_type(value._socket.type)
139+
captured = self.capture_attribute(data_type=data_type, value=value)
140+
return captured.geometry.transfer_attribute(data_type=data_type, attribute=captured.attribute)
127141

128142
for standard_socket in list(filter(lambda x: 'NodeSocket' in x, dir(bpy.types))):
129143
name = standard_socket.replace('NodeSocket', '')

0 commit comments

Comments
 (0)