def add_datablock_ref_element(collection: T.bpy_prop_collection, datablock: T.ID): """Add an element to a bpy_prop_collection using the collection specific API""" bl_rna = getattr(collection, "bl_rna", None) if bl_rna is not None: if isinstance(bl_rna, _link_collections): collection.link(datablock) return if isinstance(bl_rna, type(T.IDMaterials.bl_rna)): collection.append(datablock) return logging.warning( f"add_datablock_ref_element : no implementation for {collection} ")
def _(collection: T.bpy_prop_collection, proxy: Proxy, index: int, context: Context) -> T.bpy_struct: material_datablock = proxy.target(context) return collection.append(material_datablock)
def _add_element_material_ref(collection: T.bpy_prop_collection, proxy: Proxy, context: Context): material_datablock = proxy.target(context) return collection.append(material_datablock)