diff --git a/pype/plugins/blender/create/create_action.py b/pype/hosts/blender/plugins/create/create_action.py similarity index 91% rename from pype/plugins/blender/create/create_action.py rename to pype/hosts/blender/plugins/create/create_action.py index f5273863c4..d402998843 100644 --- a/pype/plugins/blender/create/create_action.py +++ b/pype/hosts/blender/plugins/create/create_action.py @@ -4,7 +4,7 @@ import bpy from avalon import api from avalon.blender import Creator, lib -import pype.hosts.blender.plugin +import pype.hosts.blender.api.plugin class CreateAction(Creator): @@ -19,7 +19,7 @@ class CreateAction(Creator): asset = self.data["asset"] subset = self.data["subset"] - name = pype.hosts.blender.plugin.asset_name(asset, subset) + name = pype.hosts.blender.api.plugin.asset_name(asset, subset) collection = bpy.data.collections.new(name=name) bpy.context.scene.collection.children.link(collection) self.data['task'] = api.Session.get('AVALON_TASK') diff --git a/pype/plugins/blender/create/create_animation.py b/pype/hosts/blender/plugins/create/create_animation.py similarity index 87% rename from pype/plugins/blender/create/create_animation.py rename to pype/hosts/blender/plugins/create/create_animation.py index acfd6ac1f3..9d68768201 100644 --- a/pype/plugins/blender/create/create_animation.py +++ b/pype/hosts/blender/plugins/create/create_animation.py @@ -3,7 +3,7 @@ import bpy from avalon import api, blender -import pype.hosts.blender.plugin +import pype.hosts.blender.api.plugin class CreateAnimation(blender.Creator): @@ -17,7 +17,7 @@ class CreateAnimation(blender.Creator): def process(self): asset = self.data["asset"] subset = self.data["subset"] - name = pype.hosts.blender.plugin.asset_name(asset, subset) + name = pype.hosts.blender.api.plugin.asset_name(asset, subset) collection = bpy.data.collections.new(name=name) bpy.context.scene.collection.children.link(collection) self.data['task'] = api.Session.get('AVALON_TASK') diff --git a/pype/plugins/blender/create/create_camera.py b/pype/hosts/blender/plugins/create/create_camera.py similarity index 87% rename from pype/plugins/blender/create/create_camera.py rename to pype/hosts/blender/plugins/create/create_camera.py index 5817985053..a40ddc63d4 100644 --- a/pype/plugins/blender/create/create_camera.py +++ b/pype/hosts/blender/plugins/create/create_camera.py @@ -4,7 +4,7 @@ import bpy from avalon import api from avalon.blender import Creator, lib -import pype.hosts.blender.plugin +import pype.hosts.blender.api.plugin class CreateCamera(Creator): @@ -19,7 +19,7 @@ class CreateCamera(Creator): asset = self.data["asset"] subset = self.data["subset"] - name = pype.hosts.blender.plugin.asset_name(asset, subset) + name = pype.hosts.blender.api.plugin.asset_name(asset, subset) collection = bpy.data.collections.new(name=name) bpy.context.scene.collection.children.link(collection) self.data['task'] = api.Session.get('AVALON_TASK') diff --git a/pype/plugins/blender/create/create_layout.py b/pype/hosts/blender/plugins/create/create_layout.py similarity index 91% rename from pype/plugins/blender/create/create_layout.py rename to pype/hosts/blender/plugins/create/create_layout.py index 010eec539b..ef765d741b 100644 --- a/pype/plugins/blender/create/create_layout.py +++ b/pype/hosts/blender/plugins/create/create_layout.py @@ -4,7 +4,7 @@ import bpy from avalon import api from avalon.blender import Creator, lib -import pype.hosts.blender.plugin +import pype.hosts.blender.api.plugin class CreateLayout(Creator): @@ -19,7 +19,7 @@ class CreateLayout(Creator): asset = self.data["asset"] subset = self.data["subset"] - name = pype.hosts.blender.plugin.asset_name(asset, subset) + name = pype.hosts.blender.api.plugin.asset_name(asset, subset) collection = bpy.data.collections.new(name=name) bpy.context.scene.collection.children.link(collection) self.data['task'] = api.Session.get('AVALON_TASK') diff --git a/pype/plugins/blender/create/create_model.py b/pype/hosts/blender/plugins/create/create_model.py similarity index 87% rename from pype/plugins/blender/create/create_model.py rename to pype/hosts/blender/plugins/create/create_model.py index 59905edc41..2bf8aedb48 100644 --- a/pype/plugins/blender/create/create_model.py +++ b/pype/hosts/blender/plugins/create/create_model.py @@ -4,7 +4,7 @@ import bpy from avalon import api from avalon.blender import Creator, lib -import pype.hosts.blender.plugin +import pype.hosts.blender.api.plugin class CreateModel(Creator): @@ -19,7 +19,7 @@ class CreateModel(Creator): asset = self.data["asset"] subset = self.data["subset"] - name = pype.hosts.blender.plugin.asset_name(asset, subset) + name = pype.hosts.blender.api.plugin.asset_name(asset, subset) collection = bpy.data.collections.new(name=name) bpy.context.scene.collection.children.link(collection) self.data['task'] = api.Session.get('AVALON_TASK') diff --git a/pype/plugins/blender/create/create_rig.py b/pype/hosts/blender/plugins/create/create_rig.py similarity index 92% rename from pype/plugins/blender/create/create_rig.py rename to pype/hosts/blender/plugins/create/create_rig.py index 5c85bf969d..f3efa824f4 100644 --- a/pype/plugins/blender/create/create_rig.py +++ b/pype/hosts/blender/plugins/create/create_rig.py @@ -4,7 +4,7 @@ import bpy from avalon import api from avalon.blender import Creator, lib -import pype.hosts.blender.plugin +import pype.hosts.blender.api.plugin class CreateRig(Creator): @@ -19,7 +19,7 @@ class CreateRig(Creator): asset = self.data["asset"] subset = self.data["subset"] - name = pype.hosts.blender.plugin.asset_name(asset, subset) + name = pype.hosts.blender.api.plugin.asset_name(asset, subset) collection = bpy.data.collections.new(name=name) bpy.context.scene.collection.children.link(collection) self.data['task'] = api.Session.get('AVALON_TASK') diff --git a/pype/plugins/blender/create/create_setdress.py b/pype/hosts/blender/plugins/create/create_setdress.py similarity index 84% rename from pype/plugins/blender/create/create_setdress.py rename to pype/hosts/blender/plugins/create/create_setdress.py index 06acf716e5..c918949216 100644 --- a/pype/plugins/blender/create/create_setdress.py +++ b/pype/hosts/blender/plugins/create/create_setdress.py @@ -1,7 +1,7 @@ import bpy from avalon import api, blender -import pype.hosts.blender.plugin +import pype.hosts.blender.api.plugin class CreateSetDress(blender.Creator): """A grouped package of loaded content""" @@ -15,7 +15,7 @@ class CreateSetDress(blender.Creator): def process(self): asset = self.data["asset"] subset = self.data["subset"] - name = pype.hosts.blender.plugin.asset_name(asset, subset) + name = pype.hosts.blender.api.plugin.asset_name(asset, subset) collection = bpy.data.collections.new(name=name) bpy.context.scene.collection.children.link(collection) self.data['task'] = api.Session.get('AVALON_TASK') diff --git a/pype/hosts/blender/plugins/load/__init__.py b/pype/hosts/blender/plugins/load/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/pype/plugins/blender/load/load_action.py b/pype/hosts/blender/plugins/load/load_action.py similarity index 96% rename from pype/plugins/blender/load/load_action.py rename to pype/hosts/blender/plugins/load/load_action.py index 1f2a870640..79e42995b3 100644 --- a/pype/plugins/blender/load/load_action.py +++ b/pype/hosts/blender/plugins/load/load_action.py @@ -7,12 +7,12 @@ from typing import Dict, List, Optional from avalon import api, blender import bpy -import pype.hosts.blender.plugin +import pype.hosts.blender.api.plugin logger = logging.getLogger("pype").getChild("blender").getChild("load_action") -class BlendActionLoader(pype.hosts.blender.plugin.AssetLoader): +class BlendActionLoader(pype.hosts.blender.api.plugin.AssetLoader): """Load action from a .blend file. Warning: @@ -42,8 +42,8 @@ class BlendActionLoader(pype.hosts.blender.plugin.AssetLoader): libpath = self.fname asset = context["asset"]["name"] subset = context["subset"]["name"] - lib_container = pype.hosts.blender.plugin.asset_name(asset, subset) - container_name = pype.hosts.blender.plugin.asset_name( + lib_container = pype.hosts.blender.api.plugin.asset_name(asset, subset) + container_name = pype.hosts.blender.api.plugin.asset_name( asset, subset, namespace ) @@ -149,7 +149,7 @@ class BlendActionLoader(pype.hosts.blender.plugin.AssetLoader): assert libpath.is_file(), ( f"The file doesn't exist: {libpath}" ) - assert extension in pype.hosts.blender.plugin.VALID_EXTENSIONS, ( + assert extension in pype.hosts.blender.api.plugin.VALID_EXTENSIONS, ( f"Unsupported file: {libpath}" ) diff --git a/pype/plugins/blender/load/load_animation.py b/pype/hosts/blender/plugins/load/load_animation.py similarity index 95% rename from pype/plugins/blender/load/load_animation.py rename to pype/hosts/blender/plugins/load/load_animation.py index 32050eca99..a1be6e99ed 100644 --- a/pype/plugins/blender/load/load_animation.py +++ b/pype/hosts/blender/plugins/load/load_animation.py @@ -7,14 +7,14 @@ from typing import Dict, List, Optional from avalon import api, blender import bpy -import pype.hosts.blender.plugin +import pype.hosts.blender.api.plugin logger = logging.getLogger("pype").getChild( "blender").getChild("load_animation") -class BlendAnimationLoader(pype.hosts.blender.plugin.AssetLoader): +class BlendAnimationLoader(pype.hosts.blender.api.plugin.AssetLoader): """Load animations from a .blend file. Warning: @@ -105,8 +105,8 @@ class BlendAnimationLoader(pype.hosts.blender.plugin.AssetLoader): libpath = self.fname asset = context["asset"]["name"] subset = context["subset"]["name"] - lib_container = pype.hosts.blender.plugin.asset_name(asset, subset) - container_name = pype.hosts.blender.plugin.asset_name( + lib_container = pype.hosts.blender.api.plugin.asset_name(asset, subset) + container_name = pype.hosts.blender.api.plugin.asset_name( asset, subset, namespace ) @@ -175,7 +175,7 @@ class BlendAnimationLoader(pype.hosts.blender.plugin.AssetLoader): assert libpath.is_file(), ( f"The file doesn't exist: {libpath}" ) - assert extension in pype.hosts.blender.plugin.VALID_EXTENSIONS, ( + assert extension in pype.hosts.blender.api.plugin.VALID_EXTENSIONS, ( f"Unsupported file: {libpath}" ) diff --git a/pype/plugins/blender/load/load_camera.py b/pype/hosts/blender/plugins/load/load_camera.py similarity index 95% rename from pype/plugins/blender/load/load_camera.py rename to pype/hosts/blender/plugins/load/load_camera.py index eb53870d5c..e6aa11af7e 100644 --- a/pype/plugins/blender/load/load_camera.py +++ b/pype/hosts/blender/plugins/load/load_camera.py @@ -7,12 +7,12 @@ from typing import Dict, List, Optional from avalon import api, blender import bpy -import pype.hosts.blender.plugin +import pype.hosts.blender.api.plugin logger = logging.getLogger("pype").getChild("blender").getChild("load_camera") -class BlendCameraLoader(pype.hosts.blender.plugin.AssetLoader): +class BlendCameraLoader(pype.hosts.blender.api.plugin.AssetLoader): """Load a camera from a .blend file. Warning: @@ -92,8 +92,8 @@ class BlendCameraLoader(pype.hosts.blender.plugin.AssetLoader): libpath = self.fname asset = context["asset"]["name"] subset = context["subset"]["name"] - lib_container = pype.hosts.blender.plugin.asset_name(asset, subset) - container_name = pype.hosts.blender.plugin.asset_name( + lib_container = pype.hosts.blender.api.plugin.asset_name(asset, subset) + container_name = pype.hosts.blender.api.plugin.asset_name( asset, subset, namespace ) @@ -162,7 +162,7 @@ class BlendCameraLoader(pype.hosts.blender.plugin.AssetLoader): assert libpath.is_file(), ( f"The file doesn't exist: {libpath}" ) - assert extension in pype.hosts.blender.plugin.VALID_EXTENSIONS, ( + assert extension in pype.hosts.blender.api.plugin.VALID_EXTENSIONS, ( f"Unsupported file: {libpath}" ) diff --git a/pype/plugins/blender/load/load_layout.py b/pype/hosts/blender/plugins/load/load_layout.py similarity index 99% rename from pype/plugins/blender/load/load_layout.py rename to pype/hosts/blender/plugins/load/load_layout.py index c8ef73aea3..6c1afafbee 100644 --- a/pype/plugins/blender/load/load_layout.py +++ b/pype/hosts/blender/plugins/load/load_layout.py @@ -11,7 +11,7 @@ from typing import Dict, List, Optional from avalon import api, blender, pipeline import bpy -import pype.hosts.blender.plugin as plugin +import pype.hosts.blender.api.plugin as plugin class BlendLayoutLoader(plugin.AssetLoader): diff --git a/pype/plugins/blender/load/load_model.py b/pype/hosts/blender/plugins/load/load_model.py similarity index 99% rename from pype/plugins/blender/load/load_model.py rename to pype/hosts/blender/plugins/load/load_model.py index 59dc00726d..f48c0f8f94 100644 --- a/pype/plugins/blender/load/load_model.py +++ b/pype/hosts/blender/plugins/load/load_model.py @@ -7,7 +7,7 @@ from typing import Dict, List, Optional from avalon import api, blender import bpy -import pype.hosts.blender.plugin as plugin +import pype.hosts.blender.api.plugin as plugin class BlendModelLoader(plugin.AssetLoader): diff --git a/pype/plugins/blender/load/load_rig.py b/pype/hosts/blender/plugins/load/load_rig.py similarity index 99% rename from pype/plugins/blender/load/load_rig.py rename to pype/hosts/blender/plugins/load/load_rig.py index 12017fdbb2..1cc722045c 100644 --- a/pype/plugins/blender/load/load_rig.py +++ b/pype/hosts/blender/plugins/load/load_rig.py @@ -7,7 +7,7 @@ from typing import Dict, List, Optional from avalon import api, blender import bpy -import pype.hosts.blender.plugin as plugin +import pype.hosts.blender.api.plugin as plugin class BlendRigLoader(plugin.AssetLoader): diff --git a/pype/plugins/blender/publish/collect_current_file.py b/pype/hosts/blender/plugins/publish/collect_current_file.py similarity index 100% rename from pype/plugins/blender/publish/collect_current_file.py rename to pype/hosts/blender/plugins/publish/collect_current_file.py diff --git a/pype/plugins/blender/publish/collect_instances.py b/pype/hosts/blender/plugins/publish/collect_instances.py similarity index 100% rename from pype/plugins/blender/publish/collect_instances.py rename to pype/hosts/blender/plugins/publish/collect_instances.py diff --git a/pype/plugins/blender/publish/extract_abc.py b/pype/hosts/blender/plugins/publish/extract_abc.py similarity index 94% rename from pype/plugins/blender/publish/extract_abc.py rename to pype/hosts/blender/plugins/publish/extract_abc.py index 41c9c268f7..949b28df51 100644 --- a/pype/plugins/blender/publish/extract_abc.py +++ b/pype/hosts/blender/plugins/publish/extract_abc.py @@ -1,7 +1,7 @@ import os import pype.api -import pype.hosts.blender.plugin +import pype.hosts.blender.api.plugin import bpy @@ -61,7 +61,8 @@ class ExtractABC(pype.api.Extractor): except: continue - new_context = pype.hosts.blender.plugin.create_blender_context(active=selected[0], selected=selected) + new_context = pype.hosts.blender.api.plugin.create_blender_context( + active=selected[0], selected=selected) # We set the scale of the scene for the export scene.unit_settings.scale_length = 0.01 diff --git a/pype/plugins/blender/publish/extract_animation_collection.py b/pype/hosts/blender/plugins/publish/extract_animation_collection.py similarity index 61% rename from pype/plugins/blender/publish/extract_animation_collection.py rename to pype/hosts/blender/plugins/publish/extract_animation_collection.py index e5e0877280..0cdd17cf1f 100644 --- a/pype/plugins/blender/publish/extract_animation_collection.py +++ b/pype/hosts/blender/plugins/publish/extract_animation_collection.py @@ -6,6 +6,7 @@ import pyblish.api import bpy + class ExtractSetDress(pype.api.Extractor): """Extract setdress.""" @@ -21,17 +22,20 @@ class ExtractSetDress(pype.api.Extractor): json_data = [] for i in instance.context: - collection = i.data.get('name') + collection = i.data.get("name") container = None for obj in bpy.data.collections[collection].objects: - if obj.type == 'ARMATURE': - container_name = obj.get('avalon').get('container_name') + if obj.type == "ARMATURE": + container_name = obj.get("avalon").get("container_name") container = bpy.data.collections[container_name] if container: - json_dict = {} - json_dict['subset'] = i.data.get('subset') - json_dict['container'] = container.name - json_dict['instance_name'] = container.get('avalon').get('instance_name') + json_dict = { + "subset": i.data.get("subset"), + "container": container.name, + } + json_dict["instance_name"] = container.get("avalon").get( + "instance_name" + ) json_data.append(json_dict) if "representations" not in instance.data: @@ -44,13 +48,14 @@ class ExtractSetDress(pype.api.Extractor): json.dump(json_data, fp=file, indent=2) json_representation = { - 'name': 'json', - 'ext': 'json', - 'files': json_filename, + "name": "json", + "ext": "json", + "files": json_filename, "stagingDir": stagingdir, } instance.data["representations"].append(json_representation) - self.log.info("Extracted instance '{}' to: {}".format( - instance.name, json_representation)) - + self.log.info( + "Extracted instance '{}' to: {}".format(instance.name, + json_representation) + ) diff --git a/pype/plugins/blender/publish/extract_blend.py b/pype/hosts/blender/plugins/publish/extract_blend.py similarity index 96% rename from pype/plugins/blender/publish/extract_blend.py rename to pype/hosts/blender/plugins/publish/extract_blend.py index a5e76dcf4e..6ba28d039a 100644 --- a/pype/plugins/blender/publish/extract_blend.py +++ b/pype/hosts/blender/plugins/publish/extract_blend.py @@ -1,47 +1,47 @@ -import os -import avalon.blender.workio - -import pype.api - - -class ExtractBlend(pype.api.Extractor): - """Extract a blend file.""" - - label = "Extract Blend" - hosts = ["blender"] - families = ["model", "camera", "rig", "action", "layout", "animation"] - optional = True - - def process(self, instance): - # Define extract output file path - - stagingdir = self.staging_dir(instance) - filename = f"{instance.name}.blend" - filepath = os.path.join(stagingdir, filename) - - # Perform extraction - self.log.info("Performing extraction..") - - # Just save the file to a temporary location. At least for now it's no - # problem to have (possibly) extra stuff in the file. - avalon.blender.workio.save_file(filepath, copy=True) - # - # # Store reference for integration - # if "files" not in instance.data: - # instance.data["files"] = list() - # - # # instance.data["files"].append(filename) - - if "representations" not in instance.data: - instance.data["representations"] = [] - - representation = { - 'name': 'blend', - 'ext': 'blend', - 'files': filename, - "stagingDir": stagingdir, - } - instance.data["representations"].append(representation) - - self.log.info("Extracted instance '%s' to: %s", - instance.name, representation) +import os +import avalon.blender.workio + +import pype.api + + +class ExtractBlend(pype.api.Extractor): + """Extract a blend file.""" + + label = "Extract Blend" + hosts = ["blender"] + families = ["model", "camera", "rig", "action", "layout", "animation"] + optional = True + + def process(self, instance): + # Define extract output file path + + stagingdir = self.staging_dir(instance) + filename = f"{instance.name}.blend" + filepath = os.path.join(stagingdir, filename) + + # Perform extraction + self.log.info("Performing extraction..") + + # Just save the file to a temporary location. At least for now it's no + # problem to have (possibly) extra stuff in the file. + avalon.blender.workio.save_file(filepath, copy=True) + # + # # Store reference for integration + # if "files" not in instance.data: + # instance.data["files"] = list() + # + # # instance.data["files"].append(filename) + + if "representations" not in instance.data: + instance.data["representations"] = [] + + representation = { + 'name': 'blend', + 'ext': 'blend', + 'files': filename, + "stagingDir": stagingdir, + } + instance.data["representations"].append(representation) + + self.log.info("Extracted instance '%s' to: %s", + instance.name, representation) diff --git a/pype/plugins/blender/publish/extract_fbx.py b/pype/hosts/blender/plugins/publish/extract_fbx.py similarity index 100% rename from pype/plugins/blender/publish/extract_fbx.py rename to pype/hosts/blender/plugins/publish/extract_fbx.py diff --git a/pype/plugins/blender/publish/extract_fbx_animation.py b/pype/hosts/blender/plugins/publish/extract_fbx_animation.py similarity index 100% rename from pype/plugins/blender/publish/extract_fbx_animation.py rename to pype/hosts/blender/plugins/publish/extract_fbx_animation.py diff --git a/pype/plugins/blender/publish/increment_workfile_version.py b/pype/hosts/blender/plugins/publish/increment_workfile_version.py similarity index 100% rename from pype/plugins/blender/publish/increment_workfile_version.py rename to pype/hosts/blender/plugins/publish/increment_workfile_version.py diff --git a/pype/plugins/blender/publish/integrate_animation.py b/pype/hosts/blender/plugins/publish/integrate_animation.py similarity index 100% rename from pype/plugins/blender/publish/integrate_animation.py rename to pype/hosts/blender/plugins/publish/integrate_animation.py diff --git a/pype/plugins/blender/publish/validate_mesh_has_uv.py b/pype/hosts/blender/plugins/publish/validate_mesh_has_uv.py similarity index 93% rename from pype/plugins/blender/publish/validate_mesh_has_uv.py rename to pype/hosts/blender/plugins/publish/validate_mesh_has_uv.py index ea5e12918a..c415ea0e0d 100644 --- a/pype/plugins/blender/publish/validate_mesh_has_uv.py +++ b/pype/hosts/blender/plugins/publish/validate_mesh_has_uv.py @@ -3,7 +3,7 @@ from typing import List import bpy import pyblish.api -import pype.hosts.blender.action +import pype.hosts.blender.api.action class ValidateMeshHasUvs(pyblish.api.InstancePlugin): @@ -14,7 +14,7 @@ class ValidateMeshHasUvs(pyblish.api.InstancePlugin): families = ["model"] category = "geometry" label = "Mesh Has UV's" - actions = [pype.hosts.blender.action.SelectInvalidAction] + actions = [pype.hosts.blender.api.action.SelectInvalidAction] optional = True @staticmethod diff --git a/pype/plugins/blender/publish/validate_mesh_no_negative_scale.py b/pype/hosts/blender/plugins/publish/validate_mesh_no_negative_scale.py similarity index 89% rename from pype/plugins/blender/publish/validate_mesh_no_negative_scale.py rename to pype/hosts/blender/plugins/publish/validate_mesh_no_negative_scale.py index 77057c0e68..bbce37f3db 100644 --- a/pype/plugins/blender/publish/validate_mesh_no_negative_scale.py +++ b/pype/hosts/blender/plugins/publish/validate_mesh_no_negative_scale.py @@ -3,7 +3,7 @@ from typing import List import bpy import pyblish.api -import pype.hosts.blender.action +import pype.hosts.blender.api.action class ValidateMeshNoNegativeScale(pyblish.api.Validator): @@ -13,7 +13,7 @@ class ValidateMeshNoNegativeScale(pyblish.api.Validator): hosts = ["blender"] families = ["model"] label = "Mesh No Negative Scale" - actions = [pype.hosts.blender.action.SelectInvalidAction] + actions = [pype.hosts.blender.api.action.SelectInvalidAction] @staticmethod def get_invalid(instance) -> List: