get assets from ref nodes

This commit is contained in:
Ondrej Samohel 2021-08-17 16:25:51 +02:00 committed by Ondřej Samohel
parent 50c5700f57
commit f28a1e484a
No known key found for this signature in database
GPG key ID: 02376E18990A97C6

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