diff --git a/pype/plugins/blender/create/create_action.py b/pype/plugins/blender/create/create_action.py index 88ecebdfff..64dfe9ff90 100644 --- a/pype/plugins/blender/create/create_action.py +++ b/pype/plugins/blender/create/create_action.py @@ -4,6 +4,8 @@ import bpy from avalon import api from avalon.blender import Creator, lib +import pype.blender.plugin + class CreateAction(Creator): diff --git a/pype/plugins/blender/create/create_animation.py b/pype/plugins/blender/create/create_animation.py index 14a50ba5ea..0758db280f 100644 --- a/pype/plugins/blender/create/create_animation.py +++ b/pype/plugins/blender/create/create_animation.py @@ -4,6 +4,8 @@ import bpy from avalon import api from avalon.blender import Creator, lib +import pype.blender.plugin + class CreateAnimation(Creator): diff --git a/pype/plugins/blender/create/create_model.py b/pype/plugins/blender/create/create_model.py index a3b2ffc55b..7a53f215f2 100644 --- a/pype/plugins/blender/create/create_model.py +++ b/pype/plugins/blender/create/create_model.py @@ -4,7 +4,7 @@ import bpy from avalon import api from avalon.blender import Creator, lib - +import pype.blender.plugin class CreateModel(Creator): """Polygonal static geometry""" @@ -15,7 +15,6 @@ class CreateModel(Creator): icon = "cube" def process(self): - import pype.blender asset = self.data["asset"] subset = self.data["subset"] diff --git a/pype/plugins/blender/create/create_rig.py b/pype/plugins/blender/create/create_rig.py index f630c63966..b5860787ea 100644 --- a/pype/plugins/blender/create/create_rig.py +++ b/pype/plugins/blender/create/create_rig.py @@ -4,6 +4,7 @@ import bpy from avalon import api from avalon.blender import Creator, lib +import pype.blender.plugin class CreateRig(Creator): @@ -42,16 +43,16 @@ class CreateRig(Creator): self.data['task'] = api.Session.get('AVALON_TASK') lib.imprint(collection, self.data) - # Add the rig object and all the children meshes to - # a set and link them all at the end to avoid duplicates. + # Add the rig object and all the children meshes to + # a set and link them all at the end to avoid duplicates. # Blender crashes if trying to link an object that is already linked. - # This links automatically the children meshes if they were not + # This links automatically the children meshes if they were not # selected, and doesn't link them twice if they, insted, # were manually selected by the user. objects_to_link = set() if (self.options or {}).get("useSelection"): - + for obj in lib.get_selection(): objects_to_link.add( obj ) @@ -75,7 +76,7 @@ class CreateRig(Creator): # if len( custom_shapes ) > 0: # widgets_collection = bpy.data.collections.new(name="Widgets") - + # collection.children.link(widgets_collection) # for custom_shape in custom_shapes: diff --git a/pype/plugins/blender/load/load_action.py b/pype/plugins/blender/load/load_action.py index 747bcd47f5..afde8b90a1 100644 --- a/pype/plugins/blender/load/load_action.py +++ b/pype/plugins/blender/load/load_action.py @@ -5,10 +5,9 @@ from pathlib import Path from pprint import pformat from typing import Dict, List, Optional -import avalon.blender.pipeline +from avalon import api, blender import bpy -import pype.blender -from avalon import api +import pype.blender.plugin logger = logging.getLogger("pype").getChild("blender").getChild("load_action") @@ -50,7 +49,7 @@ class BlendActionLoader(pype.blender.AssetLoader): container = bpy.data.collections.new(lib_container) container.name = container_name - avalon.blender.pipeline.containerise_existing( + blender.pipeline.containerise_existing( container, name, namespace, @@ -59,7 +58,7 @@ class BlendActionLoader(pype.blender.AssetLoader): ) container_metadata = container.get( - avalon.blender.pipeline.AVALON_PROPERTY) + blender.pipeline.AVALON_PROPERTY) container_metadata["libpath"] = libpath container_metadata["lib_container"] = lib_container @@ -89,16 +88,16 @@ class BlendActionLoader(pype.blender.AssetLoader): obj.animation_data.action.make_local() - if not obj.get(avalon.blender.pipeline.AVALON_PROPERTY): + if not obj.get(blender.pipeline.AVALON_PROPERTY): - obj[avalon.blender.pipeline.AVALON_PROPERTY] = dict() + obj[blender.pipeline.AVALON_PROPERTY] = dict() - avalon_info = obj[avalon.blender.pipeline.AVALON_PROPERTY] + avalon_info = obj[blender.pipeline.AVALON_PROPERTY] avalon_info.update({"container_name": container_name}) objects_list.append(obj) - animation_container.pop(avalon.blender.pipeline.AVALON_PROPERTY) + animation_container.pop(blender.pipeline.AVALON_PROPERTY) # Save the list of objects in the metadata container container_metadata["objects"] = objects_list @@ -153,7 +152,7 @@ class BlendActionLoader(pype.blender.AssetLoader): ) collection_metadata = collection.get( - avalon.blender.pipeline.AVALON_PROPERTY) + blender.pipeline.AVALON_PROPERTY) collection_libpath = collection_metadata["libpath"] normalized_collection_libpath = ( @@ -224,16 +223,16 @@ class BlendActionLoader(pype.blender.AssetLoader): strip.action = obj.animation_data.action strip.action_frame_end = obj.animation_data.action.frame_range[1] - if not obj.get(avalon.blender.pipeline.AVALON_PROPERTY): + if not obj.get(blender.pipeline.AVALON_PROPERTY): - obj[avalon.blender.pipeline.AVALON_PROPERTY] = dict() + obj[blender.pipeline.AVALON_PROPERTY] = dict() - avalon_info = obj[avalon.blender.pipeline.AVALON_PROPERTY] + avalon_info = obj[blender.pipeline.AVALON_PROPERTY] avalon_info.update({"container_name": collection.name}) objects_list.append(obj) - animation_container.pop(avalon.blender.pipeline.AVALON_PROPERTY) + animation_container.pop(blender.pipeline.AVALON_PROPERTY) # Save the list of objects in the metadata container collection_metadata["objects"] = objects_list @@ -266,7 +265,7 @@ class BlendActionLoader(pype.blender.AssetLoader): ) collection_metadata = collection.get( - avalon.blender.pipeline.AVALON_PROPERTY) + blender.pipeline.AVALON_PROPERTY) objects = collection_metadata["objects"] lib_container = collection_metadata["lib_container"] diff --git a/pype/plugins/blender/load/load_animation.py b/pype/plugins/blender/load/load_animation.py index 0610517b67..ec3e24443f 100644 --- a/pype/plugins/blender/load/load_animation.py +++ b/pype/plugins/blender/load/load_animation.py @@ -5,15 +5,15 @@ from pathlib import Path from pprint import pformat from typing import Dict, List, Optional -import avalon.blender.pipeline +from avalon import api, blender import bpy -import pype.blender -from avalon import api +import pype.blender.plugin + logger = logging.getLogger("pype").getChild("blender").getChild("load_animation") -class BlendAnimationLoader(pype.blender.AssetLoader): +class BlendAnimationLoader(pype.blender.plugin.AssetLoader): """Load animations from a .blend file. Warning: @@ -75,16 +75,16 @@ class BlendAnimationLoader(pype.blender.AssetLoader): obj.animation_data.action.make_local() - if not obj.get(avalon.blender.pipeline.AVALON_PROPERTY): + if not obj.get(blender.pipeline.AVALON_PROPERTY): - obj[avalon.blender.pipeline.AVALON_PROPERTY] = dict() + obj[blender.pipeline.AVALON_PROPERTY] = dict() - avalon_info = obj[avalon.blender.pipeline.AVALON_PROPERTY] + avalon_info = obj[blender.pipeline.AVALON_PROPERTY] avalon_info.update({"container_name": container_name}) objects_list.append(obj) - animation_container.pop( avalon.blender.pipeline.AVALON_PROPERTY ) + animation_container.pop( blender.pipeline.AVALON_PROPERTY ) bpy.ops.object.select_all(action='DESELECT') @@ -112,7 +112,7 @@ class BlendAnimationLoader(pype.blender.AssetLoader): container = bpy.data.collections.new(lib_container) container.name = container_name - avalon.blender.pipeline.containerise_existing( + blender.pipeline.containerise_existing( container, name, namespace, @@ -121,7 +121,7 @@ class BlendAnimationLoader(pype.blender.AssetLoader): ) container_metadata = container.get( - avalon.blender.pipeline.AVALON_PROPERTY) + blender.pipeline.AVALON_PROPERTY) container_metadata["libpath"] = libpath container_metadata["lib_container"] = lib_container @@ -179,7 +179,7 @@ class BlendAnimationLoader(pype.blender.AssetLoader): ) collection_metadata = collection.get( - avalon.blender.pipeline.AVALON_PROPERTY) + blender.pipeline.AVALON_PROPERTY) collection_libpath = collection_metadata["libpath"] normalized_collection_libpath = ( @@ -239,12 +239,12 @@ class BlendAnimationLoader(pype.blender.AssetLoader): ) collection_metadata = collection.get( - avalon.blender.pipeline.AVALON_PROPERTY) + blender.pipeline.AVALON_PROPERTY) objects = collection_metadata["objects"] lib_container = collection_metadata["lib_container"] self._remove(self, objects, lib_container) - + bpy.data.collections.remove(collection) return True diff --git a/pype/plugins/blender/load/load_model.py b/pype/plugins/blender/load/load_model.py index 10904a1f7b..b8b6b9b956 100644 --- a/pype/plugins/blender/load/load_model.py +++ b/pype/plugins/blender/load/load_model.py @@ -5,15 +5,14 @@ from pathlib import Path from pprint import pformat from typing import Dict, List, Optional -import avalon.blender.pipeline +from avalon import api, blender import bpy -import pype.blender -from avalon import api +import pype.blender.plugin logger = logging.getLogger("pype").getChild("blender").getChild("load_model") -class BlendModelLoader(pype.blender.AssetLoader): +class BlendModelLoader(pype.blender.plugin.AssetLoader): """Load models from a .blend file. Because they come from a .blend file we can simply link the collection that @@ -67,16 +66,16 @@ class BlendModelLoader(pype.blender.AssetLoader): material_slot.material.make_local() - if not obj.get(avalon.blender.pipeline.AVALON_PROPERTY): + if not obj.get(blender.pipeline.AVALON_PROPERTY): - obj[avalon.blender.pipeline.AVALON_PROPERTY] = dict() + obj[blender.pipeline.AVALON_PROPERTY] = dict() - avalon_info = obj[avalon.blender.pipeline.AVALON_PROPERTY] + avalon_info = obj[blender.pipeline.AVALON_PROPERTY] avalon_info.update({"container_name": container_name}) objects_list.append(obj) - model_container.pop( avalon.blender.pipeline.AVALON_PROPERTY ) + model_container.pop( blender.pipeline.AVALON_PROPERTY ) bpy.ops.object.select_all(action='DESELECT') @@ -104,7 +103,7 @@ class BlendModelLoader(pype.blender.AssetLoader): collection = bpy.data.collections.new(lib_container) collection.name = container_name - avalon.blender.pipeline.containerise_existing( + blender.pipeline.containerise_existing( collection, name, namespace, @@ -113,7 +112,7 @@ class BlendModelLoader(pype.blender.AssetLoader): ) container_metadata = collection.get( - avalon.blender.pipeline.AVALON_PROPERTY) + blender.pipeline.AVALON_PROPERTY) container_metadata["libpath"] = libpath container_metadata["lib_container"] = lib_container @@ -169,7 +168,7 @@ class BlendModelLoader(pype.blender.AssetLoader): ) collection_metadata = collection.get( - avalon.blender.pipeline.AVALON_PROPERTY) + blender.pipeline.AVALON_PROPERTY) collection_libpath = collection_metadata["libpath"] objects = collection_metadata["objects"] lib_container = collection_metadata["lib_container"] @@ -221,7 +220,7 @@ class BlendModelLoader(pype.blender.AssetLoader): ) collection_metadata = collection.get( - avalon.blender.pipeline.AVALON_PROPERTY) + blender.pipeline.AVALON_PROPERTY) objects = collection_metadata["objects"] lib_container = collection_metadata["lib_container"] @@ -232,7 +231,7 @@ class BlendModelLoader(pype.blender.AssetLoader): return True -class CacheModelLoader(pype.blender.AssetLoader): +class CacheModelLoader(pype.blender.plugin.AssetLoader): """Load cache models. Stores the imported asset in a collection named after the asset. diff --git a/pype/plugins/blender/load/load_rig.py b/pype/plugins/blender/load/load_rig.py index dcb70da6d8..44d47b41a1 100644 --- a/pype/plugins/blender/load/load_rig.py +++ b/pype/plugins/blender/load/load_rig.py @@ -5,15 +5,14 @@ from pathlib import Path from pprint import pformat from typing import Dict, List, Optional -import avalon.blender.pipeline +from avalon import api, blender import bpy -import pype.blender -from avalon import api +import pype.blender.plugin logger = logging.getLogger("pype").getChild("blender").getChild("load_model") -class BlendRigLoader(pype.blender.AssetLoader): +class BlendRigLoader(pype.blender.plugin.AssetLoader): """Load rigs from a .blend file. Because they come from a .blend file we can simply link the collection that @@ -30,7 +29,7 @@ class BlendRigLoader(pype.blender.AssetLoader): label = "Link Rig" icon = "code-fork" color = "orange" - + @staticmethod def _remove(self, objects, lib_container): @@ -60,7 +59,7 @@ class BlendRigLoader(pype.blender.AssetLoader): meshes = [obj for obj in rig_container.objects if obj.type == 'MESH'] armatures = [obj for obj in rig_container.objects if obj.type == 'ARMATURE'] - + objects_list = [] assert(len(armatures) == 1) @@ -74,11 +73,11 @@ class BlendRigLoader(pype.blender.AssetLoader): obj.data.make_local() - if not obj.get(avalon.blender.pipeline.AVALON_PROPERTY): + if not obj.get(blender.pipeline.AVALON_PROPERTY): - obj[avalon.blender.pipeline.AVALON_PROPERTY] = dict() + obj[blender.pipeline.AVALON_PROPERTY] = dict() - avalon_info = obj[avalon.blender.pipeline.AVALON_PROPERTY] + avalon_info = obj[blender.pipeline.AVALON_PROPERTY] avalon_info.update({"container_name": container_name}) if obj.type == 'ARMATURE' and action is not None: @@ -86,8 +85,8 @@ class BlendRigLoader(pype.blender.AssetLoader): obj.animation_data.action = action objects_list.append(obj) - - rig_container.pop( avalon.blender.pipeline.AVALON_PROPERTY ) + + rig_container.pop( blender.pipeline.AVALON_PROPERTY ) bpy.ops.object.select_all(action='DESELECT') @@ -115,7 +114,7 @@ class BlendRigLoader(pype.blender.AssetLoader): container = bpy.data.collections.new(lib_container) container.name = container_name - avalon.blender.pipeline.containerise_existing( + blender.pipeline.containerise_existing( container, name, namespace, @@ -124,7 +123,7 @@ class BlendRigLoader(pype.blender.AssetLoader): ) container_metadata = container.get( - avalon.blender.pipeline.AVALON_PROPERTY) + blender.pipeline.AVALON_PROPERTY) container_metadata["libpath"] = libpath container_metadata["lib_container"] = lib_container @@ -182,7 +181,7 @@ class BlendRigLoader(pype.blender.AssetLoader): ) collection_metadata = collection.get( - avalon.blender.pipeline.AVALON_PROPERTY) + blender.pipeline.AVALON_PROPERTY) collection_libpath = collection_metadata["libpath"] objects = collection_metadata["objects"] lib_container = collection_metadata["lib_container"] @@ -243,12 +242,12 @@ class BlendRigLoader(pype.blender.AssetLoader): ) collection_metadata = collection.get( - avalon.blender.pipeline.AVALON_PROPERTY) + blender.pipeline.AVALON_PROPERTY) objects = collection_metadata["objects"] lib_container = collection_metadata["lib_container"] self._remove(self, objects, lib_container) - + bpy.data.collections.remove(collection) return True