diff --git a/openpype/hosts/maya/plugins/publish/collect_arnold_scene_source.py b/openpype/hosts/maya/plugins/publish/collect_arnold_scene_source.py index ab15d0419f..0845f653b1 100644 --- a/openpype/hosts/maya/plugins/publish/collect_arnold_scene_source.py +++ b/openpype/hosts/maya/plugins/publish/collect_arnold_scene_source.py @@ -22,9 +22,10 @@ class CollectArnoldSceneSource(pyblish.api.InstancePlugin): self.log.warning("Skipped empty instance: \"%s\" " % objset) continue if objset.endswith("content_SET"): - set_members = get_all_children(cmds.ls(members, long=True)) - instance.data["contentMembers"] = set_members - self.log.debug("content members: {}".format(set_members)) + members = cmds.ls(members, long=True) + children = get_all_children(members) + instance.data["contentMembers"] = children + self.log.debug("content members: {}".format(children)) elif objset.endswith("proxy_SET"): set_members = get_all_children(cmds.ls(members, long=True)) instance.data["proxy"] = set_members diff --git a/openpype/hosts/maya/plugins/publish/extract_arnold_scene_source.py b/openpype/hosts/maya/plugins/publish/extract_arnold_scene_source.py index 8344f02894..ce5dc27bbd 100644 --- a/openpype/hosts/maya/plugins/publish/extract_arnold_scene_source.py +++ b/openpype/hosts/maya/plugins/publish/extract_arnold_scene_source.py @@ -126,18 +126,12 @@ class ExtractArnoldSceneSource(publish.Extractor): # Only interested in transforms with shapes. shapes = cmds.listRelatives( - node, shapes=True, fullPath=True + node, shapes=True, noIntermediate=True ) or [] if not shapes: continue - parent = cmds.listRelatives( - node, parent=True, fullPath=True - )[0] duplicate_transform = cmds.duplicate(node)[0] - duplicate_transform = "{}|{}".format( - parent, duplicate_transform - ) if cmds.listRelatives(duplicate_transform, parent=True): duplicate_transform = cmds.parent( diff --git a/openpype/hosts/maya/tools/mayalookassigner/arnold_standin.py b/openpype/hosts/maya/tools/mayalookassigner/arnold_standin.py index dfffbc5961..771b256614 100644 --- a/openpype/hosts/maya/tools/mayalookassigner/arnold_standin.py +++ b/openpype/hosts/maya/tools/mayalookassigner/arnold_standin.py @@ -58,17 +58,17 @@ def calculate_visibility_mask(attributes): return mask -def get_cbid_by_node(path): - """Get cbid from Arnold Scene Source. +def get_id_by_node(path): + """Get node id from Arnold Scene Source. Args: path (string): Path to Arnold Scene Source. Returns: - (dict): Dictionary with node full name/path and CBID. + (dict): Dictionary with node full name/path and id. """ import arnold - results = {} + results = defaultdict(list) arnold.AiBegin() @@ -82,10 +82,7 @@ def get_cbid_by_node(path): node = arnold.AiNodeIteratorGetNext(iter) if arnold.AiNodeIs(node, "polymesh"): node_name = arnold.AiNodeGetName(node) - try: - results[arnold.AiNodeGetStr(node, "cbId")].append(node_name) - except KeyError: - results[arnold.AiNodeGetStr(node, "cbId")] = [node_name] + results[arnold.AiNodeGetStr(node, "cbId")].append(node_name) arnold.AiNodeIteratorDestroy(iter) arnold.AiEnd() @@ -139,7 +136,7 @@ def shading_engine_assignments(shading_engine, attribute, nodes, assignments): def assign_look(standin, subset): log.info("Assigning {} to {}.".format(subset, standin)) - nodes_by_id = get_cbid_by_node(get_standin_path(standin)) + nodes_by_id = get_id_by_node(get_standin_path(standin)) # Group by asset id so we run over the look per asset node_ids_by_asset_id = defaultdict(set) @@ -164,7 +161,8 @@ def assign_look(standin, subset): continue relationships = lib.get_look_relationships(version["_id"]) - shader_nodes, container_node = lib.load_look(version["_id"]) + shader_nodes, container_nodes = lib.load_look(version["_id"]) + container_node = container_nodes[0] namespace = shader_nodes[0].split(":")[0] # Get only the node ids and paths related to this asset diff --git a/openpype/hosts/maya/tools/mayalookassigner/commands.py b/openpype/hosts/maya/tools/mayalookassigner/commands.py index d7061f12e1..d78e31111d 100644 --- a/openpype/hosts/maya/tools/mayalookassigner/commands.py +++ b/openpype/hosts/maya/tools/mayalookassigner/commands.py @@ -121,15 +121,13 @@ def create_asset_id_hash(nodes): path = cmds.getAttr("{}.fileName".format(node)) ids = get_alembic_ids_cache(path) for k, _ in ids.items(): - pid = k.split(":")[0] - if node not in node_id_hash[pid]: - node_id_hash[pid].append(node) + id = k.split(":")[0] + node_id_hash[id].append(node) elif shapes and cmds.nodeType(shapes[0]) == "aiStandIn": path = arnold_standin.get_standin_path(shapes[0]) - for id, _ in arnold_standin.get_cbid_by_node(path).items(): - pid = id.split(":")[0] - if shapes[0] not in node_id_hash[pid]: - node_id_hash[pid].append(shapes[0]) + for id, _ in arnold_standin.get_id_by_node(path).items(): + id = id.split(":")[0] + node_id_hash[id].append(shapes[0]) else: value = lib.get_id(node) if value is None: diff --git a/openpype/hosts/maya/tools/mayalookassigner/vray_proxies.py b/openpype/hosts/maya/tools/mayalookassigner/vray_proxies.py index 6ee618f37a..1d2ec5fd87 100644 --- a/openpype/hosts/maya/tools/mayalookassigner/vray_proxies.py +++ b/openpype/hosts/maya/tools/mayalookassigner/vray_proxies.py @@ -11,7 +11,7 @@ from maya import cmds from openpype.client import get_last_version_by_subset_name from openpype.pipeline import legacy_io -from openpype.hosts.maya import api +import openpype.hosts.maya.lib as maya_lib from . import lib @@ -189,8 +189,10 @@ def vrayproxy_assign_look(vrayproxy, subset="lookDefault"): node_id: nodes_by_id[node_id] for node_id in node_ids } edits = list( - api.lib.iter_shader_edits( - relationships, shadernodes, asset_nodes_by_id)) + maya_lib.iter_shader_edits( + relationships, shadernodes, asset_nodes_by_id + ) + ) # Create assignments assignments = {}