diff --git a/packages/tree_clipper/src/tree_clipper/specific_handlers.py b/packages/tree_clipper/src/tree_clipper/specific_handlers.py index 7286d6d..a4e8822 100644 --- a/packages/tree_clipper/src/tree_clipper/specific_handlers.py +++ b/packages/tree_clipper/src/tree_clipper/specific_handlers.py @@ -92,6 +92,9 @@ ACTIVE_GENERATION_INDEX = "active_generation_index" ACTIVE_MAIN_INDEX = "active_main_index" DEFAULT_INPUT = "default_input" +LIST_ITEMS = "list_items" +ADD = "add" +REMOVE = "remove" # this might not be needed anymore in many cases, because @@ -1471,6 +1474,62 @@ def serialize(self): return data +class FieldToListExporter(SpecificExporter[bpy.types.GeometryNodeFieldToList]): + def serialize(self): + return self.export_all_simple_writable_properties_and_list( + [INPUTS, OUTPUTS, BL_IDNAME, LIST_ITEMS], + [PARENT], + ) + + +class FieldToListImporter(SpecificImporter[bpy.types.GeometryNodeFieldToList]): + def deserialize(self): + self.import_all_simple_writable_properties_and_list( + # ordering is important, the list_items implicitly create sockets + [LIST_ITEMS, ACTIVE_INDEX, INPUTS, OUTPUTS] + ) + + +class FieldToListItemExporter(SpecificExporter[bpy.types.GeometryNodeFieldToListItem]): + def serialize(self): + return self.export_all_simple_writable_properties() + + +class FieldToGridItemsImporter( + SpecificImporter[bpy.types.GeometryNodeFieldToListItems] +): + def deserialize(self): + self.getter().clear() + for item in self.serialization[ITEMS]: + socket_type = item[DATA][SOCKET_TYPE] + name = item[DATA][NAME] + self.getter().new(name=name, socket_type=socket_type) + + +class CryptomatteExporter(SpecificExporter[bpy.types.CompositorNodeCryptomatte]): + def serialize(self): + data = self.export_all_simple_writable_properties_and_list( + [INPUTS, OUTPUTS, BL_IDNAME], + [PARENT], + ) + # https://github.com/Algebraic-UG/tree_clipper/issues/165 + data.pop(ADD) + data.pop(REMOVE) + return data + + +class CryptomatteV2Exporter(SpecificExporter[bpy.types.CompositorNodeCryptomatteV2]): + def serialize(self): + data = self.export_all_simple_writable_properties_and_list( + [INPUTS, OUTPUTS, BL_IDNAME, ENTRIES], + [PARENT, IMAGE, SCENE], + ) + # https://github.com/Algebraic-UG/tree_clipper/issues/165 + data.pop(ADD) + data.pop(REMOVE) + return data + + # now they are cooked and ready to use ~ bon appétit BUILT_IN_EXPORTER = _BUILT_IN_EXPORTER BUILT_IN_IMPORTER = _BUILT_IN_IMPORTER