Merge pull request #66 from aardschok/PLN-0058

Update Yeti pipeline
This commit is contained in:
Wijnand Koreman 2017-12-07 16:42:15 +01:00 committed by GitHub
commit 41f07dbdb4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 14 deletions

View file

@ -46,7 +46,7 @@ class YetiCacheLoader(api.Loader):
node_data = fursettings["nodes"]
nodes = self.create_nodes(namespace, node_data)
group_name = "{}:{}".format(namespace, asset["name"])
group_name = "{}:{}".format(namespace, name)
group_node = cmds.group(nodes, name=group_name)
nodes.append(group_node)
@ -84,15 +84,26 @@ class YetiCacheLoader(api.Loader):
def update(self, container, representation):
path = api.get_representation_path(representation)
namespace = "{}:".format(container["namespace"])
members = cmds.sets(container['objectName'], query=True)
yeti_node = cmds.ls(members, type="pgYetiMaya", long=True)
yeti_node = cmds.ls(members, type="pgYetiMaya")
# TODO: Count the amount of nodes cached
# To ensure new nodes get created or old nodes get destroyed
for node in yeti_node:
node_name = node.split(":")[-1]
tmp_cache = os.path.join(path, "{}.%04d.fur".format(node_name))
# Remove local given namespace
node_name = node.split(namespace, 1)[-1]
file_name = node_name.replace(":", "_")
# Check if the node has a cache
tmp_cache = os.path.join(path, "{}.%04d.fur".format(file_name))
fpath = self.validate_cache(os.path.normpath(tmp_cache))
# Update the attribute
cmds.setAttr("{}.cacheFileName".format(node), fpath, type="string")
# Update the container
cmds.setAttr("{}.representation".format(container["objectName"]),
str(representation["_id"]),
type="string")
@ -194,6 +205,9 @@ class YetiCacheLoader(api.Loader):
# Enable the cache by setting the file mode
cmds.setAttr("%s.fileMode" % yeti_node, 1)
# Connect to the time node
cmds.connectAttr("time1.outTime", "%s.currentTime" % yeti_node)
nodes.append(yeti_node)
nodes.append(transform_node)

View file

@ -40,7 +40,6 @@ class CollectYetiRig(pyblish.api.InstancePlugin):
input_shapes = cmds.ls(input_nodes, long=True, noIntermediate=True)
# Store all connections
print "input shape:", input_shapes
connections = cmds.listConnections(input_shapes,
source=True,
destination=False,

View file

@ -13,7 +13,7 @@ from cb.utils.maya import context
def disconnected_attributes(settings, members):
members = cmds.ls(members, long=True)
original_connection = []
original_connections = []
try:
for input in settings["inputs"]:
@ -40,14 +40,13 @@ def disconnected_attributes(settings, members):
continue
cmds.disconnectAttr(src_attribute, dst_attribute)
original_connection.append([src_attribute, dst_attribute])
original_connections.append([src_attribute, dst_attribute])
yield
finally:
# restore connections
for connection in original_connection:
src, dest = connection
for connection in original_connections:
try:
cmds.connectAttr(dest, src)
cmds.connectAttr(connection[0], connection[1])
except Exception as e:
print e,
continue
@ -102,9 +101,10 @@ class ExtractYetiRig(colorbleed.api.Extractor):
# Get input_SET members
input_set = [i for i in instance if i == "input_SET"]
members = cmds.sets(input_set[0], query=True)
# Get all items
members = cmds.listRelatives(members, ad=True, fullPath=True)
set_members = cmds.sets(input_set[0], query=True)
members = cmds.listRelatives(set_members, ad=True, fullPath=True) or []
members += cmds.ls(set_members, long=True)
nodes = instance.data["setMembers"]
with disconnected_attributes(settings, members):

View file

@ -1,5 +1,3 @@
import pprint
from maya import cmds
import pyblish.api