mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 12:54:40 +01:00
improved loaders
This commit is contained in:
parent
115a85f391
commit
c4cf4b3917
2 changed files with 34 additions and 28 deletions
|
|
@ -1,4 +1,8 @@
|
|||
from avalon import api
|
||||
import os
|
||||
|
||||
from maya import cmds
|
||||
|
||||
from avalon import api, maya
|
||||
|
||||
|
||||
class AbcLoader(api.Loader):
|
||||
|
|
@ -13,12 +17,17 @@ class AbcLoader(api.Loader):
|
|||
color = "orange"
|
||||
|
||||
def process(self, name, namespace, context, data):
|
||||
from maya import cmds
|
||||
|
||||
cmds.loadPlugin("AbcImport.mll", quiet=True)
|
||||
# Prevent identical alembic nodes from being shared
|
||||
# Create unique namespace for the cameras
|
||||
|
||||
# Get name from asset being loaded
|
||||
assert "_" in name, "Naming convention not followed"
|
||||
assetname = "{}_".format(name.split("_")[0])
|
||||
namespace = maya.unique_namespace(assetname,
|
||||
format="%03d",
|
||||
suffix="_abc")
|
||||
nodes = cmds.file(self.fname,
|
||||
namespace=namespace,
|
||||
sharedReferenceFile=False,
|
||||
|
|
@ -27,8 +36,13 @@ class AbcLoader(api.Loader):
|
|||
reference=True,
|
||||
returnNewNodes=True)
|
||||
|
||||
# load colorbleed ID attribute
|
||||
self.lock_id_attr(nodes)
|
||||
|
||||
self[:] = nodes
|
||||
|
||||
def lock_id_attr(self):
|
||||
pass
|
||||
|
||||
class CurvesLoader(api.Loader):
|
||||
"""Specific loader of Curves for the avalon.animation family"""
|
||||
|
|
@ -77,24 +91,19 @@ class CurvesLoader(api.Loader):
|
|||
])
|
||||
|
||||
with maya.maintained_selection():
|
||||
cmds.select(
|
||||
control_set,
|
||||
replace=True,
|
||||
cmds.select(control_set,
|
||||
replace=True,
|
||||
# Support controllers being embedded in
|
||||
# additional selection sets.
|
||||
noExpand=False)
|
||||
|
||||
# Support controllers being embedded in
|
||||
# additional selection sets.
|
||||
noExpand=False
|
||||
)
|
||||
|
||||
nodes = cmds.file(
|
||||
self.fname,
|
||||
i=True,
|
||||
type="atomImport",
|
||||
renameAll=True,
|
||||
namespace=namespace,
|
||||
options=options,
|
||||
returnNewNodes=True,
|
||||
)
|
||||
nodes = cmds.file(self.fname,
|
||||
i=True,
|
||||
type="atomImport",
|
||||
renameAll=True,
|
||||
namespace=namespace,
|
||||
options=options,
|
||||
returnNewNodes=True)
|
||||
|
||||
self[:] = nodes + cmds.sets(container, query=True) + [container]
|
||||
|
||||
|
|
@ -102,8 +111,7 @@ class CurvesLoader(api.Loader):
|
|||
self._post_process(name, namespace, context, data)
|
||||
|
||||
def _post_process(self, name, namespace, context, data):
|
||||
import os
|
||||
from maya import cmds
|
||||
|
||||
from avalon import maya, io
|
||||
|
||||
# Task-dependent post-process
|
||||
|
|
@ -137,6 +145,7 @@ class CurvesLoader(api.Loader):
|
|||
cmds.select([output, controls], noExpand=True)
|
||||
|
||||
dependencies = [context["representation"]["_id"]]
|
||||
dependencies = " ".join(str(d) for d in dependencies)
|
||||
name = "anim{}_".format(dependency["name"].title())
|
||||
|
||||
# TODO(marcus): Hardcoding the family here, better separate this.
|
||||
|
|
@ -144,8 +153,7 @@ class CurvesLoader(api.Loader):
|
|||
assert len(family) == 1, ("None or multiple animation "
|
||||
"families found")
|
||||
family = family[0]
|
||||
maya.create(
|
||||
name=maya.unique_name(name, suffix="_SET"),
|
||||
family=family,
|
||||
options={"useSelection": True},
|
||||
data={"dependencies": " ".join(str(d) for d in dependencies)})
|
||||
maya.create(name=maya.unique_name(name, suffix="_SET"),
|
||||
family=family,
|
||||
options={"useSelection": True},
|
||||
data={"dependencies": dependencies})
|
||||
|
|
|
|||
|
|
@ -46,8 +46,6 @@ class ModelGPUCacheLoader(api.Loader):
|
|||
|
||||
def process(self, name, namespace, context, data):
|
||||
|
||||
from maya import cmds
|
||||
|
||||
# todo: This will likely not be entirely safe with "containerize"
|
||||
# also this cannot work in the manager because it only works
|
||||
# on references at the moment!
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue