move blender plugins to host folder

This commit is contained in:
Milan Kolar 2021-01-28 11:44:13 +01:00
parent b2e152a16f
commit a9de95dd7c
25 changed files with 104 additions and 98 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -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}"
)

View file

@ -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}"
)

View file

@ -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}"
)

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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