@@ -345,6 +345,8 @@ def _set_settings_defaults(self, node: Node) -> None:
345345 self ._load_image (attr , f"{ node_var } .{ attr_name } " )
346346 elif st == ST .IMAGE_USER :
347347 self ._image_user_settings (attr , f"{ node_var } .{ attr_name } " )
348+ elif st == ST .INDEX_SWITCH_ITEMS :
349+ self ._index_switch_items (attr , f"{ node_var } .{ attr_name } " )
348350
349351 if bpy .app .version < (4 , 0 , 0 ):
350352 def _set_group_socket_defaults (self , socket_interface : NodeSocketInterface ,
@@ -1043,6 +1045,22 @@ def _image_user_settings(self, img_user: bpy.types.ImageUser,
10431045 self ._write (f"{ img_user_var } .{ img_usr_attr } = "
10441046 f"{ getattr (img_user , img_usr_attr )} " )
10451047
1048+ if bpy .app .version >= (4 , 1 , 0 ):
1049+ def _index_switch_items (self , switch_items : bpy .types .NodeIndexSwitchItems ,
1050+ items_str : str ) -> None :
1051+ """
1052+ Set the proper amount of index switch items
1053+
1054+ Parameters:
1055+ switch_items (bpy.types.NodeIndexSwitchItems): switch items to copy
1056+ items_str (str): string for the generated switch items attribute
1057+ """
1058+ num_items = len (switch_items )
1059+ self ._write (f"{ items_str } .clear()" )
1060+ for i in range (num_items ):
1061+ self ._write (f"{ items_str } .new()" )
1062+
1063+
10461064 def _set_parents (self , node_tree : NodeTree ) -> None :
10471065 """
10481066 Sets parents for all nodes, mostly used to put nodes in frames
0 commit comments