Merge pull request #1855 from pypeclub/bugfix/maya-minimize-ref-connections

This commit is contained in:
Milan Kolar 2021-08-17 17:07:35 +02:00 committed by GitHub
commit 53bafa319f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 42 additions and 27 deletions

View file

@ -99,14 +99,24 @@ class ReferenceLoader(api.Loader):
nodes = self[:]
if not nodes:
return
loaded_containers.append(containerise(
name=name,
namespace=namespace,
nodes=nodes,
context=context,
loader=self.__class__.__name__
))
# FIXME: there is probably better way to do this for looks.
if "look" in self.families:
loaded_containers.append(containerise(
name=name,
namespace=namespace,
nodes=nodes,
context=context,
loader=self.__class__.__name__
))
else:
ref_node = self._get_reference_node(nodes)
loaded_containers.append(containerise(
name=name,
namespace=namespace,
nodes=[ref_node],
context=context,
loader=self.__class__.__name__
))
c += 1
namespace = None
@ -235,9 +245,6 @@ class ReferenceLoader(api.Loader):
self.log.info("Setting %s.verticesOnlySet to False", node)
cmds.setAttr("{}.verticesOnlySet".format(node), False)
# Add new nodes of the reference to the container
cmds.sets(content, forceElement=node)
# Remove any placeHolderList attribute entries from the set that
# are remaining from nodes being removed from the referenced file.
members = cmds.sets(node, query=True)

View file

@ -103,12 +103,19 @@ def create_asset_id_hash(nodes):
"""
node_id_hash = defaultdict(list)
for node in nodes:
value = lib.get_id(node)
if value is None:
continue
# iterate over content of reference node
if cmds.nodeType(node) == "reference":
ref_hashes = create_asset_id_hash(
cmds.referenceQuery(node, nodes=True))
for asset_id, ref_nodes in ref_hashes.items():
node_id_hash[asset_id] += ref_nodes
else:
value = lib.get_id(node)
if value is None:
continue
asset_id = value.split(":")[0]
node_id_hash[asset_id].append(node)
asset_id = value.split(":")[0]
node_id_hash[asset_id].append(node)
return dict(node_id_hash)
@ -135,18 +142,19 @@ def create_items_from_nodes(nodes):
id_hashes = create_asset_id_hash(nodes)
# get ids from alembic
vray_proxy_nodes = cmds.ls(nodes, type="VRayProxy")
for vp in vray_proxy_nodes:
path = cmds.getAttr("{}.fileName".format(vp))
ids = vray_proxies.get_alembic_ids_cache(path)
parent_id = {}
for k, _ in ids.items():
pid = k.split(":")[0]
if not parent_id.get(pid):
parent_id.update({pid: [vp]})
if cmds.pluginInfo('vrayformaya', query=True, loaded=True):
vray_proxy_nodes = cmds.ls(nodes, type="VRayProxy")
for vp in vray_proxy_nodes:
path = cmds.getAttr("{}.fileName".format(vp))
ids = vray_proxies.get_alembic_ids_cache(path)
parent_id = {}
for k, _ in ids.items():
pid = k.split(":")[0]
if not parent_id.get(pid):
parent_id.update({pid: [vp]})
print("Adding ids from alembic {}".format(path))
id_hashes.update(parent_id)
print("Adding ids from alembic {}".format(path))
id_hashes.update(parent_id)
if not id_hashes:
return asset_view_items