From b1f1edba9441f721836c9f529ef1782ec1dee2dd Mon Sep 17 00:00:00 2001 From: Carson Katri Date: Fri, 18 Nov 2022 18:27:56 -0500 Subject: [PATCH] Add sugar for Capture Attribute --- api/types.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/api/types.py b/api/types.py index 4e2a878..0eaab6f 100644 --- a/api/types.py +++ b/api/types.py @@ -6,6 +6,15 @@ from .state import State def map_case_name(i): return ('_' if not i.identifier[0].isalpha() else '') + i.identifier.replace(' ', '_').upper() +def socket_type_to_data_type(socket_type): + match socket_type: + case 'VECTOR': + return 'FLOAT_VECTOR' + case 'COLOR': + return 'FLOAT_COLOR' + case _: + return socket_type + # The base class all exposed socket types conform to. class Type: socket_type: str @@ -124,6 +133,11 @@ class Type: @property def z(self): return self._get_xyz_component(2) + + def capture(self, value): + 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) for standard_socket in list(filter(lambda x: 'NodeSocket' in x, dir(bpy.types))): name = standard_socket.replace('NodeSocket', '')