Merge pull request #58 from aardschok/PLN-0053

Updated Yeti Rig / Cache Loader
This commit is contained in:
Wijnand Koreman 2017-11-30 17:09:15 +01:00 committed by GitHub
commit 353118b618
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 49 deletions

View file

@ -124,14 +124,19 @@ class YetiCacheLoader(api.Loader):
path = api.get_representation_path(representation)
members = cmds.sets(container['objectName'], query=True)
yeti_node = cmds.ls(members, type="pgYetiMaya", long=True)
all_members = cmds.listRelatives(members, ad=True)
yeti_node = cmds.ls(all_members, type="pgYetiMaya", long=True)
for node in yeti_node:
node_name = node.split(":")[-1]
tmp_cache = os.path.join(path, "{}.%04d.fur".format(node_name))
fpath = self.validate_cache(tmp_cache)
fpath = self.validate_cache(os.path.normpath(tmp_cache))
cmds.setAttr("{}.cacheFileName".format(node), fpath, type="string")
cmds.setAttr("{}.representation".format(container["objectName"]),
str(representation["_id"]),
type="string")
# helper functions
def create_namespace(self, asset):

View file

@ -26,52 +26,6 @@ class YetiRigLoader(colorbleed.maya.plugin.ReferenceLoader):
self[:] = nodes
self._post_process(name, name, context, data)
self.log.info("Yeti Rig Connection Manager will be available soon")
return nodes
def _post_process(self, name, namespace, context, data):
import os
import json
import maya.cmds as cmds
import avalon.maya.lib as lib
# Get json data
fname, ext = os.path.splitext(self.fname)
data_file = "{}.rigsettings".format(fname)
with open(data_file, "r") as fp:
rigsettings = json.load(fp)
# Get content from input_SET
input_set = [i for i in self if "input_SET" in i]
assert len(input_set) == 1, "Could not find input_SET!"
members = cmds.ls(cmds.sets(input_set[0], query=True), long=True)
for input in rigsettings["inputs"]:
# Find input / output mesh
# Ensure the mesh is not it's self
plug_id_matches = lib.lsattr("cbId", input["plugID"]) or []
plug_mesh = [i for i in plug_id_matches if i not in members]
# Ensure connection goes to the correct mesh (might be duplicates)
socket_id_matches = lib.lsattr("cbId", input["socketID"]) or []
socket_mesh = [i for i in socket_id_matches if i in members]
if len(plug_mesh) == 0:
return
# Connect meshes, list of attributes to connect
socket_attr, plug_attr = input["connections"]
_plug_attr = "{}.{}".format(plug_mesh[0], plug_attr)
_socket_attr = "{}.{}".format(socket_mesh[0], socket_attr)
try:
cmds.connectAttr(_plug_attr, _socket_attr)
except Exception as e:
self.log.wanring(e)
continue
return