From b86201546fbd498c966ccda59d659b9f61ca8da6 Mon Sep 17 00:00:00 2001 From: Bo Zhou Date: Fri, 4 Mar 2022 18:16:19 +0900 Subject: [PATCH 01/56] create dummy creator plugin for multiverse usd --- .../hosts/maya/plugins/create/create_multiverse_usd.py | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 openpype/hosts/maya/plugins/create/create_multiverse_usd.py diff --git a/openpype/hosts/maya/plugins/create/create_multiverse_usd.py b/openpype/hosts/maya/plugins/create/create_multiverse_usd.py new file mode 100644 index 0000000000..2dc57823f1 --- /dev/null +++ b/openpype/hosts/maya/plugins/create/create_multiverse_usd.py @@ -0,0 +1,10 @@ +from openpype.hosts.maya.api import plugin + + +class CreateMultiverseUsd(plugin.Creator): + """Multiverse USD data""" + + name = "usd" + label = "Multiverse USD" + family = "usd" + icon = "cubes" From 2cb1925790555c7bea45e343ebce7ac25cd7d664 Mon Sep 17 00:00:00 2001 From: Bo Zhou Date: Fri, 4 Mar 2022 18:16:48 +0900 Subject: [PATCH 02/56] create first version of multiverse usd extractor --- .../plugins/publish/extract_multiverse_usd.py | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 openpype/hosts/maya/plugins/publish/extract_multiverse_usd.py diff --git a/openpype/hosts/maya/plugins/publish/extract_multiverse_usd.py b/openpype/hosts/maya/plugins/publish/extract_multiverse_usd.py new file mode 100644 index 0000000000..72b1dcbbe5 --- /dev/null +++ b/openpype/hosts/maya/plugins/publish/extract_multiverse_usd.py @@ -0,0 +1,54 @@ +import os + +import avalon.maya +import openpype.api + +from maya import cmds + + +class ExtractMultiverseUsd(openpype.api.Extractor): + """Extractor for USD by Multiverse.""" + + label = "Extract Multiverse USD" + hosts = ["maya"] + families = ["usd"] + + def process(self, instance): + # Load plugin firstly + cmds.loadPlugin("MultiverseForMaya", quiet=True) + + # Define output file path + staging_dir = self.staging_dir(instance) + file_name = "{}.usd".format(instance.name) + file_path = os.path.join(staging_dir, file_name) + file_path = file_path.replace('\\', '/') + + # Perform extraction + self.log.info("Performing extraction ...") + + with avalon.maya.maintained_selection(): + members = instance.data("setMembers") + members = cmds.ls(members, + dag=True, + shapes=True, + type=("mesh"), + noIntermediate=True, + long=True) + + # TODO: Deal with asset, composition, overide with options. + import multiverse + options = multiverse.AssetWriteOptions() + multiverse.WriteAsset(file_path, members, options) + + if "representations" not in instance.data: + instance.data["representations"] = [] + + representation = { + 'name': 'usd', + 'ext': 'usd', + 'files': file_name, + "stagingDir": staging_dir + } + instance.data["representations"].append(representation) + + self.log.info("Extracted {} to {}".format(instance, file_path)) From d155f6024903070ebbcfd942e89dff49541a59e7 Mon Sep 17 00:00:00 2001 From: Bo Zhou Date: Tue, 8 Mar 2022 12:11:40 +0900 Subject: [PATCH 03/56] fill attributes to creator CreateMultiverseUsd --- .../plugins/create/create_multiverse_usd.py | 48 ++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/openpype/hosts/maya/plugins/create/create_multiverse_usd.py b/openpype/hosts/maya/plugins/create/create_multiverse_usd.py index 2dc57823f1..fcc6ce231d 100644 --- a/openpype/hosts/maya/plugins/create/create_multiverse_usd.py +++ b/openpype/hosts/maya/plugins/create/create_multiverse_usd.py @@ -1,4 +1,4 @@ -from openpype.hosts.maya.api import plugin +from openpype.hosts.maya.api import plugin, lib class CreateMultiverseUsd(plugin.Creator): @@ -8,3 +8,49 @@ class CreateMultiverseUsd(plugin.Creator): label = "Multiverse USD" family = "usd" icon = "cubes" + + def __init__(self, *args, **kwargs): + super(CreateMultiverseUsd, self).__init__(*args, **kwargs) + + self.data["stripNamespaces"] = False + self.data["mergeTransformAndShape"] = False + self.data["writeAncestors"] = True + self.data["flattenParentXforms"] = False + self.data["writeSparseOverrides"] = False + self.data["useMetaPrimPath"] = False + self.data["customRootPath"] = '' + self.data["customAttributes"] = '' + self.data["nodeTypesToIgnore"] = '' + self.data["writeMeshes"] = True + self.data["writeCurves"] = True + self.data["writeParticles"] = True + self.data["writeCameras"] = False + self.data["writeLights"] = False + self.data["writeJoints"] = False + self.data["writeCollections"] = False + self.data["writePositions"] = True + self.data["writeNormals"] = True + self.data["writeUVs"] = True + self.data["writeColorSets"] = False + self.data["writeTangents"] = False + self.data["writeRefPositions"] = False + self.data["writeBlendShapes"] = False + self.data["writeDisplayColor"] = False + self.data["writeSkinWeights"] = False + self.data["writeMaterialAssignment"] = False + self.data["writeHardwareShader"] = False + self.data["writeShadingNetworks"] = False + self.data["writeTransformMatrix"] = True + self.data["writeUsdAttributes"] = False + self.data["timeVaryingTopology"] = False + self.data["customMaterialNamespace"] = '' + + animation_data = lib.collect_animation_data() + + self.data["writeTimeRange"] = False + self.data["timeRangeStart"] = animation_data["frameStart"] + self.data["timeRangeEnd"] = animation_data["frameEnd"] + self.data["timeRangeIncrement"] = animation_data["step"] + self.data["timeRangeNumTimeSamples"] = 0 + self.data["timeRangeSamplesSpan"] = 0.0 + self.data["timeRangeFramesPerSecond"] = 24.0 From 1c58a3d1dfbbd2122a83607aebb574ba328f717d Mon Sep 17 00:00:00 2001 From: Bo Zhou Date: Tue, 8 Mar 2022 13:00:00 +0900 Subject: [PATCH 04/56] created load plugin to read USD file by multiverse --- .../maya/plugins/load/load_multiverse_usd.py | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 openpype/hosts/maya/plugins/load/load_multiverse_usd.py diff --git a/openpype/hosts/maya/plugins/load/load_multiverse_usd.py b/openpype/hosts/maya/plugins/load/load_multiverse_usd.py new file mode 100644 index 0000000000..b46dbdc56b --- /dev/null +++ b/openpype/hosts/maya/plugins/load/load_multiverse_usd.py @@ -0,0 +1,45 @@ +from avalon import api + +class MultiverseUsdLoader(api.Loader): + """Load the USD by Multiverse""" + + families = ["usd"] + representations = ["usd", "usda", "usdc", "usdz", "abc"] + + label = "Read USD by Multiverse" + order = -10 + icon = "code-fork" + color = "orange" + + def load(self, context, name=None, namespace=None, options=None): + + import maya.cmds as cmds + from openpype.hosts.maya.api.pipeline import containerise + from openpype.hosts.maya.api.lib import unique_namespace + + asset = context['asset']['name'] + namespace = namespace or unique_namespace( + asset + "_", + prefix="_" if asset[0].isdigit() else "", + suffix="_", + ) + + cmds.loadPlugin("MultiverseForMaya", quiet=True) + + # Root group + label = "{}:{}".format(namespace, name) + root = cmds.group(name=label, empty=True) + + # Create shape and move it under root + import multiverse + shape = multiverse.CreateUsdCompound(self.fname) + cmds.parent(shape, root) + + def update(self, container, representation): + pass + + def switch(self, container, representation): + self.update(container, representation) + + def remove(self, container): + pass From 9f83eec3244ce83a43a5c2240f2f989427d7a2c3 Mon Sep 17 00:00:00 2001 From: Bo Zhou Date: Wed, 9 Mar 2022 10:21:26 +0900 Subject: [PATCH 05/56] imroved data for creator of multiverse usd on animated parameters --- .../maya/plugins/create/create_multiverse_usd.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/openpype/hosts/maya/plugins/create/create_multiverse_usd.py b/openpype/hosts/maya/plugins/create/create_multiverse_usd.py index fcc6ce231d..b7f892deb4 100644 --- a/openpype/hosts/maya/plugins/create/create_multiverse_usd.py +++ b/openpype/hosts/maya/plugins/create/create_multiverse_usd.py @@ -45,12 +45,14 @@ class CreateMultiverseUsd(plugin.Creator): self.data["timeVaryingTopology"] = False self.data["customMaterialNamespace"] = '' - animation_data = lib.collect_animation_data() - + # The attributes below are about animated cache. self.data["writeTimeRange"] = False + self.data["timeRangeNumTimeSamples"] = 0 + self.data["timeRangeSamplesSpan"] = 0.0 + + animation_data = lib.collect_animation_data(True) + self.data["timeRangeStart"] = animation_data["frameStart"] self.data["timeRangeEnd"] = animation_data["frameEnd"] self.data["timeRangeIncrement"] = animation_data["step"] - self.data["timeRangeNumTimeSamples"] = 0 - self.data["timeRangeSamplesSpan"] = 0.0 - self.data["timeRangeFramesPerSecond"] = 24.0 + self.data["timeRangeFramesPerSecond"] = animation_data["fps"] From 2adbe78122c10b159341b78d2e542b4f455658d5 Mon Sep 17 00:00:00 2001 From: Bo Zhou Date: Wed, 9 Mar 2022 10:27:51 +0900 Subject: [PATCH 06/56] implemented load method of multiverse usd loader --- .../maya/plugins/load/load_multiverse_usd.py | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/openpype/hosts/maya/plugins/load/load_multiverse_usd.py b/openpype/hosts/maya/plugins/load/load_multiverse_usd.py index b46dbdc56b..4e9952b1a1 100644 --- a/openpype/hosts/maya/plugins/load/load_multiverse_usd.py +++ b/openpype/hosts/maya/plugins/load/load_multiverse_usd.py @@ -1,5 +1,9 @@ +# -*- coding: utf-8 -*- from avalon import api +import maya.cmds as cmds + + class MultiverseUsdLoader(api.Loader): """Load the USD by Multiverse""" @@ -10,10 +14,9 @@ class MultiverseUsdLoader(api.Loader): order = -10 icon = "code-fork" color = "orange" - + def load(self, context, name=None, namespace=None, options=None): - import maya.cmds as cmds from openpype.hosts.maya.api.pipeline import containerise from openpype.hosts.maya.api.lib import unique_namespace @@ -36,10 +39,25 @@ class MultiverseUsdLoader(api.Loader): cmds.parent(shape, root) def update(self, container, representation): - pass + + path = api.get_representation_path(representation) + + # Update the shape + members = cmds.sets(container['objectName'], query=True) + shapes = cmds.ls(members, type="mvUsdPackedShape", long=True) + + assert len(shapes) == 1, "This is a bug" + + import multiverse + for shape in shapes: + multiverse.SetUsdCompoundAssetPaths(shape, [path]) + + cmds.setAttr(container["objectName"] + ".representation", + str(representation["_id"]), + type="string") def switch(self, container, representation): self.update(container, representation) def remove(self, container): - pass + pass From d6a0d2cd2e4a9ff2ec915eb8c25a9d38ee34286d Mon Sep 17 00:00:00 2001 From: Bo Zhou Date: Wed, 9 Mar 2022 10:34:25 +0900 Subject: [PATCH 07/56] use time options for multiverse usd extractor --- .../plugins/publish/extract_multiverse_usd.py | 137 +++++++++++++++++- 1 file changed, 134 insertions(+), 3 deletions(-) diff --git a/openpype/hosts/maya/plugins/publish/extract_multiverse_usd.py b/openpype/hosts/maya/plugins/publish/extract_multiverse_usd.py index 72b1dcbbe5..a45ebf2f9b 100644 --- a/openpype/hosts/maya/plugins/publish/extract_multiverse_usd.py +++ b/openpype/hosts/maya/plugins/publish/extract_multiverse_usd.py @@ -13,6 +13,110 @@ class ExtractMultiverseUsd(openpype.api.Extractor): hosts = ["maya"] families = ["usd"] + @property + def options(self): + """Overridable options for Multiverse USD Export + + Given in the following format + - {NAME: EXPECTED TYPE} + + If the overridden option's type does not match, + the option is not included and a warning is logged. + + """ + + return { + "stripNamespaces": bool, + "mergeTransformAndShape": bool, + "writeAncestors": bool, + "flattenParentXforms": bool, + "writeSparseOverrides": bool, + "useMetaPrimPath": bool, + "customRootPath": str, + "customAttributes": str, + "nodeTypesToIgnore": str, + "writeMeshes": bool, + "writeCurves": bool, + "writeParticles": bool, + "writeCameras": bool, + "writeLights": bool, + "writeJoints": bool, + "writeCollections": bool, + "writePositions": bool, + "writeNormals": bool, + "writeUVs": bool, + "writeColorSets": bool, + "writeTangents": bool, + "writeRefPositions": bool, + "writeBlendShapes": bool, + "writeDisplayColor": bool, + "writeSkinWeights": bool, + "writeMaterialAssignment": bool, + "writeHardwareShader": bool, + "writeShadingNetworks": bool, + "writeTransformMatrix": bool, + "writeUsdAttributes": bool, + "timeVaryingTopology": bool, + "customMaterialNamespace": str, + "writeTimeRange": bool, + "timeRangeStart": int, + "timeRangeEnd": int, + "timeRangeIncrement": int, + "timeRangeNumTimeSamples": int, + "timeRangeSamplesSpan": float, + "timeRangeFramesPerSecond": float + } + + @property + def default_options(self): + """The default options for Multiverse USD extraction.""" + start_frame = int(cmds.playbackOptions(query=True, + animationStartTime=True)) + end_frame = int(cmds.playbackOptions(query=True, + animationEndTime=True)) + + return { + "stripNamespaces": False, + "mergeTransformAndShape": False, + "writeAncestors": True, + "flattenParentXforms": False, + "writeSparseOverrides": False, + "useMetaPrimPath": False, + "customRootPath": '', + "customAttributes": '', + "nodeTypesToIgnore": '', + "writeMeshes": True, + "writeCurves": True, + "writeParticles": True, + "writeCameras": False, + "writeLights": False, + "writeJoints": False, + "writeCollections": False, + "writePositions": True, + "writeNormals": True, + "writeUVs": True, + "writeColorSets": False, + "writeTangents": False, + "writeRefPositions": False, + "writeBlendShapes": False, + "writeDisplayColor": False, + "writeSkinWeights": False, + "writeMaterialAssignment": False, + "writeHardwareShader": False, + "writeShadingNetworks": False, + "writeTransformMatrix": True, + "writeUsdAttributes": False, + "timeVaryingTopology": False, + "customMaterialNamespace": '', + "writeTimeRange": False, + "timeRangeStart": 1, + "timeRangeEnd": 1, + "timeRangeIncrement": 1, + "timeRangeNumTimeSamples": 0, + "timeRangeSamplesSpan": 0.0, + "timeRangeFramesPerSecond": 24.0 + } + def process(self, instance): # Load plugin firstly cmds.loadPlugin("MultiverseForMaya", quiet=True) @@ -23,6 +127,10 @@ class ExtractMultiverseUsd(openpype.api.Extractor): file_path = os.path.join(staging_dir, file_name) file_path = file_path.replace('\\', '/') + # Parse export options + options = self.default_options + self.log.info("Export options: {0}".format(options)) + # Perform extraction self.log.info("Performing extraction ...") @@ -34,11 +142,33 @@ class ExtractMultiverseUsd(openpype.api.Extractor): type=("mesh"), noIntermediate=True, long=True) + self.log.info('Collected object {}'.format(members)) # TODO: Deal with asset, composition, overide with options. import multiverse - options = multiverse.AssetWriteOptions() - multiverse.WriteAsset(file_path, members, options) + + time_opts = None + if options["writeTimeRange"]: + time_opts = multiverse.TimeOptions() + + time_opts.writeTimeRange = True + + time_range_start = options["timeRangeStart"] + time_range_end = options["timeRangeEnd"] + time_opts.frameRange = (time_range_start, time_range_end) + + time_opts.frameIncrement = options["timeRangeIncrement"] + time_opts.numTimeSamples = options["timeRangeNumTimeSamples"] + time_opts.timeSamplesSpan = options["timeRangeSamplesSpan"] + time_opts.framePerSecond = options["timeRangeFramesPerSecond"] + + asset_write_opts = multiverse.AssetWriteOptions(time_opts) + for (k, v) in options.iteritems(): + if k == "writeTimeRange" or k.startswith("timeRange"): + continue + setattr(asset_write_opts, k, v) + + multiverse.WriteAsset(file_path, members, asset_write_opts) if "representations" not in instance.data: instance.data["representations"] = [] @@ -51,4 +181,5 @@ class ExtractMultiverseUsd(openpype.api.Extractor): } instance.data["representations"].append(representation) - self.log.info("Extracted {} to {}".format(instance, file_path)) + self.log.info("Extracted instance {} to {}".format( + instance.name, file_path)) From 9418a496c8cb96b18644bc9da08904cf4602b053 Mon Sep 17 00:00:00 2001 From: Bo Zhou Date: Thu, 10 Mar 2022 16:32:38 +0900 Subject: [PATCH 08/56] improved multiverse usd loader --- .../maya/plugins/load/load_multiverse_usd.py | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/openpype/hosts/maya/plugins/load/load_multiverse_usd.py b/openpype/hosts/maya/plugins/load/load_multiverse_usd.py index 4e9952b1a1..d5006cccb7 100644 --- a/openpype/hosts/maya/plugins/load/load_multiverse_usd.py +++ b/openpype/hosts/maya/plugins/load/load_multiverse_usd.py @@ -30,13 +30,24 @@ class MultiverseUsdLoader(api.Loader): cmds.loadPlugin("MultiverseForMaya", quiet=True) # Root group - label = "{}:{}".format(namespace, name) - root = cmds.group(name=label, empty=True) + rootName = "{}:{}".format(namespace, name) + root = cmds.group(name=rootName, empty=True) - # Create shape and move it under root + # Create shape with transform and move it under root import multiverse - shape = multiverse.CreateUsdCompound(self.fname) - cmds.parent(shape, root) + transform = multiverse.CreateUsdCompound(self.fname) + cmds.parent(transform, root) + + # Rename transform + nodes = [root, transform] + self[:] = nodes + + return containerise( + name=name, + namespace=namespace, + nodes=nodes, + context=context, + loader=self.__class__.__name__) def update(self, container, representation): @@ -44,7 +55,7 @@ class MultiverseUsdLoader(api.Loader): # Update the shape members = cmds.sets(container['objectName'], query=True) - shapes = cmds.ls(members, type="mvUsdPackedShape", long=True) + shapes = cmds.ls(members, type="mvUsdCompoundShape", long=True) assert len(shapes) == 1, "This is a bug" From 310c572e65e5505996efc0fd8d1aa7307a385267 Mon Sep 17 00:00:00 2001 From: Bo Zhou Date: Fri, 11 Mar 2022 11:40:32 +0900 Subject: [PATCH 09/56] added creator for multiverse usd override --- .../create/create_multiverse_usd_over.py | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 openpype/hosts/maya/plugins/create/create_multiverse_usd_over.py diff --git a/openpype/hosts/maya/plugins/create/create_multiverse_usd_over.py b/openpype/hosts/maya/plugins/create/create_multiverse_usd_over.py new file mode 100644 index 0000000000..522487e99b --- /dev/null +++ b/openpype/hosts/maya/plugins/create/create_multiverse_usd_over.py @@ -0,0 +1,35 @@ +from openpype.hosts.maya.api import plugin, lib + + +class CreateMultiverseUsdOver(plugin.Creator): + """Multiverse USD data""" + + name = "usd" + label = "Multiverse USD" + family = "usd" + icon = "cubes" + + def __init__(self, *args, **kwargs): + super(CreateMultiverseUsdOver, self).__init__(*args, **kwargs) + + self.data["writeAll"] = False + self.data["writeTransforms"] = True + self.data["writeVisibility"] = True + self.data["writeAttributes"] = True + self.data["writeMaterials"] = True + self.data["writeVariants"] = True + self.data["writeVariantsDefinition"] = True + self.data["writeActiveState"] = True + self.data["writeNamespaces"] = False + + # The attributes below are about animated cache. + self.data["writeTimeRange"] = True + self.data["timeRangeNumTimeSamples"] = 0 + self.data["timeRangeSamplesSpan"] = 0.0 + + animation_data = lib.collect_animation_data(True) + + self.data["timeRangeStart"] = animation_data["frameStart"] + self.data["timeRangeEnd"] = animation_data["frameEnd"] + self.data["timeRangeIncrement"] = animation_data["step"] + self.data["timeRangeFramesPerSecond"] = animation_data["fps"] From 8ab9a146525219ff6b73483c2ead4e418b2f2933 Mon Sep 17 00:00:00 2001 From: Bo Zhou Date: Fri, 11 Mar 2022 12:15:42 +0900 Subject: [PATCH 10/56] Changed name, label family of multiverse usd override creator --- .../hosts/maya/plugins/create/create_multiverse_usd_over.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openpype/hosts/maya/plugins/create/create_multiverse_usd_over.py b/openpype/hosts/maya/plugins/create/create_multiverse_usd_over.py index 522487e99b..3bb563d20c 100644 --- a/openpype/hosts/maya/plugins/create/create_multiverse_usd_over.py +++ b/openpype/hosts/maya/plugins/create/create_multiverse_usd_over.py @@ -4,9 +4,9 @@ from openpype.hosts.maya.api import plugin, lib class CreateMultiverseUsdOver(plugin.Creator): """Multiverse USD data""" - name = "usd" - label = "Multiverse USD" - family = "usd" + name = "usdOverrideMain" + label = "Multiverse USD Override" + family = "usd_override" icon = "cubes" def __init__(self, *args, **kwargs): From ab4849ab968203e00db2cc4503f92a9faf83be82 Mon Sep 17 00:00:00 2001 From: Bo Zhou Date: Fri, 11 Mar 2022 12:16:48 +0900 Subject: [PATCH 11/56] Changed name and writeTimeRange of multiverse usd creator --- openpype/hosts/maya/plugins/create/create_multiverse_usd.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openpype/hosts/maya/plugins/create/create_multiverse_usd.py b/openpype/hosts/maya/plugins/create/create_multiverse_usd.py index b7f892deb4..6851e0f6bc 100644 --- a/openpype/hosts/maya/plugins/create/create_multiverse_usd.py +++ b/openpype/hosts/maya/plugins/create/create_multiverse_usd.py @@ -4,7 +4,7 @@ from openpype.hosts.maya.api import plugin, lib class CreateMultiverseUsd(plugin.Creator): """Multiverse USD data""" - name = "usd" + name = "usdMain" label = "Multiverse USD" family = "usd" icon = "cubes" @@ -46,7 +46,7 @@ class CreateMultiverseUsd(plugin.Creator): self.data["customMaterialNamespace"] = '' # The attributes below are about animated cache. - self.data["writeTimeRange"] = False + self.data["writeTimeRange"] = True self.data["timeRangeNumTimeSamples"] = 0 self.data["timeRangeSamplesSpan"] = 0.0 From 3151784b1826392228776901abd0f93f8a94da79 Mon Sep 17 00:00:00 2001 From: Bo Zhou Date: Fri, 11 Mar 2022 12:18:14 +0900 Subject: [PATCH 12/56] Updated multiverse usd extracor for default option values --- .../hosts/maya/plugins/publish/extract_multiverse_usd.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openpype/hosts/maya/plugins/publish/extract_multiverse_usd.py b/openpype/hosts/maya/plugins/publish/extract_multiverse_usd.py index a45ebf2f9b..565fbd1ee3 100644 --- a/openpype/hosts/maya/plugins/publish/extract_multiverse_usd.py +++ b/openpype/hosts/maya/plugins/publish/extract_multiverse_usd.py @@ -108,9 +108,9 @@ class ExtractMultiverseUsd(openpype.api.Extractor): "writeUsdAttributes": False, "timeVaryingTopology": False, "customMaterialNamespace": '', - "writeTimeRange": False, - "timeRangeStart": 1, - "timeRangeEnd": 1, + "writeTimeRange": True, + "timeRangeStart": start_frame, + "timeRangeEnd": end_frame, "timeRangeIncrement": 1, "timeRangeNumTimeSamples": 0, "timeRangeSamplesSpan": 0.0, From b36e3127dc50314cf7adc72749ebab2bbbc40451 Mon Sep 17 00:00:00 2001 From: Bo Zhou Date: Fri, 11 Mar 2022 12:20:10 +0900 Subject: [PATCH 13/56] add multiverse usd override extractor plugin --- .../publish/extract_multiverse_usd_over.py | 141 ++++++++++++++++++ 1 file changed, 141 insertions(+) create mode 100644 openpype/hosts/maya/plugins/publish/extract_multiverse_usd_over.py diff --git a/openpype/hosts/maya/plugins/publish/extract_multiverse_usd_over.py b/openpype/hosts/maya/plugins/publish/extract_multiverse_usd_over.py new file mode 100644 index 0000000000..f1b9ca88f0 --- /dev/null +++ b/openpype/hosts/maya/plugins/publish/extract_multiverse_usd_over.py @@ -0,0 +1,141 @@ +import os + +import avalon.maya +import openpype.api + +from maya import cmds + + +class ExtractMultiverseUsdOverride(openpype.api.Extractor): + """Extractor for USD Override by Multiverse.""" + + label = "Extract Multiverse USD Override" + hosts = ["maya"] + families = ["usd_override"] + + @property + def options(self): + """Overridable options for Multiverse USD Export + + Given in the following format + - {NAME: EXPECTED TYPE} + + If the overridden option's type does not match, + the option is not included and a warning is logged. + + """ + + return { + "writeAll": bool, + "writeTransforms": bool, + "writeVisibility": bool, + "writeAttributes": bool, + "writeMaterials": bool, + "writeVariants": bool, + "writeVariantsDefinition": bool, + "writeActiveState": bool, + "writeNamespaces": bool, + "writeTimeRange": bool, + "timeRangeStart": int, + "timeRangeEnd": int, + "timeRangeIncrement": int, + "timeRangeNumTimeSamples": int, + "timeRangeSamplesSpan": float, + "timeRangeFramesPerSecond": float + } + + @property + def default_options(self): + """The default options for Multiverse USD extraction.""" + start_frame = int(cmds.playbackOptions(query=True, + animationStartTime=True)) + end_frame = int(cmds.playbackOptions(query=True, + animationEndTime=True)) + + return { + "writeAll": False, + "writeTransforms": True, + "writeVisibility": True, + "writeAttributes": True, + "writeMaterials": True, + "writeVariants": True, + "writeVariantsDefinition": True, + "writeActiveState": True, + "writeNamespaces": False, + "writeTimeRange": True, + "timeRangeStart": start_frame, + "timeRangeEnd": end_frame, + "timeRangeIncrement": 1, + "timeRangeNumTimeSamples": 0, + "timeRangeSamplesSpan": 0.0, + "timeRangeFramesPerSecond": 24.0 + } + + def process(self, instance): + # Load plugin firstly + cmds.loadPlugin("MultiverseForMaya", quiet=True) + + # Define output file path + staging_dir = self.staging_dir(instance) + file_name = "{}.usda".format(instance.name) + file_path = os.path.join(staging_dir, file_name) + file_path = file_path.replace('\\', '/') + + # Parse export options + options = self.default_options + self.log.info("Export options: {0}".format(options)) + + # Perform extraction + self.log.info("Performing extraction ...") + + with avalon.maya.maintained_selection(): + members = instance.data("setMembers") + members = cmds.ls(members, + dag=True, + shapes=True, + type=("mvUsdCompoundShape"), + noIntermediate=True, + long=True) + self.log.info('Collected object {}'.format(members)) + + # TODO: Deal with asset, composition, overide with options. + import multiverse + + time_opts = None + if options["writeTimeRange"]: + time_opts = multiverse.TimeOptions() + + time_opts.writeTimeRange = True + + time_range_start = options["timeRangeStart"] + time_range_end = options["timeRangeEnd"] + time_opts.frameRange = (time_range_start, time_range_end) + + time_opts.frameIncrement = options["timeRangeIncrement"] + time_opts.numTimeSamples = options["timeRangeNumTimeSamples"] + time_opts.timeSamplesSpan = options["timeRangeSamplesSpan"] + time_opts.framePerSecond = options["timeRangeFramesPerSecond"] + + over_write_opts = multiverse.OverridesWriteOptions() + for (k, v) in options.iteritems(): + if k == "writeTimeRange" or k.startswith("timeRange"): + continue + setattr(over_write_opts, k, v) + over_write_opts.timeOptions = time_opts + + for member in members: + multiverse.WriteOverrides(file_path, member, over_write_opts) + + if "representations" not in instance.data: + instance.data["representations"] = [] + + representation = { + 'name': 'usda', + 'ext': 'usda', + 'files': file_name, + "stagingDir": staging_dir + } + instance.data["representations"].append(representation) + + self.log.info("Extracted instance {} to {}".format( + instance.name, file_path)) From bf5f5365b1dc90f51cdf5200420d3a0e6954317d Mon Sep 17 00:00:00 2001 From: Bo Zhou Date: Fri, 11 Mar 2022 12:22:07 +0900 Subject: [PATCH 14/56] added new family usd_override --- openpype/plugins/publish/integrate_new.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openpype/plugins/publish/integrate_new.py b/openpype/plugins/publish/integrate_new.py index e8dab089af..fc98327f2d 100644 --- a/openpype/plugins/publish/integrate_new.py +++ b/openpype/plugins/publish/integrate_new.py @@ -103,7 +103,8 @@ class IntegrateAssetNew(pyblish.api.InstancePlugin): "effect", "xgen", "hda", - "usd" + "usd", + "usd_override" ] exclude_families = ["clip"] db_representation_context_keys = [ From 28f57a045b714d01113d3efc5317a5c02df63369 Mon Sep 17 00:00:00 2001 From: Bo Zhou Date: Mon, 14 Mar 2022 12:13:51 +0900 Subject: [PATCH 15/56] added new creator for multiverse usd composition --- .../create/create_multiverse_usd_comp.py | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 openpype/hosts/maya/plugins/create/create_multiverse_usd_comp.py diff --git a/openpype/hosts/maya/plugins/create/create_multiverse_usd_comp.py b/openpype/hosts/maya/plugins/create/create_multiverse_usd_comp.py new file mode 100644 index 0000000000..397f31d577 --- /dev/null +++ b/openpype/hosts/maya/plugins/create/create_multiverse_usd_comp.py @@ -0,0 +1,30 @@ +from openpype.hosts.maya.api import plugin, lib + + +class CreateMultiverseUsdComp(plugin.Creator): + """Create Multiverse USD Composition""" + + name = "usdOverrideMain" + label = "Multiverse USD Override" + family = "usd_override" + icon = "cubes" + + def __init__(self, *args, **kwargs): + super(CreateMultiverseUsdComp, self).__init__(*args, **kwargs) + + self.data["stripNamespaces"] = False + self.data["mergeTransformAndShape"] = False + self.data["flattenContent"] = False + self.data["writePendingOverrides"] = False + + # The attributes below are about animated cache. + self.data["writeTimeRange"] = True + self.data["timeRangeNumTimeSamples"] = 0 + self.data["timeRangeSamplesSpan"] = 0.0 + + animation_data = lib.collect_animation_data(True) + + self.data["timeRangeStart"] = animation_data["frameStart"] + self.data["timeRangeEnd"] = animation_data["frameEnd"] + self.data["timeRangeIncrement"] = animation_data["step"] + self.data["timeRangeFramesPerSecond"] = animation_data["fps"] From 9f54faed1c989ac6fa1b1cb904daa0f37fd24e43 Mon Sep 17 00:00:00 2001 From: Bo Zhou Date: Mon, 14 Mar 2022 12:37:09 +0900 Subject: [PATCH 16/56] fixed label and family for multiverse usd composition creator --- .../hosts/maya/plugins/create/create_multiverse_usd_comp.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openpype/hosts/maya/plugins/create/create_multiverse_usd_comp.py b/openpype/hosts/maya/plugins/create/create_multiverse_usd_comp.py index 397f31d577..2f57ccec6c 100644 --- a/openpype/hosts/maya/plugins/create/create_multiverse_usd_comp.py +++ b/openpype/hosts/maya/plugins/create/create_multiverse_usd_comp.py @@ -5,8 +5,8 @@ class CreateMultiverseUsdComp(plugin.Creator): """Create Multiverse USD Composition""" name = "usdOverrideMain" - label = "Multiverse USD Override" - family = "usd_override" + label = "Multiverse USD Composition" + family = "usdComposition" icon = "cubes" def __init__(self, *args, **kwargs): From 86d51270e22650effeff64e16f6943b67c622b6f Mon Sep 17 00:00:00 2001 From: Bo Zhou Date: Mon, 14 Mar 2022 14:04:58 +0900 Subject: [PATCH 17/56] declare more families for multiverse usd loader --- openpype/hosts/maya/plugins/load/load_multiverse_usd.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openpype/hosts/maya/plugins/load/load_multiverse_usd.py b/openpype/hosts/maya/plugins/load/load_multiverse_usd.py index d5006cccb7..7214e1cbb6 100644 --- a/openpype/hosts/maya/plugins/load/load_multiverse_usd.py +++ b/openpype/hosts/maya/plugins/load/load_multiverse_usd.py @@ -7,7 +7,7 @@ import maya.cmds as cmds class MultiverseUsdLoader(api.Loader): """Load the USD by Multiverse""" - families = ["usd"] + families = ["model", "usd", "usdComposition", "usd_override"] representations = ["usd", "usda", "usdc", "usdz", "abc"] label = "Read USD by Multiverse" From 82929bba785bd1966038002ae63a69bde566f378 Mon Sep 17 00:00:00 2001 From: Bo Zhou Date: Mon, 14 Mar 2022 14:06:26 +0900 Subject: [PATCH 18/56] renamed family usd_override to usdOverride --- .../hosts/maya/plugins/create/create_multiverse_usd_over.py | 2 +- openpype/hosts/maya/plugins/load/load_multiverse_usd.py | 2 +- .../hosts/maya/plugins/publish/extract_multiverse_usd_over.py | 2 +- openpype/plugins/publish/integrate_new.py | 3 ++- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/openpype/hosts/maya/plugins/create/create_multiverse_usd_over.py b/openpype/hosts/maya/plugins/create/create_multiverse_usd_over.py index 3bb563d20c..bdec96c2ff 100644 --- a/openpype/hosts/maya/plugins/create/create_multiverse_usd_over.py +++ b/openpype/hosts/maya/plugins/create/create_multiverse_usd_over.py @@ -6,7 +6,7 @@ class CreateMultiverseUsdOver(plugin.Creator): name = "usdOverrideMain" label = "Multiverse USD Override" - family = "usd_override" + family = "usdOverride" icon = "cubes" def __init__(self, *args, **kwargs): diff --git a/openpype/hosts/maya/plugins/load/load_multiverse_usd.py b/openpype/hosts/maya/plugins/load/load_multiverse_usd.py index 7214e1cbb6..3370033141 100644 --- a/openpype/hosts/maya/plugins/load/load_multiverse_usd.py +++ b/openpype/hosts/maya/plugins/load/load_multiverse_usd.py @@ -7,7 +7,7 @@ import maya.cmds as cmds class MultiverseUsdLoader(api.Loader): """Load the USD by Multiverse""" - families = ["model", "usd", "usdComposition", "usd_override"] + families = ["model", "usd", "usdComposition", "usdOverride"] representations = ["usd", "usda", "usdc", "usdz", "abc"] label = "Read USD by Multiverse" diff --git a/openpype/hosts/maya/plugins/publish/extract_multiverse_usd_over.py b/openpype/hosts/maya/plugins/publish/extract_multiverse_usd_over.py index f1b9ca88f0..e0e65d83d1 100644 --- a/openpype/hosts/maya/plugins/publish/extract_multiverse_usd_over.py +++ b/openpype/hosts/maya/plugins/publish/extract_multiverse_usd_over.py @@ -11,7 +11,7 @@ class ExtractMultiverseUsdOverride(openpype.api.Extractor): label = "Extract Multiverse USD Override" hosts = ["maya"] - families = ["usd_override"] + families = ["usdOverride"] @property def options(self): diff --git a/openpype/plugins/publish/integrate_new.py b/openpype/plugins/publish/integrate_new.py index fc98327f2d..4118583787 100644 --- a/openpype/plugins/publish/integrate_new.py +++ b/openpype/plugins/publish/integrate_new.py @@ -104,7 +104,8 @@ class IntegrateAssetNew(pyblish.api.InstancePlugin): "xgen", "hda", "usd", - "usd_override" + "usdComposition", + "usdOverride" ] exclude_families = ["clip"] db_representation_context_keys = [ From 99288ee03aa06613734c7feac627281bb94cb938 Mon Sep 17 00:00:00 2001 From: Bo Zhou Date: Thu, 17 Mar 2022 17:29:54 +0900 Subject: [PATCH 19/56] added multiverse usd composition extractor --- .../publish/extract_multiverse_usd_comp.py | 129 ++++++++++++++++++ 1 file changed, 129 insertions(+) create mode 100644 openpype/hosts/maya/plugins/publish/extract_multiverse_usd_comp.py diff --git a/openpype/hosts/maya/plugins/publish/extract_multiverse_usd_comp.py b/openpype/hosts/maya/plugins/publish/extract_multiverse_usd_comp.py new file mode 100644 index 0000000000..f35096e516 --- /dev/null +++ b/openpype/hosts/maya/plugins/publish/extract_multiverse_usd_comp.py @@ -0,0 +1,129 @@ +import os + +import avalon.maya +import openpype.api + +from maya import cmds + + +class ExtractMultiverseUsdComposition(openpype.api.Extractor): + """Extractor of Multiverse USD Composition.""" + + label = "Extract Multiverse USD Composition" + hosts = ["maya"] + families = ["usdComposition"] + + @property + def options(self): + """Overridable options for Multiverse USD Export + + Given in the following format + - {NAME: EXPECTED TYPE} + + If the overridden option's type does not match, + the option is not included and a warning is logged. + + """ + + return { + "stripNamespaces": bool, + "mergeTransformAndShape": bool, + "flattenContent": bool, + "writePendingOverrides": bool, + "writeTimeRange": bool, + "timeRangeStart": int, + "timeRangeEnd": int, + "timeRangeIncrement": int, + "timeRangeNumTimeSamples": int, + "timeRangeSamplesSpan": float, + "timeRangeFramesPerSecond": float + } + + @property + def default_options(self): + """The default options for Multiverse USD extraction.""" + start_frame = int(cmds.playbackOptions(query=True, + animationStartTime=True)) + end_frame = int(cmds.playbackOptions(query=True, + animationEndTime=True)) + + return { + "stripNamespaces": False, + "mergeTransformAndShape": False, + "flattenContent": False, + "writePendingOverrides": False, + "writeTimeRange": True, + "timeRangeStart": start_frame, + "timeRangeEnd": end_frame, + "timeRangeIncrement": 1, + "timeRangeNumTimeSamples": 0, + "timeRangeSamplesSpan": 0.0, + "timeRangeFramesPerSecond": 24.0 + } + + def process(self, instance): + # Load plugin firstly + cmds.loadPlugin("MultiverseForMaya", quiet=True) + + # Define output file path + staging_dir = self.staging_dir(instance) + file_name = "{}.usda".format(instance.name) + file_path = os.path.join(staging_dir, file_name) + file_path = file_path.replace('\\', '/') + + # Parse export options + options = self.default_options + self.log.info("Export options: {0}".format(options)) + + # Perform extraction + self.log.info("Performing extraction ...") + + with avalon.maya.maintained_selection(): + members = instance.data("setMembers") + members = cmds.ls(members, + dag=True, + shapes=True, + type=("mvUsdCompoundShape"), + noIntermediate=True, + long=True) + self.log.info('Collected object {}'.format(members)) + + # TODO: Deal with asset, composition, overide with options. + import multiverse + + time_opts = None + if options["writeTimeRange"]: + time_opts = multiverse.TimeOptions() + + time_opts.writeTimeRange = True + + time_range_start = options["timeRangeStart"] + time_range_end = options["timeRangeEnd"] + time_opts.frameRange = (time_range_start, time_range_end) + + time_opts.frameIncrement = options["timeRangeIncrement"] + time_opts.numTimeSamples = options["timeRangeNumTimeSamples"] + time_opts.timeSamplesSpan = options["timeRangeSamplesSpan"] + time_opts.framePerSecond = options["timeRangeFramesPerSecond"] + + comp_write_opts = multiverse.CompositionWriteOptions() + for (k, v) in options.iteritems(): + if k == "writeTimeRange" or k.startswith("timeRange"): + continue + setattr(comp_write_opts, k, v) + comp_write_opts.timeOptions = time_opts + multiverse.WriteComposition(file_path, members, comp_write_opts) + + if "representations" not in instance.data: + instance.data["representations"] = [] + + representation = { + 'name': 'usda', + 'ext': 'usda', + 'files': file_name, + "stagingDir": staging_dir + } + instance.data["representations"].append(representation) + + self.log.info("Extracted instance {} to {}".format( + instance.name, file_path)) From f8c06e0e1fb0d91b09a76c4611cfdf4d1ac546d8 Mon Sep 17 00:00:00 2001 From: Bo Zhou Date: Fri, 18 Mar 2022 11:15:19 +0900 Subject: [PATCH 20/56] fix iteration for options among multiverse extractor --- openpype/hosts/maya/plugins/publish/extract_multiverse_usd.py | 3 ++- .../hosts/maya/plugins/publish/extract_multiverse_usd_comp.py | 3 ++- .../hosts/maya/plugins/publish/extract_multiverse_usd_over.py | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/openpype/hosts/maya/plugins/publish/extract_multiverse_usd.py b/openpype/hosts/maya/plugins/publish/extract_multiverse_usd.py index 565fbd1ee3..96e0e79c29 100644 --- a/openpype/hosts/maya/plugins/publish/extract_multiverse_usd.py +++ b/openpype/hosts/maya/plugins/publish/extract_multiverse_usd.py @@ -163,7 +163,8 @@ class ExtractMultiverseUsd(openpype.api.Extractor): time_opts.framePerSecond = options["timeRangeFramesPerSecond"] asset_write_opts = multiverse.AssetWriteOptions(time_opts) - for (k, v) in options.iteritems(): + options_items = getattr(options, "iteritems", options.items) + for (k, v) in options_items: if k == "writeTimeRange" or k.startswith("timeRange"): continue setattr(asset_write_opts, k, v) diff --git a/openpype/hosts/maya/plugins/publish/extract_multiverse_usd_comp.py b/openpype/hosts/maya/plugins/publish/extract_multiverse_usd_comp.py index f35096e516..ef54e9ceff 100644 --- a/openpype/hosts/maya/plugins/publish/extract_multiverse_usd_comp.py +++ b/openpype/hosts/maya/plugins/publish/extract_multiverse_usd_comp.py @@ -107,7 +107,8 @@ class ExtractMultiverseUsdComposition(openpype.api.Extractor): time_opts.framePerSecond = options["timeRangeFramesPerSecond"] comp_write_opts = multiverse.CompositionWriteOptions() - for (k, v) in options.iteritems(): + options_items = getattr(options, "iteritems", options.items) + for (k, v) in options_items: if k == "writeTimeRange" or k.startswith("timeRange"): continue setattr(comp_write_opts, k, v) diff --git a/openpype/hosts/maya/plugins/publish/extract_multiverse_usd_over.py b/openpype/hosts/maya/plugins/publish/extract_multiverse_usd_over.py index e0e65d83d1..df76614f5a 100644 --- a/openpype/hosts/maya/plugins/publish/extract_multiverse_usd_over.py +++ b/openpype/hosts/maya/plugins/publish/extract_multiverse_usd_over.py @@ -117,7 +117,8 @@ class ExtractMultiverseUsdOverride(openpype.api.Extractor): time_opts.framePerSecond = options["timeRangeFramesPerSecond"] over_write_opts = multiverse.OverridesWriteOptions() - for (k, v) in options.iteritems(): + options_items = getattr(options, "iteritems", options.items) + for (k, v) in options_items: if k == "writeTimeRange" or k.startswith("timeRange"): continue setattr(over_write_opts, k, v) From ca5017f730f71de4a4034b06cd3ce5835724e4fa Mon Sep 17 00:00:00 2001 From: Bo Zhou Date: Fri, 18 Mar 2022 12:23:42 +0900 Subject: [PATCH 21/56] fix iteration loop --- openpype/hosts/maya/plugins/publish/extract_multiverse_usd.py | 2 +- .../hosts/maya/plugins/publish/extract_multiverse_usd_comp.py | 2 +- .../hosts/maya/plugins/publish/extract_multiverse_usd_over.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/openpype/hosts/maya/plugins/publish/extract_multiverse_usd.py b/openpype/hosts/maya/plugins/publish/extract_multiverse_usd.py index 96e0e79c29..7c13252957 100644 --- a/openpype/hosts/maya/plugins/publish/extract_multiverse_usd.py +++ b/openpype/hosts/maya/plugins/publish/extract_multiverse_usd.py @@ -164,7 +164,7 @@ class ExtractMultiverseUsd(openpype.api.Extractor): asset_write_opts = multiverse.AssetWriteOptions(time_opts) options_items = getattr(options, "iteritems", options.items) - for (k, v) in options_items: + for (k, v) in options_items(): if k == "writeTimeRange" or k.startswith("timeRange"): continue setattr(asset_write_opts, k, v) diff --git a/openpype/hosts/maya/plugins/publish/extract_multiverse_usd_comp.py b/openpype/hosts/maya/plugins/publish/extract_multiverse_usd_comp.py index ef54e9ceff..449a99e1be 100644 --- a/openpype/hosts/maya/plugins/publish/extract_multiverse_usd_comp.py +++ b/openpype/hosts/maya/plugins/publish/extract_multiverse_usd_comp.py @@ -108,7 +108,7 @@ class ExtractMultiverseUsdComposition(openpype.api.Extractor): comp_write_opts = multiverse.CompositionWriteOptions() options_items = getattr(options, "iteritems", options.items) - for (k, v) in options_items: + for (k, v) in options_items(): if k == "writeTimeRange" or k.startswith("timeRange"): continue setattr(comp_write_opts, k, v) diff --git a/openpype/hosts/maya/plugins/publish/extract_multiverse_usd_over.py b/openpype/hosts/maya/plugins/publish/extract_multiverse_usd_over.py index df76614f5a..406ff8ba11 100644 --- a/openpype/hosts/maya/plugins/publish/extract_multiverse_usd_over.py +++ b/openpype/hosts/maya/plugins/publish/extract_multiverse_usd_over.py @@ -118,7 +118,7 @@ class ExtractMultiverseUsdOverride(openpype.api.Extractor): over_write_opts = multiverse.OverridesWriteOptions() options_items = getattr(options, "iteritems", options.items) - for (k, v) in options_items: + for (k, v) in options_items(): if k == "writeTimeRange" or k.startswith("timeRange"): continue setattr(over_write_opts, k, v) From ae9e34bc62d5d9918842df27492d4a418a83cc82 Mon Sep 17 00:00:00 2001 From: Bo Zhou Date: Tue, 22 Mar 2022 11:21:26 +0900 Subject: [PATCH 22/56] use collected animation data at multiverse use creator --- .../maya/plugins/create/create_multiverse_usd.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/openpype/hosts/maya/plugins/create/create_multiverse_usd.py b/openpype/hosts/maya/plugins/create/create_multiverse_usd.py index 6851e0f6bc..c06c764f95 100644 --- a/openpype/hosts/maya/plugins/create/create_multiverse_usd.py +++ b/openpype/hosts/maya/plugins/create/create_multiverse_usd.py @@ -44,15 +44,9 @@ class CreateMultiverseUsd(plugin.Creator): self.data["writeUsdAttributes"] = False self.data["timeVaryingTopology"] = False self.data["customMaterialNamespace"] = '' + self.data["numTimeSamples"] = 1 + self.data["timeSamplesSpan"] = 0.0 - # The attributes below are about animated cache. - self.data["writeTimeRange"] = True - self.data["timeRangeNumTimeSamples"] = 0 - self.data["timeRangeSamplesSpan"] = 0.0 - + # Add animation data animation_data = lib.collect_animation_data(True) - - self.data["timeRangeStart"] = animation_data["frameStart"] - self.data["timeRangeEnd"] = animation_data["frameEnd"] - self.data["timeRangeIncrement"] = animation_data["step"] - self.data["timeRangeFramesPerSecond"] = animation_data["fps"] + self.data.update(animation_data) From 370416a949280a4223a07f0e4a70060b43433fa4 Mon Sep 17 00:00:00 2001 From: Bo Zhou Date: Tue, 22 Mar 2022 11:41:13 +0900 Subject: [PATCH 23/56] use openpye built-in variables for multiverse usd extractor --- .../plugins/publish/extract_multiverse_usd.py | 60 +++++++++---------- 1 file changed, 28 insertions(+), 32 deletions(-) diff --git a/openpype/hosts/maya/plugins/publish/extract_multiverse_usd.py b/openpype/hosts/maya/plugins/publish/extract_multiverse_usd.py index 7c13252957..db0f57768b 100644 --- a/openpype/hosts/maya/plugins/publish/extract_multiverse_usd.py +++ b/openpype/hosts/maya/plugins/publish/extract_multiverse_usd.py @@ -58,22 +58,13 @@ class ExtractMultiverseUsd(openpype.api.Extractor): "writeUsdAttributes": bool, "timeVaryingTopology": bool, "customMaterialNamespace": str, - "writeTimeRange": bool, - "timeRangeStart": int, - "timeRangeEnd": int, - "timeRangeIncrement": int, - "timeRangeNumTimeSamples": int, - "timeRangeSamplesSpan": float, - "timeRangeFramesPerSecond": float + "numTimeSamples": int, + "timeSamplesSpan": float } @property def default_options(self): """The default options for Multiverse USD extraction.""" - start_frame = int(cmds.playbackOptions(query=True, - animationStartTime=True)) - end_frame = int(cmds.playbackOptions(query=True, - animationEndTime=True)) return { "stripNamespaces": False, @@ -108,13 +99,8 @@ class ExtractMultiverseUsd(openpype.api.Extractor): "writeUsdAttributes": False, "timeVaryingTopology": False, "customMaterialNamespace": '', - "writeTimeRange": True, - "timeRangeStart": start_frame, - "timeRangeEnd": end_frame, - "timeRangeIncrement": 1, - "timeRangeNumTimeSamples": 0, - "timeRangeSamplesSpan": 0.0, - "timeRangeFramesPerSecond": 24.0 + "numTimeSamples": 1, + "timeSamplesSpan": 0.0 } def process(self, instance): @@ -130,6 +116,7 @@ class ExtractMultiverseUsd(openpype.api.Extractor): # Parse export options options = self.default_options self.log.info("Export options: {0}".format(options)) + self.log.info("Export instance data: {0}".format(instance.data)) # Perform extraction self.log.info("Performing extraction ...") @@ -144,30 +131,39 @@ class ExtractMultiverseUsd(openpype.api.Extractor): long=True) self.log.info('Collected object {}'.format(members)) - # TODO: Deal with asset, composition, overide with options. import multiverse time_opts = None - if options["writeTimeRange"]: + frame_start = instance.data['frameStart'] + frame_end = instance.data['frameEnd'] + step = instance.data['step'] + fps = instance.data['fps'] + if frame_end != frame_start: time_opts = multiverse.TimeOptions() time_opts.writeTimeRange = True - - time_range_start = options["timeRangeStart"] - time_range_end = options["timeRangeEnd"] - time_opts.frameRange = (time_range_start, time_range_end) - - time_opts.frameIncrement = options["timeRangeIncrement"] - time_opts.numTimeSamples = options["timeRangeNumTimeSamples"] - time_opts.timeSamplesSpan = options["timeRangeSamplesSpan"] - time_opts.framePerSecond = options["timeRangeFramesPerSecond"] + time_opts.frameRange = (frame_start, frame_end) + time_opts.frameIncrement = step + time_opts.numTimeSamples = instance.data["numTimeSamples"] + time_opts.timeSamplesSpan = instance.data["timeSamplesSpan"] + time_opts.framePerSecond = fps asset_write_opts = multiverse.AssetWriteOptions(time_opts) options_items = getattr(options, "iteritems", options.items) - for (k, v) in options_items(): - if k == "writeTimeRange" or k.startswith("timeRange"): + options_discard_keys = [ + 'numTimeSamples', + 'timeSamplesSpan', + 'frameStart', + 'frameEnd', + 'handleStart', + 'handleEnd', + 'step', + 'fps' + ] + for key, value in options_items(): + if key in options_discard_keys: continue - setattr(asset_write_opts, k, v) + setattr(asset_write_opts, key, instance.data[key]) multiverse.WriteAsset(file_path, members, asset_write_opts) From 889851a2d820cc43c23819b2afca4781c3c471c5 Mon Sep 17 00:00:00 2001 From: Bo Zhou Date: Tue, 22 Mar 2022 11:43:58 +0900 Subject: [PATCH 24/56] tidy variable of unused variable at multiverse usd creator --- openpype/hosts/maya/plugins/publish/extract_multiverse_usd.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openpype/hosts/maya/plugins/publish/extract_multiverse_usd.py b/openpype/hosts/maya/plugins/publish/extract_multiverse_usd.py index db0f57768b..d084ac844e 100644 --- a/openpype/hosts/maya/plugins/publish/extract_multiverse_usd.py +++ b/openpype/hosts/maya/plugins/publish/extract_multiverse_usd.py @@ -160,7 +160,7 @@ class ExtractMultiverseUsd(openpype.api.Extractor): 'step', 'fps' ] - for key, value in options_items(): + for key, _value in options_items(): if key in options_discard_keys: continue setattr(asset_write_opts, key, instance.data[key]) From b553fe66a044a4b3f2570503375b1a8a0f13a2c8 Mon Sep 17 00:00:00 2001 From: Bo Zhou Date: Tue, 22 Mar 2022 12:10:35 +0900 Subject: [PATCH 25/56] add method parse_overrides to multiverse usd extractor to update option values --- .../plugins/publish/extract_multiverse_usd.py | 33 ++++++++++++++++--- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/openpype/hosts/maya/plugins/publish/extract_multiverse_usd.py b/openpype/hosts/maya/plugins/publish/extract_multiverse_usd.py index d084ac844e..9e6d46af7e 100644 --- a/openpype/hosts/maya/plugins/publish/extract_multiverse_usd.py +++ b/openpype/hosts/maya/plugins/publish/extract_multiverse_usd.py @@ -32,9 +32,9 @@ class ExtractMultiverseUsd(openpype.api.Extractor): "flattenParentXforms": bool, "writeSparseOverrides": bool, "useMetaPrimPath": bool, - "customRootPath": str, - "customAttributes": str, - "nodeTypesToIgnore": str, + "customRootPath": unicode, + "customAttributes": unicode, + "nodeTypesToIgnore": unicode, "writeMeshes": bool, "writeCurves": bool, "writeParticles": bool, @@ -57,7 +57,7 @@ class ExtractMultiverseUsd(openpype.api.Extractor): "writeTransformMatrix": bool, "writeUsdAttributes": bool, "timeVaryingTopology": bool, - "customMaterialNamespace": str, + "customMaterialNamespace": unicode, "numTimeSamples": int, "timeSamplesSpan": float } @@ -103,6 +103,29 @@ class ExtractMultiverseUsd(openpype.api.Extractor): "timeSamplesSpan": 0.0 } + def parse_overrides(self, instance, options): + """Inspect data of instance to determine overridden options""" + + for key in instance.data: + if key not in self.options: + continue + + # Ensure the data is of correct type + value = instance.data[key] + if not isinstance(value, self.options[key]): + self.log.warning( + "Overridden attribute {key} was of " + "the wrong type: {invalid_type} " + "- should have been {valid_type}".format( + key=key, + invalid_type=type(value).__name__, + valid_type=self.options[key].__name__)) + continue + + options[key] = value + + return options + def process(self, instance): # Load plugin firstly cmds.loadPlugin("MultiverseForMaya", quiet=True) @@ -115,8 +138,8 @@ class ExtractMultiverseUsd(openpype.api.Extractor): # Parse export options options = self.default_options + options = self.parse_overrides(instance, options) self.log.info("Export options: {0}".format(options)) - self.log.info("Export instance data: {0}".format(instance.data)) # Perform extraction self.log.info("Performing extraction ...") From cc1d6313d534d1a6dc76cc4101fd8021806bf44d Mon Sep 17 00:00:00 2001 From: Bo Zhou Date: Tue, 22 Mar 2022 12:24:09 +0900 Subject: [PATCH 26/56] convert string to unicode at multiverse usd extractor --- openpype/hosts/maya/plugins/publish/extract_multiverse_usd.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/openpype/hosts/maya/plugins/publish/extract_multiverse_usd.py b/openpype/hosts/maya/plugins/publish/extract_multiverse_usd.py index 9e6d46af7e..5fece9cfd3 100644 --- a/openpype/hosts/maya/plugins/publish/extract_multiverse_usd.py +++ b/openpype/hosts/maya/plugins/publish/extract_multiverse_usd.py @@ -112,6 +112,8 @@ class ExtractMultiverseUsd(openpype.api.Extractor): # Ensure the data is of correct type value = instance.data[key] + if isinstance(value, str): + value = unicode(value, "utf-8") if not isinstance(value, self.options[key]): self.log.warning( "Overridden attribute {key} was of " From b5d775700d8cfe20ea8d3db0db2354eaa815380c Mon Sep 17 00:00:00 2001 From: Bo Zhou Date: Tue, 22 Mar 2022 12:28:51 +0900 Subject: [PATCH 27/56] declare default string option as unicode --- .../maya/plugins/publish/extract_multiverse_usd.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/openpype/hosts/maya/plugins/publish/extract_multiverse_usd.py b/openpype/hosts/maya/plugins/publish/extract_multiverse_usd.py index 5fece9cfd3..7b01d3066d 100644 --- a/openpype/hosts/maya/plugins/publish/extract_multiverse_usd.py +++ b/openpype/hosts/maya/plugins/publish/extract_multiverse_usd.py @@ -73,9 +73,9 @@ class ExtractMultiverseUsd(openpype.api.Extractor): "flattenParentXforms": False, "writeSparseOverrides": False, "useMetaPrimPath": False, - "customRootPath": '', - "customAttributes": '', - "nodeTypesToIgnore": '', + "customRootPath": u'', + "customAttributes": u'', + "nodeTypesToIgnore": u'', "writeMeshes": True, "writeCurves": True, "writeParticles": True, @@ -98,7 +98,7 @@ class ExtractMultiverseUsd(openpype.api.Extractor): "writeTransformMatrix": True, "writeUsdAttributes": False, "timeVaryingTopology": False, - "customMaterialNamespace": '', + "customMaterialNamespace": u'', "numTimeSamples": 1, "timeSamplesSpan": 0.0 } @@ -112,8 +112,6 @@ class ExtractMultiverseUsd(openpype.api.Extractor): # Ensure the data is of correct type value = instance.data[key] - if isinstance(value, str): - value = unicode(value, "utf-8") if not isinstance(value, self.options[key]): self.log.warning( "Overridden attribute {key} was of " From fba9399bd3cef9ea5043f312903684bc88b0cab1 Mon Sep 17 00:00:00 2001 From: Bo Zhou Date: Tue, 22 Mar 2022 12:31:09 +0900 Subject: [PATCH 28/56] use values from processed options from multiverse usd extractor --- openpype/hosts/maya/plugins/publish/extract_multiverse_usd.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openpype/hosts/maya/plugins/publish/extract_multiverse_usd.py b/openpype/hosts/maya/plugins/publish/extract_multiverse_usd.py index 7b01d3066d..fd46f87684 100644 --- a/openpype/hosts/maya/plugins/publish/extract_multiverse_usd.py +++ b/openpype/hosts/maya/plugins/publish/extract_multiverse_usd.py @@ -183,10 +183,10 @@ class ExtractMultiverseUsd(openpype.api.Extractor): 'step', 'fps' ] - for key, _value in options_items(): + for key, value in options_items(): if key in options_discard_keys: continue - setattr(asset_write_opts, key, instance.data[key]) + setattr(asset_write_opts, key, value) multiverse.WriteAsset(file_path, members, asset_write_opts) From adde37f982b001bd1aae6722c4e2d4ff3b94d466 Mon Sep 17 00:00:00 2001 From: Bo Zhou Date: Tue, 22 Mar 2022 13:48:47 +0900 Subject: [PATCH 29/56] removed root transform when load the usd file --- .../maya/plugins/load/load_multiverse_usd.py | 33 +++++++++++-------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/openpype/hosts/maya/plugins/load/load_multiverse_usd.py b/openpype/hosts/maya/plugins/load/load_multiverse_usd.py index 3370033141..8a618d5b01 100644 --- a/openpype/hosts/maya/plugins/load/load_multiverse_usd.py +++ b/openpype/hosts/maya/plugins/load/load_multiverse_usd.py @@ -1,7 +1,15 @@ # -*- coding: utf-8 -*- +import maya.cmds as cmds +import maya.mel as mel + from avalon import api -import maya.cmds as cmds +from openpype.hosts.maya.api.lib import ( + maintained_selection, + namespaced, + unique_namespace +) +from openpype.hosts.maya.api.pipeline import containerise class MultiverseUsdLoader(api.Loader): @@ -17,9 +25,6 @@ class MultiverseUsdLoader(api.Loader): def load(self, context, name=None, namespace=None, options=None): - from openpype.hosts.maya.api.pipeline import containerise - from openpype.hosts.maya.api.lib import unique_namespace - asset = context['asset']['name'] namespace = namespace or unique_namespace( asset + "_", @@ -27,19 +32,19 @@ class MultiverseUsdLoader(api.Loader): suffix="_", ) + # Create the shape cmds.loadPlugin("MultiverseForMaya", quiet=True) - # Root group - rootName = "{}:{}".format(namespace, name) - root = cmds.group(name=rootName, empty=True) + shape = None + transform = None + with maintained_selection(): + cmds.namespace(addNamespace=namespace) + with namespaced(namespace, new=False): + import multiverse + shape = multiverse.CreateUsdCompound(self.fname) + transform = mel.eval('firstParentOf "{}"'.format(shape)) - # Create shape with transform and move it under root - import multiverse - transform = multiverse.CreateUsdCompound(self.fname) - cmds.parent(transform, root) - - # Rename transform - nodes = [root, transform] + nodes = [transform, shape] self[:] = nodes return containerise( From e1bdbf3cdc61e2dbf3b211cc80c725af6c1c2e06 Mon Sep 17 00:00:00 2001 From: Bo Zhou Date: Tue, 22 Mar 2022 14:18:17 +0900 Subject: [PATCH 30/56] updated update and remove method in usd loader --- .../maya/plugins/load/load_multiverse_usd.py | 33 ++++++++++++++----- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/openpype/hosts/maya/plugins/load/load_multiverse_usd.py b/openpype/hosts/maya/plugins/load/load_multiverse_usd.py index 8a618d5b01..dac2244b5f 100644 --- a/openpype/hosts/maya/plugins/load/load_multiverse_usd.py +++ b/openpype/hosts/maya/plugins/load/load_multiverse_usd.py @@ -55,20 +55,22 @@ class MultiverseUsdLoader(api.Loader): loader=self.__class__.__name__) def update(self, container, representation): + # type: (dict, dict) -> None + """Update container with specified representation.""" + node = container['objectName'] + assert cmds.objExists(node), "Missing container" + + members = cmds.sets(node, query=True) or [] + shapes = cmds.ls(members, type="mvUsdCompoundShape") + assert shapes, "Cannot find mvUsdCompoundShape in container" path = api.get_representation_path(representation) - # Update the shape - members = cmds.sets(container['objectName'], query=True) - shapes = cmds.ls(members, type="mvUsdCompoundShape", long=True) - - assert len(shapes) == 1, "This is a bug" - import multiverse for shape in shapes: multiverse.SetUsdCompoundAssetPaths(shape, [path]) - cmds.setAttr(container["objectName"] + ".representation", + cmds.setAttr("{}.representation".format(node), str(representation["_id"]), type="string") @@ -76,4 +78,19 @@ class MultiverseUsdLoader(api.Loader): self.update(container, representation) def remove(self, container): - pass + # type: (dict) -> None + """Remove loaded container.""" + # Delete container and its contents + if cmds.objExists(container['objectName']): + members = cmds.sets(container['objectName'], query=True) or [] + cmds.delete([container['objectName']] + members) + + # Remove the namespace, if empty + namespace = container['namespace'] + if cmds.namespace(exists=namespace): + members = cmds.namespaceInfo(namespace, listNamespace=True) + if not members: + cmds.namespace(removeNamespace=namespace) + else: + self.log.warning("Namespace not deleted because it " + "still has members: %s", namespace) From 0990163a0b487f3e32c5563c7f742e29ca26d0bd Mon Sep 17 00:00:00 2001 From: Bo Zhou Date: Wed, 23 Mar 2022 18:30:34 +0900 Subject: [PATCH 31/56] fix removed module from multiverse usd extractor --- .../hosts/maya/plugins/publish/extract_multiverse_usd.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/openpype/hosts/maya/plugins/publish/extract_multiverse_usd.py b/openpype/hosts/maya/plugins/publish/extract_multiverse_usd.py index fd46f87684..d45ceb1932 100644 --- a/openpype/hosts/maya/plugins/publish/extract_multiverse_usd.py +++ b/openpype/hosts/maya/plugins/publish/extract_multiverse_usd.py @@ -1,10 +1,10 @@ import os -import avalon.maya -import openpype.api - from maya import cmds +import openpype.api +from openpype.hosts.maya.api.lib import maintained_selection + class ExtractMultiverseUsd(openpype.api.Extractor): """Extractor for USD by Multiverse.""" @@ -144,7 +144,7 @@ class ExtractMultiverseUsd(openpype.api.Extractor): # Perform extraction self.log.info("Performing extraction ...") - with avalon.maya.maintained_selection(): + with maintained_selection(): members = instance.data("setMembers") members = cmds.ls(members, dag=True, From 7a96bfcfbf2199d2c4c0d1c3d5db9cc049018653 Mon Sep 17 00:00:00 2001 From: Bo Zhou Date: Thu, 24 Mar 2022 09:45:36 +0900 Subject: [PATCH 32/56] deal with handle start and end for multiverse usd extractor --- .../hosts/maya/plugins/publish/extract_multiverse_usd.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/openpype/hosts/maya/plugins/publish/extract_multiverse_usd.py b/openpype/hosts/maya/plugins/publish/extract_multiverse_usd.py index d45ceb1932..c64e5b03e2 100644 --- a/openpype/hosts/maya/plugins/publish/extract_multiverse_usd.py +++ b/openpype/hosts/maya/plugins/publish/extract_multiverse_usd.py @@ -159,13 +159,16 @@ class ExtractMultiverseUsd(openpype.api.Extractor): time_opts = None frame_start = instance.data['frameStart'] frame_end = instance.data['frameEnd'] + handle_start = instance.data['handleStart'] + handle_end = instance.data['handleEnd'] step = instance.data['step'] fps = instance.data['fps'] if frame_end != frame_start: time_opts = multiverse.TimeOptions() time_opts.writeTimeRange = True - time_opts.frameRange = (frame_start, frame_end) + time_opts.frameRange = ( + frame_start - handle_start, frame_end + handle_end) time_opts.frameIncrement = step time_opts.numTimeSamples = instance.data["numTimeSamples"] time_opts.timeSamplesSpan = instance.data["timeSamplesSpan"] From 006c43c6f08106dc7702ca49623dd18e3f1b18c4 Mon Sep 17 00:00:00 2001 From: Bo Zhou Date: Thu, 24 Mar 2022 10:37:17 +0900 Subject: [PATCH 33/56] replace unicode with str and normalize unicode instance data value --- .../plugins/publish/extract_multiverse_usd.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/openpype/hosts/maya/plugins/publish/extract_multiverse_usd.py b/openpype/hosts/maya/plugins/publish/extract_multiverse_usd.py index c64e5b03e2..d7d1337930 100644 --- a/openpype/hosts/maya/plugins/publish/extract_multiverse_usd.py +++ b/openpype/hosts/maya/plugins/publish/extract_multiverse_usd.py @@ -1,4 +1,5 @@ import os +import six from maya import cmds @@ -32,9 +33,9 @@ class ExtractMultiverseUsd(openpype.api.Extractor): "flattenParentXforms": bool, "writeSparseOverrides": bool, "useMetaPrimPath": bool, - "customRootPath": unicode, - "customAttributes": unicode, - "nodeTypesToIgnore": unicode, + "customRootPath": str, + "customAttributes": str, + "nodeTypesToIgnore": str, "writeMeshes": bool, "writeCurves": bool, "writeParticles": bool, @@ -57,7 +58,7 @@ class ExtractMultiverseUsd(openpype.api.Extractor): "writeTransformMatrix": bool, "writeUsdAttributes": bool, "timeVaryingTopology": bool, - "customMaterialNamespace": unicode, + "customMaterialNamespace": str, "numTimeSamples": int, "timeSamplesSpan": float } @@ -73,9 +74,9 @@ class ExtractMultiverseUsd(openpype.api.Extractor): "flattenParentXforms": False, "writeSparseOverrides": False, "useMetaPrimPath": False, - "customRootPath": u'', - "customAttributes": u'', - "nodeTypesToIgnore": u'', + "customRootPath": str(), + "customAttributes": str(), + "nodeTypesToIgnore": str(), "writeMeshes": True, "writeCurves": True, "writeParticles": True, @@ -98,7 +99,7 @@ class ExtractMultiverseUsd(openpype.api.Extractor): "writeTransformMatrix": True, "writeUsdAttributes": False, "timeVaryingTopology": False, - "customMaterialNamespace": u'', + "customMaterialNamespace": str(), "numTimeSamples": 1, "timeSamplesSpan": 0.0 } @@ -112,6 +113,8 @@ class ExtractMultiverseUsd(openpype.api.Extractor): # Ensure the data is of correct type value = instance.data[key] + if isinstance(value, six.text_type): + value = str(value) if not isinstance(value, self.options[key]): self.log.warning( "Overridden attribute {key} was of " From de8eac521c091914a4a1e7063e792c269b0db162 Mon Sep 17 00:00:00 2001 From: Bo Zhou Date: Thu, 24 Mar 2022 11:00:44 +0900 Subject: [PATCH 34/56] improved multiverse usd composition creator --- .../plugins/create/create_multiverse_usd_comp.py | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/openpype/hosts/maya/plugins/create/create_multiverse_usd_comp.py b/openpype/hosts/maya/plugins/create/create_multiverse_usd_comp.py index 2f57ccec6c..5d216ddb9c 100644 --- a/openpype/hosts/maya/plugins/create/create_multiverse_usd_comp.py +++ b/openpype/hosts/maya/plugins/create/create_multiverse_usd_comp.py @@ -4,7 +4,7 @@ from openpype.hosts.maya.api import plugin, lib class CreateMultiverseUsdComp(plugin.Creator): """Create Multiverse USD Composition""" - name = "usdOverrideMain" + name = "usdCompositionMain" label = "Multiverse USD Composition" family = "usdComposition" icon = "cubes" @@ -17,14 +17,6 @@ class CreateMultiverseUsdComp(plugin.Creator): self.data["flattenContent"] = False self.data["writePendingOverrides"] = False - # The attributes below are about animated cache. - self.data["writeTimeRange"] = True - self.data["timeRangeNumTimeSamples"] = 0 - self.data["timeRangeSamplesSpan"] = 0.0 - + # Add animation data animation_data = lib.collect_animation_data(True) - - self.data["timeRangeStart"] = animation_data["frameStart"] - self.data["timeRangeEnd"] = animation_data["frameEnd"] - self.data["timeRangeIncrement"] = animation_data["step"] - self.data["timeRangeFramesPerSecond"] = animation_data["fps"] + self.data.update(animation_data) From 7320e570cac9e2c5852709e9c37dc9e2dd37f9dd Mon Sep 17 00:00:00 2001 From: Bo Zhou Date: Thu, 24 Mar 2022 11:37:11 +0900 Subject: [PATCH 35/56] fixed multiverse usd composition extractor --- .../publish/extract_multiverse_usd_comp.py | 98 +++++++++++-------- 1 file changed, 58 insertions(+), 40 deletions(-) diff --git a/openpype/hosts/maya/plugins/publish/extract_multiverse_usd_comp.py b/openpype/hosts/maya/plugins/publish/extract_multiverse_usd_comp.py index 449a99e1be..c80a3cce6c 100644 --- a/openpype/hosts/maya/plugins/publish/extract_multiverse_usd_comp.py +++ b/openpype/hosts/maya/plugins/publish/extract_multiverse_usd_comp.py @@ -1,10 +1,10 @@ import os -import avalon.maya -import openpype.api - from maya import cmds +import openpype.api +from openpype.hosts.maya.api.lib import maintained_selection + class ExtractMultiverseUsdComposition(openpype.api.Extractor): """Extractor of Multiverse USD Composition.""" @@ -29,38 +29,43 @@ class ExtractMultiverseUsdComposition(openpype.api.Extractor): "stripNamespaces": bool, "mergeTransformAndShape": bool, "flattenContent": bool, - "writePendingOverrides": bool, - "writeTimeRange": bool, - "timeRangeStart": int, - "timeRangeEnd": int, - "timeRangeIncrement": int, - "timeRangeNumTimeSamples": int, - "timeRangeSamplesSpan": float, - "timeRangeFramesPerSecond": float + "writePendingOverrides": bool } @property def default_options(self): """The default options for Multiverse USD extraction.""" - start_frame = int(cmds.playbackOptions(query=True, - animationStartTime=True)) - end_frame = int(cmds.playbackOptions(query=True, - animationEndTime=True)) return { "stripNamespaces": False, "mergeTransformAndShape": False, "flattenContent": False, - "writePendingOverrides": False, - "writeTimeRange": True, - "timeRangeStart": start_frame, - "timeRangeEnd": end_frame, - "timeRangeIncrement": 1, - "timeRangeNumTimeSamples": 0, - "timeRangeSamplesSpan": 0.0, - "timeRangeFramesPerSecond": 24.0 + "writePendingOverrides": False } + def parse_overrides(self, instance, options): + """Inspect data of instance to determine overridden options""" + + for key in instance.data: + if key not in self.options: + continue + + # Ensure the data is of correct type + value = instance.data[key] + if not isinstance(value, self.options[key]): + self.log.warning( + "Overridden attribute {key} was of " + "the wrong type: {invalid_type} " + "- should have been {valid_type}".format( + key=key, + invalid_type=type(value).__name__, + valid_type=self.options[key].__name__)) + continue + + options[key] = value + + return options + def process(self, instance): # Load plugin firstly cmds.loadPlugin("MultiverseForMaya", quiet=True) @@ -73,46 +78,59 @@ class ExtractMultiverseUsdComposition(openpype.api.Extractor): # Parse export options options = self.default_options + options = self.parse_overrides(instance, options) self.log.info("Export options: {0}".format(options)) # Perform extraction self.log.info("Performing extraction ...") - with avalon.maya.maintained_selection(): + with maintained_selection(): members = instance.data("setMembers") members = cmds.ls(members, dag=True, shapes=True, - type=("mvUsdCompoundShape"), + type="mvUsdCompoundShape", noIntermediate=True, long=True) self.log.info('Collected object {}'.format(members)) - # TODO: Deal with asset, composition, overide with options. import multiverse time_opts = None - if options["writeTimeRange"]: + frame_start = instance.data['frameStart'] + frame_end = instance.data['frameEnd'] + handle_start = instance.data['handleStart'] + handle_end = instance.data['handleEnd'] + step = instance.data['step'] + fps = instance.data['fps'] + if frame_end != frame_start: time_opts = multiverse.TimeOptions() time_opts.writeTimeRange = True - - time_range_start = options["timeRangeStart"] - time_range_end = options["timeRangeEnd"] - time_opts.frameRange = (time_range_start, time_range_end) - - time_opts.frameIncrement = options["timeRangeIncrement"] - time_opts.numTimeSamples = options["timeRangeNumTimeSamples"] - time_opts.timeSamplesSpan = options["timeRangeSamplesSpan"] - time_opts.framePerSecond = options["timeRangeFramesPerSecond"] + time_opts.frameRange = ( + frame_start - handle_start, frame_end + handle_end) + time_opts.frameIncrement = step + time_opts.numTimeSamples = instance.data["numTimeSamples"] + time_opts.timeSamplesSpan = instance.data["timeSamplesSpan"] + time_opts.framePerSecond = fps comp_write_opts = multiverse.CompositionWriteOptions() options_items = getattr(options, "iteritems", options.items) - for (k, v) in options_items(): - if k == "writeTimeRange" or k.startswith("timeRange"): + options_discard_keys = [ + 'numTimeSamples', + 'timeSamplesSpan', + 'frameStart', + 'frameEnd', + 'handleStart', + 'handleEnd', + 'step', + 'fps' + ] + for key, value in options_items(): + if key in options_discard_keys: continue - setattr(comp_write_opts, k, v) - comp_write_opts.timeOptions = time_opts + setattr(asset_write_opts, key, value) + multiverse.WriteComposition(file_path, members, comp_write_opts) if "representations" not in instance.data: From 783c315c7eaba812d6b9e16fde5b962c4ebae6d2 Mon Sep 17 00:00:00 2001 From: Bo Zhou Date: Thu, 24 Mar 2022 12:05:49 +0900 Subject: [PATCH 36/56] fixed creator of multiverse usd composition with more arguments --- .../hosts/maya/plugins/create/create_multiverse_usd_comp.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/openpype/hosts/maya/plugins/create/create_multiverse_usd_comp.py b/openpype/hosts/maya/plugins/create/create_multiverse_usd_comp.py index 5d216ddb9c..56b8721ce0 100644 --- a/openpype/hosts/maya/plugins/create/create_multiverse_usd_comp.py +++ b/openpype/hosts/maya/plugins/create/create_multiverse_usd_comp.py @@ -16,6 +16,8 @@ class CreateMultiverseUsdComp(plugin.Creator): self.data["mergeTransformAndShape"] = False self.data["flattenContent"] = False self.data["writePendingOverrides"] = False + self.data["numTimeSamples"] = 1 + self.data["timeSamplesSpan"] = 0.0 # Add animation data animation_data = lib.collect_animation_data(True) From d69d7cddf488dd109f9be3fbb38f13578f165bbb Mon Sep 17 00:00:00 2001 From: Bo Zhou Date: Thu, 24 Mar 2022 12:07:06 +0900 Subject: [PATCH 37/56] fix multiverse composition extractor for arguments --- .../plugins/publish/extract_multiverse_usd_comp.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/openpype/hosts/maya/plugins/publish/extract_multiverse_usd_comp.py b/openpype/hosts/maya/plugins/publish/extract_multiverse_usd_comp.py index c80a3cce6c..3876afb89c 100644 --- a/openpype/hosts/maya/plugins/publish/extract_multiverse_usd_comp.py +++ b/openpype/hosts/maya/plugins/publish/extract_multiverse_usd_comp.py @@ -29,7 +29,9 @@ class ExtractMultiverseUsdComposition(openpype.api.Extractor): "stripNamespaces": bool, "mergeTransformAndShape": bool, "flattenContent": bool, - "writePendingOverrides": bool + "writePendingOverrides": bool, + "numTimeSamples": int, + "timeSamplesSpan": float } @property @@ -37,10 +39,12 @@ class ExtractMultiverseUsdComposition(openpype.api.Extractor): """The default options for Multiverse USD extraction.""" return { - "stripNamespaces": False, + "stripNamespaces": True, "mergeTransformAndShape": False, "flattenContent": False, - "writePendingOverrides": False + "writePendingOverrides": False, + "numTimeSamples": 1, + "timeSamplesSpan": 0.0 } def parse_overrides(self, instance, options): @@ -72,7 +76,7 @@ class ExtractMultiverseUsdComposition(openpype.api.Extractor): # Define output file path staging_dir = self.staging_dir(instance) - file_name = "{}.usda".format(instance.name) + file_name = "{}.usd".format(instance.name) file_path = os.path.join(staging_dir, file_name) file_path = file_path.replace('\\', '/') @@ -129,7 +133,7 @@ class ExtractMultiverseUsdComposition(openpype.api.Extractor): for key, value in options_items(): if key in options_discard_keys: continue - setattr(asset_write_opts, key, value) + setattr(comp_write_opts, key, value) multiverse.WriteComposition(file_path, members, comp_write_opts) From 3ab9c8c0bf09cf68e74e38684c9ab1dac2367820 Mon Sep 17 00:00:00 2001 From: Bo Zhou Date: Thu, 24 Mar 2022 12:07:37 +0900 Subject: [PATCH 38/56] fixed multiverse usd loader for new api --- .../hosts/maya/plugins/load/load_multiverse_usd.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/openpype/hosts/maya/plugins/load/load_multiverse_usd.py b/openpype/hosts/maya/plugins/load/load_multiverse_usd.py index dac2244b5f..ce84c0baf8 100644 --- a/openpype/hosts/maya/plugins/load/load_multiverse_usd.py +++ b/openpype/hosts/maya/plugins/load/load_multiverse_usd.py @@ -2,8 +2,10 @@ import maya.cmds as cmds import maya.mel as mel -from avalon import api - +from openpype.pipeline import ( + load, + get_representation_path +) from openpype.hosts.maya.api.lib import ( maintained_selection, namespaced, @@ -12,7 +14,7 @@ from openpype.hosts.maya.api.lib import ( from openpype.hosts.maya.api.pipeline import containerise -class MultiverseUsdLoader(api.Loader): +class MultiverseUsdLoader(load.LoaderPlugin): """Load the USD by Multiverse""" families = ["model", "usd", "usdComposition", "usdOverride"] @@ -64,7 +66,7 @@ class MultiverseUsdLoader(api.Loader): shapes = cmds.ls(members, type="mvUsdCompoundShape") assert shapes, "Cannot find mvUsdCompoundShape in container" - path = api.get_representation_path(representation) + path = get_representation_path(representation) import multiverse for shape in shapes: From 498c968805bbaa1097582deee3999499245f03e4 Mon Sep 17 00:00:00 2001 From: Bo Zhou Date: Thu, 24 Mar 2022 13:43:42 +0900 Subject: [PATCH 39/56] use py3 style to iterate option dict --- openpype/hosts/maya/plugins/publish/extract_multiverse_usd.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/openpype/hosts/maya/plugins/publish/extract_multiverse_usd.py b/openpype/hosts/maya/plugins/publish/extract_multiverse_usd.py index d7d1337930..29f806375e 100644 --- a/openpype/hosts/maya/plugins/publish/extract_multiverse_usd.py +++ b/openpype/hosts/maya/plugins/publish/extract_multiverse_usd.py @@ -178,7 +178,6 @@ class ExtractMultiverseUsd(openpype.api.Extractor): time_opts.framePerSecond = fps asset_write_opts = multiverse.AssetWriteOptions(time_opts) - options_items = getattr(options, "iteritems", options.items) options_discard_keys = [ 'numTimeSamples', 'timeSamplesSpan', @@ -189,7 +188,7 @@ class ExtractMultiverseUsd(openpype.api.Extractor): 'step', 'fps' ] - for key, value in options_items(): + for key, value in options.items(): if key in options_discard_keys: continue setattr(asset_write_opts, key, value) From 0645dc8190db07e70a6f8c5caa12a47b3975fdb2 Mon Sep 17 00:00:00 2001 From: Bo Zhou Date: Thu, 24 Mar 2022 13:49:58 +0900 Subject: [PATCH 40/56] use py3 style to iterate option dict from multiverse usd composition extractor --- .../hosts/maya/plugins/publish/extract_multiverse_usd_comp.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/openpype/hosts/maya/plugins/publish/extract_multiverse_usd_comp.py b/openpype/hosts/maya/plugins/publish/extract_multiverse_usd_comp.py index 3876afb89c..1d764d1221 100644 --- a/openpype/hosts/maya/plugins/publish/extract_multiverse_usd_comp.py +++ b/openpype/hosts/maya/plugins/publish/extract_multiverse_usd_comp.py @@ -119,7 +119,6 @@ class ExtractMultiverseUsdComposition(openpype.api.Extractor): time_opts.framePerSecond = fps comp_write_opts = multiverse.CompositionWriteOptions() - options_items = getattr(options, "iteritems", options.items) options_discard_keys = [ 'numTimeSamples', 'timeSamplesSpan', @@ -130,7 +129,7 @@ class ExtractMultiverseUsdComposition(openpype.api.Extractor): 'step', 'fps' ] - for key, value in options_items(): + for key, value in options.items(): if key in options_discard_keys: continue setattr(comp_write_opts, key, value) From fe2a3e8c2f086bd6dab61d9ac358a8a9ae12f66c Mon Sep 17 00:00:00 2001 From: Bo Zhou Date: Thu, 24 Mar 2022 13:52:06 +0900 Subject: [PATCH 41/56] use usd as name and ext for representation from multiverse usd composition extractor --- .../hosts/maya/plugins/publish/extract_multiverse_usd_comp.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openpype/hosts/maya/plugins/publish/extract_multiverse_usd_comp.py b/openpype/hosts/maya/plugins/publish/extract_multiverse_usd_comp.py index 1d764d1221..8a26379313 100644 --- a/openpype/hosts/maya/plugins/publish/extract_multiverse_usd_comp.py +++ b/openpype/hosts/maya/plugins/publish/extract_multiverse_usd_comp.py @@ -140,8 +140,8 @@ class ExtractMultiverseUsdComposition(openpype.api.Extractor): instance.data["representations"] = [] representation = { - 'name': 'usda', - 'ext': 'usda', + 'name': 'usd', + 'ext': 'usd', 'files': file_name, "stagingDir": staging_dir } From d41d114bd3afcb25c98a1ce15f73322673eae210 Mon Sep 17 00:00:00 2001 From: DMO Date: Thu, 24 Mar 2022 16:49:57 +0900 Subject: [PATCH 42/56] updating create mv overwrite to correct data fields getting used. --- .../plugins/create/create_multiverse_usd_over.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/openpype/hosts/maya/plugins/create/create_multiverse_usd_over.py b/openpype/hosts/maya/plugins/create/create_multiverse_usd_over.py index bdec96c2ff..9ccf2e45fc 100644 --- a/openpype/hosts/maya/plugins/create/create_multiverse_usd_over.py +++ b/openpype/hosts/maya/plugins/create/create_multiverse_usd_over.py @@ -21,15 +21,9 @@ class CreateMultiverseUsdOver(plugin.Creator): self.data["writeVariantsDefinition"] = True self.data["writeActiveState"] = True self.data["writeNamespaces"] = False + self.data["numTimeSamples"] = 1 + self.data["timeSamplesSpan"] = 0.0 - # The attributes below are about animated cache. - self.data["writeTimeRange"] = True - self.data["timeRangeNumTimeSamples"] = 0 - self.data["timeRangeSamplesSpan"] = 0.0 - + # Add animation data animation_data = lib.collect_animation_data(True) - - self.data["timeRangeStart"] = animation_data["frameStart"] - self.data["timeRangeEnd"] = animation_data["frameEnd"] - self.data["timeRangeIncrement"] = animation_data["step"] - self.data["timeRangeFramesPerSecond"] = animation_data["fps"] + self.data.update(animation_data) From 20124bdc836839bea94dc480ef813fa03d828fad Mon Sep 17 00:00:00 2001 From: DMO Date: Thu, 24 Mar 2022 16:50:53 +0900 Subject: [PATCH 43/56] fix import - use direct api vs avalon --- .../hosts/maya/plugins/publish/extract_multiverse_usd_over.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openpype/hosts/maya/plugins/publish/extract_multiverse_usd_over.py b/openpype/hosts/maya/plugins/publish/extract_multiverse_usd_over.py index 406ff8ba11..aa355513f3 100644 --- a/openpype/hosts/maya/plugins/publish/extract_multiverse_usd_over.py +++ b/openpype/hosts/maya/plugins/publish/extract_multiverse_usd_over.py @@ -1,7 +1,7 @@ import os -import avalon.maya import openpype.api +from openpype.hosts.maya.api.lib import maintained_selection from maya import cmds @@ -88,7 +88,7 @@ class ExtractMultiverseUsdOverride(openpype.api.Extractor): # Perform extraction self.log.info("Performing extraction ...") - with avalon.maya.maintained_selection(): + with maintained_selection(): members = instance.data("setMembers") members = cmds.ls(members, dag=True, From 06dce74a3682bd2f30f4085d628d6e1cd28103dc Mon Sep 17 00:00:00 2001 From: DMO Date: Thu, 24 Mar 2022 16:51:24 +0900 Subject: [PATCH 44/56] use a set instead of a list --- .../hosts/maya/plugins/publish/extract_multiverse_usd.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/openpype/hosts/maya/plugins/publish/extract_multiverse_usd.py b/openpype/hosts/maya/plugins/publish/extract_multiverse_usd.py index 29f806375e..2357690160 100644 --- a/openpype/hosts/maya/plugins/publish/extract_multiverse_usd.py +++ b/openpype/hosts/maya/plugins/publish/extract_multiverse_usd.py @@ -178,7 +178,8 @@ class ExtractMultiverseUsd(openpype.api.Extractor): time_opts.framePerSecond = fps asset_write_opts = multiverse.AssetWriteOptions(time_opts) - options_discard_keys = [ + options_items = getattr(options, "iteritems", options.items) + options_discard_keys = { 'numTimeSamples', 'timeSamplesSpan', 'frameStart', @@ -187,8 +188,8 @@ class ExtractMultiverseUsd(openpype.api.Extractor): 'handleEnd', 'step', 'fps' - ] - for key, value in options.items(): + } + for key, value in options_items(): if key in options_discard_keys: continue setattr(asset_write_opts, key, value) From 1cea33d94ca967a6bc5aaeb7f8b3a10016a71052 Mon Sep 17 00:00:00 2001 From: DMO Date: Thu, 24 Mar 2022 16:52:02 +0900 Subject: [PATCH 45/56] fixing the data getting used for the write options ; standardise on " vs '. --- .../publish/extract_multiverse_usd_over.py | 72 ++++++++++--------- 1 file changed, 37 insertions(+), 35 deletions(-) diff --git a/openpype/hosts/maya/plugins/publish/extract_multiverse_usd_over.py b/openpype/hosts/maya/plugins/publish/extract_multiverse_usd_over.py index aa355513f3..9ee6f99de4 100644 --- a/openpype/hosts/maya/plugins/publish/extract_multiverse_usd_over.py +++ b/openpype/hosts/maya/plugins/publish/extract_multiverse_usd_over.py @@ -35,13 +35,8 @@ class ExtractMultiverseUsdOverride(openpype.api.Extractor): "writeVariantsDefinition": bool, "writeActiveState": bool, "writeNamespaces": bool, - "writeTimeRange": bool, - "timeRangeStart": int, - "timeRangeEnd": int, - "timeRangeIncrement": int, - "timeRangeNumTimeSamples": int, - "timeRangeSamplesSpan": float, - "timeRangeFramesPerSecond": float + "numTimeSamples": int, + "timeSamplesSpan": float } @property @@ -62,13 +57,8 @@ class ExtractMultiverseUsdOverride(openpype.api.Extractor): "writeVariantsDefinition": True, "writeActiveState": True, "writeNamespaces": False, - "writeTimeRange": True, - "timeRangeStart": start_frame, - "timeRangeEnd": end_frame, - "timeRangeIncrement": 1, - "timeRangeNumTimeSamples": 0, - "timeRangeSamplesSpan": 0.0, - "timeRangeFramesPerSecond": 24.0 + "numTimeSamples": 1, + "timeSamplesSpan": 0.0 } def process(self, instance): @@ -79,7 +69,7 @@ class ExtractMultiverseUsdOverride(openpype.api.Extractor): staging_dir = self.staging_dir(instance) file_name = "{}.usda".format(instance.name) file_path = os.path.join(staging_dir, file_name) - file_path = file_path.replace('\\', '/') + file_path = file_path.replace("\\", "/") # Parse export options options = self.default_options @@ -93,36 +83,48 @@ class ExtractMultiverseUsdOverride(openpype.api.Extractor): members = cmds.ls(members, dag=True, shapes=True, - type=("mvUsdCompoundShape"), + type="mvUsdCompoundShape", noIntermediate=True, long=True) - self.log.info('Collected object {}'.format(members)) + self.log.info("Collected object {}".format(members)) # TODO: Deal with asset, composition, overide with options. import multiverse time_opts = None - if options["writeTimeRange"]: + frame_start = instance.data["frameStart"] + frame_end = instance.data["frameEnd"] + handle_start = instance.data["handleStart"] + handle_end = instance.data["handleEnd"] + step = instance.data["step"] + fps = instance.data["fps"] + if frame_end != frame_start: time_opts = multiverse.TimeOptions() time_opts.writeTimeRange = True + time_opts.frameRange = ( + frame_start - handle_start, frame_end + handle_end) + time_opts.frameIncrement = step + time_opts.numTimeSamples = instance.data["numTimeSamples"] + time_opts.timeSamplesSpan = instance.data["timeSamplesSpan"] + time_opts.framePerSecond = fps - time_range_start = options["timeRangeStart"] - time_range_end = options["timeRangeEnd"] - time_opts.frameRange = (time_range_start, time_range_end) - - time_opts.frameIncrement = options["timeRangeIncrement"] - time_opts.numTimeSamples = options["timeRangeNumTimeSamples"] - time_opts.timeSamplesSpan = options["timeRangeSamplesSpan"] - time_opts.framePerSecond = options["timeRangeFramesPerSecond"] - - over_write_opts = multiverse.OverridesWriteOptions() + over_write_opts = multiverse.OverridesWriteOptions(time_opts) options_items = getattr(options, "iteritems", options.items) - for (k, v) in options_items(): - if k == "writeTimeRange" or k.startswith("timeRange"): + options_discard_keys = { + "numTimeSamples", + "timeSamplesSpan", + "frameStart", + "frameEnd", + "handleStart", + "handleEnd", + "step", + "fps" + } + for key, value in options_items(): + if key in options_discard_keys: continue - setattr(over_write_opts, k, v) - over_write_opts.timeOptions = time_opts + setattr(over_write_opts, key, value) for member in members: multiverse.WriteOverrides(file_path, member, over_write_opts) @@ -131,9 +133,9 @@ class ExtractMultiverseUsdOverride(openpype.api.Extractor): instance.data["representations"] = [] representation = { - 'name': 'usda', - 'ext': 'usda', - 'files': file_name, + "name": "usd", + "ext": "usd", + "files": file_name, "stagingDir": staging_dir } instance.data["representations"].append(representation) From 73e691f379765841bf2169b477a62e5eceaa2100 Mon Sep 17 00:00:00 2001 From: Bo Zhou Date: Thu, 24 Mar 2022 17:27:22 +0900 Subject: [PATCH 46/56] use cmds.listRelatives instead of mel at multiverse usd loader --- openpype/hosts/maya/plugins/load/load_multiverse_usd.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openpype/hosts/maya/plugins/load/load_multiverse_usd.py b/openpype/hosts/maya/plugins/load/load_multiverse_usd.py index ce84c0baf8..5361f7a85b 100644 --- a/openpype/hosts/maya/plugins/load/load_multiverse_usd.py +++ b/openpype/hosts/maya/plugins/load/load_multiverse_usd.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- import maya.cmds as cmds -import maya.mel as mel from openpype.pipeline import ( load, @@ -44,7 +43,8 @@ class MultiverseUsdLoader(load.LoaderPlugin): with namespaced(namespace, new=False): import multiverse shape = multiverse.CreateUsdCompound(self.fname) - transform = mel.eval('firstParentOf "{}"'.format(shape)) + transform = cmds.listRelatives( + shape, parent=True, fullPath=True)[0] nodes = [transform, shape] self[:] = nodes From 7f18f94abce80194783d3d6032fa39ac834ef577 Mon Sep 17 00:00:00 2001 From: DMO Date: Thu, 24 Mar 2022 17:28:09 +0900 Subject: [PATCH 47/56] removing unused variables. --- .../hosts/maya/plugins/publish/extract_multiverse_usd_over.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/openpype/hosts/maya/plugins/publish/extract_multiverse_usd_over.py b/openpype/hosts/maya/plugins/publish/extract_multiverse_usd_over.py index 9ee6f99de4..b26d6421fd 100644 --- a/openpype/hosts/maya/plugins/publish/extract_multiverse_usd_over.py +++ b/openpype/hosts/maya/plugins/publish/extract_multiverse_usd_over.py @@ -42,10 +42,6 @@ class ExtractMultiverseUsdOverride(openpype.api.Extractor): @property def default_options(self): """The default options for Multiverse USD extraction.""" - start_frame = int(cmds.playbackOptions(query=True, - animationStartTime=True)) - end_frame = int(cmds.playbackOptions(query=True, - animationEndTime=True)) return { "writeAll": False, From e64797c4337c97b9119a7eaf704f806c09a46def Mon Sep 17 00:00:00 2001 From: DMO Date: Thu, 24 Mar 2022 17:43:43 +0900 Subject: [PATCH 48/56] switch do more readable options.items() --- .../hosts/maya/plugins/publish/extract_multiverse_usd_over.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/openpype/hosts/maya/plugins/publish/extract_multiverse_usd_over.py b/openpype/hosts/maya/plugins/publish/extract_multiverse_usd_over.py index b26d6421fd..83d840d045 100644 --- a/openpype/hosts/maya/plugins/publish/extract_multiverse_usd_over.py +++ b/openpype/hosts/maya/plugins/publish/extract_multiverse_usd_over.py @@ -106,7 +106,6 @@ class ExtractMultiverseUsdOverride(openpype.api.Extractor): time_opts.framePerSecond = fps over_write_opts = multiverse.OverridesWriteOptions(time_opts) - options_items = getattr(options, "iteritems", options.items) options_discard_keys = { "numTimeSamples", "timeSamplesSpan", @@ -117,7 +116,7 @@ class ExtractMultiverseUsdOverride(openpype.api.Extractor): "step", "fps" } - for key, value in options_items(): + for key, value in options.items(): if key in options_discard_keys: continue setattr(over_write_opts, key, value) From 600a07237c8412468ce72e7d5951535acedc291b Mon Sep 17 00:00:00 2001 From: DMO Date: Thu, 24 Mar 2022 17:45:10 +0900 Subject: [PATCH 49/56] removed extra space. --- .../hosts/maya/plugins/publish/extract_multiverse_usd_over.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openpype/hosts/maya/plugins/publish/extract_multiverse_usd_over.py b/openpype/hosts/maya/plugins/publish/extract_multiverse_usd_over.py index 83d840d045..ce0e8a392a 100644 --- a/openpype/hosts/maya/plugins/publish/extract_multiverse_usd_over.py +++ b/openpype/hosts/maya/plugins/publish/extract_multiverse_usd_over.py @@ -116,7 +116,7 @@ class ExtractMultiverseUsdOverride(openpype.api.Extractor): "step", "fps" } - for key, value in options.items(): + for key, value in options.items(): if key in options_discard_keys: continue setattr(over_write_opts, key, value) From ef832181e4e0a3e6f0e7e06f7d06e800ab17a79a Mon Sep 17 00:00:00 2001 From: Bo Zhou Date: Thu, 24 Mar 2022 17:46:28 +0900 Subject: [PATCH 50/56] use py3 style to iterate options dict --- openpype/hosts/maya/plugins/publish/extract_multiverse_usd.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/openpype/hosts/maya/plugins/publish/extract_multiverse_usd.py b/openpype/hosts/maya/plugins/publish/extract_multiverse_usd.py index 2357690160..4e4efdc32c 100644 --- a/openpype/hosts/maya/plugins/publish/extract_multiverse_usd.py +++ b/openpype/hosts/maya/plugins/publish/extract_multiverse_usd.py @@ -178,7 +178,6 @@ class ExtractMultiverseUsd(openpype.api.Extractor): time_opts.framePerSecond = fps asset_write_opts = multiverse.AssetWriteOptions(time_opts) - options_items = getattr(options, "iteritems", options.items) options_discard_keys = { 'numTimeSamples', 'timeSamplesSpan', @@ -189,7 +188,7 @@ class ExtractMultiverseUsd(openpype.api.Extractor): 'step', 'fps' } - for key, value in options_items(): + for key, value in options.items(): if key in options_discard_keys: continue setattr(asset_write_opts, key, value) From 6ea037175a03db3efc022a42859120754f8a4b28 Mon Sep 17 00:00:00 2001 From: Bo Zhou Date: Thu, 24 Mar 2022 17:57:18 +0900 Subject: [PATCH 51/56] use set instead of list for discard option keys from multiverse composition extractor --- .../hosts/maya/plugins/publish/extract_multiverse_usd_comp.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openpype/hosts/maya/plugins/publish/extract_multiverse_usd_comp.py b/openpype/hosts/maya/plugins/publish/extract_multiverse_usd_comp.py index 8a26379313..8fccc412e6 100644 --- a/openpype/hosts/maya/plugins/publish/extract_multiverse_usd_comp.py +++ b/openpype/hosts/maya/plugins/publish/extract_multiverse_usd_comp.py @@ -119,7 +119,7 @@ class ExtractMultiverseUsdComposition(openpype.api.Extractor): time_opts.framePerSecond = fps comp_write_opts = multiverse.CompositionWriteOptions() - options_discard_keys = [ + options_discard_keys = { 'numTimeSamples', 'timeSamplesSpan', 'frameStart', @@ -128,7 +128,7 @@ class ExtractMultiverseUsdComposition(openpype.api.Extractor): 'handleEnd', 'step', 'fps' - ] + } for key, value in options.items(): if key in options_discard_keys: continue From bb8bd9042778ad4293682993832242cb8b57e200 Mon Sep 17 00:00:00 2001 From: DMO Date: Fri, 25 Mar 2022 11:08:53 +0900 Subject: [PATCH 52/56] add the animation data first to maintain order. --- .../hosts/maya/plugins/create/create_multiverse_usd.py | 7 +++---- .../maya/plugins/create/create_multiverse_usd_comp.py | 7 +++---- .../maya/plugins/create/create_multiverse_usd_over.py | 7 +++---- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/openpype/hosts/maya/plugins/create/create_multiverse_usd.py b/openpype/hosts/maya/plugins/create/create_multiverse_usd.py index c06c764f95..b2266e5a57 100644 --- a/openpype/hosts/maya/plugins/create/create_multiverse_usd.py +++ b/openpype/hosts/maya/plugins/create/create_multiverse_usd.py @@ -12,6 +12,9 @@ class CreateMultiverseUsd(plugin.Creator): def __init__(self, *args, **kwargs): super(CreateMultiverseUsd, self).__init__(*args, **kwargs) + # Add animation data first, since it maintains order. + self.data.update(lib.collect_animation_data(True)) + self.data["stripNamespaces"] = False self.data["mergeTransformAndShape"] = False self.data["writeAncestors"] = True @@ -46,7 +49,3 @@ class CreateMultiverseUsd(plugin.Creator): self.data["customMaterialNamespace"] = '' self.data["numTimeSamples"] = 1 self.data["timeSamplesSpan"] = 0.0 - - # Add animation data - animation_data = lib.collect_animation_data(True) - self.data.update(animation_data) diff --git a/openpype/hosts/maya/plugins/create/create_multiverse_usd_comp.py b/openpype/hosts/maya/plugins/create/create_multiverse_usd_comp.py index 56b8721ce0..77b808c459 100644 --- a/openpype/hosts/maya/plugins/create/create_multiverse_usd_comp.py +++ b/openpype/hosts/maya/plugins/create/create_multiverse_usd_comp.py @@ -12,13 +12,12 @@ class CreateMultiverseUsdComp(plugin.Creator): def __init__(self, *args, **kwargs): super(CreateMultiverseUsdComp, self).__init__(*args, **kwargs) + # Add animation data first, since it maintains order. + self.data.update(lib.collect_animation_data(True)) + self.data["stripNamespaces"] = False self.data["mergeTransformAndShape"] = False self.data["flattenContent"] = False self.data["writePendingOverrides"] = False self.data["numTimeSamples"] = 1 self.data["timeSamplesSpan"] = 0.0 - - # Add animation data - animation_data = lib.collect_animation_data(True) - self.data.update(animation_data) diff --git a/openpype/hosts/maya/plugins/create/create_multiverse_usd_over.py b/openpype/hosts/maya/plugins/create/create_multiverse_usd_over.py index 9ccf2e45fc..bb82ab2039 100644 --- a/openpype/hosts/maya/plugins/create/create_multiverse_usd_over.py +++ b/openpype/hosts/maya/plugins/create/create_multiverse_usd_over.py @@ -12,6 +12,9 @@ class CreateMultiverseUsdOver(plugin.Creator): def __init__(self, *args, **kwargs): super(CreateMultiverseUsdOver, self).__init__(*args, **kwargs) + # Add animation data first, since it maintains order. + self.data.update(lib.collect_animation_data(True)) + self.data["writeAll"] = False self.data["writeTransforms"] = True self.data["writeVisibility"] = True @@ -23,7 +26,3 @@ class CreateMultiverseUsdOver(plugin.Creator): self.data["writeNamespaces"] = False self.data["numTimeSamples"] = 1 self.data["timeSamplesSpan"] = 0.0 - - # Add animation data - animation_data = lib.collect_animation_data(True) - self.data.update(animation_data) From 5adf3966106f528bdfc38ccc2f7d1a1171efcb5b Mon Sep 17 00:00:00 2001 From: DMO Date: Fri, 25 Mar 2022 18:07:07 +0900 Subject: [PATCH 53/56] Adding "pointcache" & "animation" to the list of families, since it's supported. --- openpype/hosts/maya/plugins/load/load_multiverse_usd.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openpype/hosts/maya/plugins/load/load_multiverse_usd.py b/openpype/hosts/maya/plugins/load/load_multiverse_usd.py index 5361f7a85b..eafad535eb 100644 --- a/openpype/hosts/maya/plugins/load/load_multiverse_usd.py +++ b/openpype/hosts/maya/plugins/load/load_multiverse_usd.py @@ -16,7 +16,8 @@ from openpype.hosts.maya.api.pipeline import containerise class MultiverseUsdLoader(load.LoaderPlugin): """Load the USD by Multiverse""" - families = ["model", "usd", "usdComposition", "usdOverride"] + families = ["model", "usd", "usdComposition", "usdOverride", + "pointcache", "animation"] representations = ["usd", "usda", "usdc", "usdz", "abc"] label = "Read USD by Multiverse" From deedc893bf82248149e652422270c27c16518ac8 Mon Sep 17 00:00:00 2001 From: DMO Date: Fri, 25 Mar 2022 18:07:28 +0900 Subject: [PATCH 54/56] Lock the shape after creating to avoid deletion. --- openpype/hosts/maya/plugins/load/load_multiverse_usd.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/openpype/hosts/maya/plugins/load/load_multiverse_usd.py b/openpype/hosts/maya/plugins/load/load_multiverse_usd.py index eafad535eb..c03f2c5d92 100644 --- a/openpype/hosts/maya/plugins/load/load_multiverse_usd.py +++ b/openpype/hosts/maya/plugins/load/load_multiverse_usd.py @@ -47,6 +47,9 @@ class MultiverseUsdLoader(load.LoaderPlugin): transform = cmds.listRelatives( shape, parent=True, fullPath=True)[0] + # Lock the shape node so the user cannot delete it. + cmds.lockNode(shape, lock=True) + nodes = [transform, shape] self[:] = nodes From d6a7beb16b056f24114aec5b27ecc6b5e60497cd Mon Sep 17 00:00:00 2001 From: OpenPype Date: Wed, 30 Mar 2022 03:40:40 +0000 Subject: [PATCH 55/56] [Automated] Bump version --- CHANGELOG.md | 19 ++++++++++++------- openpype/version.py | 2 +- pyproject.toml | 2 +- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index abe9eaa3ce..f767bc71d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -## [3.9.2-nightly.2](https://github.com/pypeclub/OpenPype/tree/HEAD) +## [3.9.2-nightly.3](https://github.com/pypeclub/OpenPype/tree/HEAD) [Full Changelog](https://github.com/pypeclub/OpenPype/compare/3.9.1...HEAD) @@ -8,11 +8,16 @@ - Docs: Added MongoDB requirements [\#2951](https://github.com/pypeclub/OpenPype/pull/2951) +**🆕 New features** + +- Multiverse: First PR [\#2908](https://github.com/pypeclub/OpenPype/pull/2908) + **🚀 Enhancements** - Slack: Added configurable maximum file size of review upload to Slack [\#2945](https://github.com/pypeclub/OpenPype/pull/2945) - NewPublisher: Prepared implementation of optional pyblish plugin [\#2943](https://github.com/pypeclub/OpenPype/pull/2943) - Workfiles: Open published workfiles [\#2925](https://github.com/pypeclub/OpenPype/pull/2925) +- General: Default modules loaded dynamically [\#2923](https://github.com/pypeclub/OpenPype/pull/2923) - CI: change the version bump logic [\#2919](https://github.com/pypeclub/OpenPype/pull/2919) - Deadline: Add headless argument [\#2916](https://github.com/pypeclub/OpenPype/pull/2916) - Nuke: Add no-audio Tag [\#2911](https://github.com/pypeclub/OpenPype/pull/2911) @@ -22,16 +27,21 @@ **🐛 Bug fixes** +- Slack: Added default for review\_upload\_limit for Slack [\#2965](https://github.com/pypeclub/OpenPype/pull/2965) +- Settings: Conditional dictionary avoid invalid logs [\#2956](https://github.com/pypeclub/OpenPype/pull/2956) - LogViewer: Don't refresh on initialization [\#2949](https://github.com/pypeclub/OpenPype/pull/2949) +- nuke: python3 compatibility issue with `iteritems` [\#2948](https://github.com/pypeclub/OpenPype/pull/2948) - General: anatomy data with correct task short key [\#2947](https://github.com/pypeclub/OpenPype/pull/2947) - SceneInventory: Fix imports in UI [\#2944](https://github.com/pypeclub/OpenPype/pull/2944) - Slack: add generic exception [\#2941](https://github.com/pypeclub/OpenPype/pull/2941) - General: Python specific vendor paths on env injection [\#2939](https://github.com/pypeclub/OpenPype/pull/2939) - General: More fail safe delete old versions [\#2936](https://github.com/pypeclub/OpenPype/pull/2936) - Settings UI: Collapsed of collapsible wrapper works as expected [\#2934](https://github.com/pypeclub/OpenPype/pull/2934) +- Maya: Do not pass `set` to maya commands \(fixes support for older maya versions\) [\#2932](https://github.com/pypeclub/OpenPype/pull/2932) - General: Don't print log record on OSError [\#2926](https://github.com/pypeclub/OpenPype/pull/2926) - Hiero: Fix import of 'register\_event\_callback' [\#2924](https://github.com/pypeclub/OpenPype/pull/2924) - Ftrack: Missing Ftrack id after editorial publish [\#2905](https://github.com/pypeclub/OpenPype/pull/2905) +- AfterEffects: Fix rendering for single frame in DL [\#2875](https://github.com/pypeclub/OpenPype/pull/2875) **🔀 Refactored code** @@ -43,7 +53,7 @@ **Merged pull requests:** -- Maya: Do not pass `set` to maya commands \(fixes support for older maya versions\) [\#2932](https://github.com/pypeclub/OpenPype/pull/2932) +- Maya - added transparency into review creator [\#2952](https://github.com/pypeclub/OpenPype/pull/2952) ## [3.9.1](https://github.com/pypeclub/OpenPype/tree/3.9.1) (2022-03-18) @@ -96,14 +106,10 @@ - Maya: add loaded containers to published instance [\#2837](https://github.com/pypeclub/OpenPype/pull/2837) - Ftrack: Can sync fps as string [\#2836](https://github.com/pypeclub/OpenPype/pull/2836) - General: Custom function for find executable [\#2822](https://github.com/pypeclub/OpenPype/pull/2822) -- General: Color dialog UI fixes [\#2817](https://github.com/pypeclub/OpenPype/pull/2817) -- global: letter box calculated on output as last process [\#2812](https://github.com/pypeclub/OpenPype/pull/2812) -- Nuke: adding Reformat to baking mov plugin [\#2811](https://github.com/pypeclub/OpenPype/pull/2811) **🐛 Bug fixes** - General: Missing time function [\#2877](https://github.com/pypeclub/OpenPype/pull/2877) -- AfterEffects: Fix rendering for single frame in DL [\#2875](https://github.com/pypeclub/OpenPype/pull/2875) - Deadline: Fix plugin name for tile assemble [\#2868](https://github.com/pypeclub/OpenPype/pull/2868) - Nuke: gizmo precollect fix [\#2866](https://github.com/pypeclub/OpenPype/pull/2866) - General: Fix hardlink for windows [\#2864](https://github.com/pypeclub/OpenPype/pull/2864) @@ -126,7 +132,6 @@ - Settings UI: Fix "Apply from" action [\#2820](https://github.com/pypeclub/OpenPype/pull/2820) - Ftrack: Job killer with missing user [\#2819](https://github.com/pypeclub/OpenPype/pull/2819) - Nuke: Use AVALON\_APP to get value for "app" key [\#2818](https://github.com/pypeclub/OpenPype/pull/2818) -- StandalonePublisher: use dynamic groups in subset names [\#2816](https://github.com/pypeclub/OpenPype/pull/2816) **🔀 Refactored code** diff --git a/openpype/version.py b/openpype/version.py index 84ea02fd08..6d55672aca 100644 --- a/openpype/version.py +++ b/openpype/version.py @@ -1,3 +1,3 @@ # -*- coding: utf-8 -*- """Package declaring Pype version.""" -__version__ = "3.9.2-nightly.2" +__version__ = "3.9.2-nightly.3" diff --git a/pyproject.toml b/pyproject.toml index 46515b4785..479cd731fe 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "OpenPype" -version = "3.9.2-nightly.2" # OpenPype +version = "3.9.2-nightly.3" # OpenPype description = "Open VFX and Animation pipeline with support." authors = ["OpenPype Team "] license = "MIT License" From ccf563d60ab7a11dc3dcd7ab81c45134d0a5c387 Mon Sep 17 00:00:00 2001 From: Roy Nieterau Date: Wed, 30 Mar 2022 11:54:38 +0200 Subject: [PATCH 56/56] `METADATA_KEYS` constant as `frozenset` for optimal immutable lookup --- openpype/settings/constants.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openpype/settings/constants.py b/openpype/settings/constants.py index 8b8acf5714..19ff953eb4 100644 --- a/openpype/settings/constants.py +++ b/openpype/settings/constants.py @@ -8,11 +8,11 @@ M_ENVIRONMENT_KEY = "__environment_keys__" # Metadata key for storing dynamic created labels M_DYNAMIC_KEY_LABEL = "__dynamic_keys_labels__" -METADATA_KEYS = ( +METADATA_KEYS = frozenset([ M_OVERRIDDEN_KEY, M_ENVIRONMENT_KEY, M_DYNAMIC_KEY_LABEL -) +]) # Keys where studio's system overrides are stored GLOBAL_SETTINGS_KEY = "global_settings"