def process_asset(self, context: dict, name: str, namespace: Optional[str] = None, options: Optional[Dict] = None): """ Arguments: name: Use pre-defined name namespace: Use pre-defined namespace context: Full parenthood of representation to load options: Additional settings dictionary """ libpath = self.fname asset = context["asset"]["name"] subset = context["subset"]["name"] lib_container = plugin.asset_name(asset, subset) unique_number = plugin.get_unique_number(asset, subset) namespace = namespace or f"{asset}_{unique_number}" container_name = plugin.asset_name(asset, subset, unique_number) layout_container = bpy.data.collections.new(container_name) blender.pipeline.containerise_existing( layout_container, name, namespace, context, self.__class__.__name__, ) container_metadata = layout_container.get( blender.pipeline.AVALON_PROPERTY) container_metadata["libpath"] = libpath container_metadata["lib_container"] = lib_container # Create a setdress subset to contain all the animation for all # the rigs in the layout creator_plugin = get_creator_by_name(self.setdress_creator_name) if not creator_plugin: raise ValueError("Creator plugin \"{}\" was not found.".format( self.setdress_creator_name)) parent = api.create( creator_plugin, name="animation", asset=api.Session["AVALON_ASSET"], options={"useSelection": True}, data={"dependencies": str(context["representation"]["_id"])}) layout_collection = self._process( libpath, layout_container, container_name, str(context["representation"]["_id"]), None, parent) container_metadata["obj_container"] = layout_collection # Save the list of objects in the metadata container container_metadata["objects"] = layout_collection.all_objects nodes = [layout_container] self[:] = nodes return nodes
def process_asset(self, context: dict, name: str, namespace: Optional[str] = None, options: Optional[Dict] = None) -> Optional[List]: """ Arguments: name: Use pre-defined name namespace: Use pre-defined namespace context: Full parenthood of representation to load options: Additional settings dictionary """ libpath = self.fname asset = context["asset"]["name"] subset = context["subset"]["name"] lib_container = plugin.asset_name(asset, subset) unique_number = plugin.get_unique_number(asset, subset) namespace = namespace or f"{asset}_{unique_number}" container_name = plugin.asset_name(asset, subset, unique_number) container = bpy.data.collections.new(lib_container) container.name = container_name blender.pipeline.containerise_existing( container, name, namespace, context, self.__class__.__name__, ) container_metadata = container.get(blender.pipeline.AVALON_PROPERTY) container_metadata["libpath"] = libpath container_metadata["lib_container"] = lib_container obj_container = self._process(libpath, lib_container, container_name, None) container_metadata["obj_container"] = obj_container # Save the list of objects in the metadata container container_metadata["objects"] = obj_container.all_objects nodes = list(container.objects) nodes.append(container) self[:] = nodes return nodes
def process_asset(self, context: dict, name: str, namespace: Optional[str] = None, options: Optional[Dict] = None) -> Optional[List]: """ Arguments: name: Use pre-defined name namespace: Use pre-defined namespace context: Full parenthood of representation to load options: Additional settings dictionary """ raise NotImplementedError( "Loading of Alembic files is not yet implemented.") # TODO (jasper): implement Alembic import. libpath = self.fname asset = context["asset"]["name"] subset = context["subset"]["name"] # TODO (jasper): evaluate use of namespace which is 'alien' to Blender. lib_container = container_name = (plugin.asset_name( asset, subset, namespace)) relative = bpy.context.preferences.filepaths.use_relative_paths with bpy.data.libraries.load(libpath, link=True, relative=relative) as (data_from, data_to): data_to.collections = [lib_container] scene = bpy.context.scene instance_empty = bpy.data.objects.new(container_name, None) scene.collection.objects.link(instance_empty) instance_empty.instance_type = 'COLLECTION' collection = bpy.data.collections[lib_container] collection.name = container_name instance_empty.instance_collection = collection nodes = list(collection.objects) nodes.append(collection) nodes.append(instance_empty) self[:] = nodes return nodes