fix imports

This commit is contained in:
Milan Kolar 2020-03-19 18:07:36 +01:00
parent b58adfec31
commit 05441eb2fe
8 changed files with 65 additions and 64 deletions

View file

@ -4,6 +4,8 @@ import bpy
from avalon import api
from avalon.blender import Creator, lib
import pype.blender.plugin
class CreateAction(Creator):

View file

@ -4,6 +4,8 @@ import bpy
from avalon import api
from avalon.blender import Creator, lib
import pype.blender.plugin
class CreateAnimation(Creator):

View file

@ -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"]

View file

@ -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:

View file

@ -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"]

View file

@ -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

View file

@ -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.

View file

@ -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