Improve and document 'capture'

This commit is contained in:
Carson Katri 2022-11-18 19:04:34 -05:00
commit 7a52377ae9
4 changed files with 71 additions and 3 deletions

View file

@ -326,6 +326,7 @@ class Type:
x = Type()
y = Type()
z = Type()
def capture(self, attribute: Type, **kwargs) -> Callable[[], Type]: return transfer_attribute
{(newline + ' ').join(map(lambda x: x.replace('(', '(self, '), filter(lambda x: x.startswith('def'), symbols)))}
{newline.join(map(type_symbol, Type.__subclasses__()))}

View file

@ -134,10 +134,10 @@ class Type:
def z(self):
return self._get_xyz_component(2)
def capture(self, value):
def capture(self, value, **kwargs):
data_type = socket_type_to_data_type(value._socket.type)
captured = self.capture_attribute(data_type=data_type, value=value)
return captured.geometry.transfer_attribute(data_type=data_type, attribute=captured.attribute)
captured = self.capture_attribute(data_type=data_type, value=value, **kwargs)
return lambda **kwargs: captured.geometry.transfer_attribute(data_type=data_type, attribute=captured.attribute, **kwargs)
for standard_socket in list(filter(lambda x: 'NodeSocket' in x, dir(bpy.types))):
name = standard_socket.replace('NodeSocket', '')