From 75175b8a747a06c14c52a8d95bb951bc083e406a Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Mon, 21 Nov 2022 16:02:13 +0800 Subject: [PATCH] create and publish bb geometry --- openpype/hosts/maya/plugins/load/actions.py | 2 + .../maya/plugins/publish/collect_proxy_abc.py | 14 ------ .../maya/plugins/publish/extract_proxy_abc.py | 43 +++++++++++++------ .../plugins/publish/validate_frame_range.py | 1 + .../defaults/project_settings/maya.json | 6 +++ .../schemas/schema_maya_publish.json | 20 +++++++++ 6 files changed, 58 insertions(+), 28 deletions(-) delete mode 100644 openpype/hosts/maya/plugins/publish/collect_proxy_abc.py diff --git a/openpype/hosts/maya/plugins/load/actions.py b/openpype/hosts/maya/plugins/load/actions.py index eca1b27f34..9cc9180d6e 100644 --- a/openpype/hosts/maya/plugins/load/actions.py +++ b/openpype/hosts/maya/plugins/load/actions.py @@ -14,6 +14,7 @@ class SetFrameRangeLoader(load.LoaderPlugin): families = ["animation", "camera", + "proxyAbc", "pointcache"] representations = ["abc"] @@ -48,6 +49,7 @@ class SetFrameRangeWithHandlesLoader(load.LoaderPlugin): families = ["animation", "camera", + "proxyAbc", "pointcache"] representations = ["abc"] diff --git a/openpype/hosts/maya/plugins/publish/collect_proxy_abc.py b/openpype/hosts/maya/plugins/publish/collect_proxy_abc.py deleted file mode 100644 index 2a7890fcac..0000000000 --- a/openpype/hosts/maya/plugins/publish/collect_proxy_abc.py +++ /dev/null @@ -1,14 +0,0 @@ -import pyblish.api - -class CollectProxyAlembic(pyblish.api.InstancePlugin): - """Collect Proxy Alembic for instance.""" - - order = pyblish.api.CollectorOrder + 0.45 - families = ["proxyAbc"] - label = "Collect Proxy Alembic" - hosts = ["maya"] - - def process(self, instance): - """Collector entry point.""" - if not instance.data.get('families'): - instance.data["families"] = [] diff --git a/openpype/hosts/maya/plugins/publish/extract_proxy_abc.py b/openpype/hosts/maya/plugins/publish/extract_proxy_abc.py index b1306edac5..4607fd8a4b 100644 --- a/openpype/hosts/maya/plugins/publish/extract_proxy_abc.py +++ b/openpype/hosts/maya/plugins/publish/extract_proxy_abc.py @@ -11,7 +11,7 @@ from openpype.hosts.maya.api.lib import ( ) -class ExtractAlembic(publish.Extractor): +class ExtractProxyAlembic(publish.Extractor): """Produce an alembic for bounding box geometry """ @@ -22,6 +22,8 @@ class ExtractAlembic(publish.Extractor): def process(self, instance): nodes, roots = self.get_members_and_roots(instance) + + # Collect the start and end including handles start = float(instance.data.get("frameStartHandle", 1)) end = float(instance.data.get("frameEndHandle", 1)) @@ -32,9 +34,9 @@ class ExtractAlembic(publish.Extractor): attr_prefixes = instance.data.get("attrPrefix", "").split(";") attr_prefixes = [value for value in attr_prefixes if value.strip()] - self.log.info("Extracting Proxy Meshes...") - + self.log.info("Extracting pointcache..") dirname = self.staging_dir(instance) + filename = "{name}.abc".format(**instance.data) path = os.path.join(dirname, filename) @@ -52,18 +54,17 @@ class ExtractAlembic(publish.Extractor): } if not instance.data.get("includeParentHierarchy", True): - options["root"] = roots + + if instance.data.get("visibleOnly", False): nodes = list(iter_visible_nodes_in_range(nodes, start=start, end=end)) + with suspended_refresh(): with maintained_selection(): - # TODO: select the bb geometry - self.create_proxy_geometry(instance, - start, - end) + self.create_proxy_geometry(instance, nodes, start, end) extract_alembic(file=path, startFrame=start, endFrame=end, @@ -76,21 +77,35 @@ class ExtractAlembic(publish.Extractor): 'name': 'abc', 'ext': 'abc', 'files': filename, - 'stagingDir': dirname + "stagingDir": dirname } instance.data["representations"].append(representation) instance.context.data["cleanupFullPaths"].append(path) self.log.info("Extracted {} to {}".format(instance, dirname)) - #TODO: delete the bounding box def get_members_and_roots(self, instance): return instance[:], instance.data.get("setMembers") - def create_proxy_geometry(self, instance, start, end): - - inst_selection = cmds.ls(instance.name, long=True) + def create_proxy_geometry(self, instance, node, start, end): + inst_selection = cmds.ls(node, long=True) name_suffix = instance.data.get("nameSuffix") if instance.data.get("single", True): - pass + cmds.geomToBBox(inst_selection, + name=instance.name, + nameSuffix=name_suffix, + single=True, + keepOriginal=True, + bakeAnimation=True, + startTime=start, + endTime=end) + else: + cmds.geomToBBox(inst_selection, + name=instance.name, + nameSuffix=name_suffix, + single=False, + keepOriginal=True, + bakeAnimation=True, + startTime=start, + endTime=end) diff --git a/openpype/hosts/maya/plugins/publish/validate_frame_range.py b/openpype/hosts/maya/plugins/publish/validate_frame_range.py index b467a7c232..5e50ae72cd 100644 --- a/openpype/hosts/maya/plugins/publish/validate_frame_range.py +++ b/openpype/hosts/maya/plugins/publish/validate_frame_range.py @@ -25,6 +25,7 @@ class ValidateFrameRange(pyblish.api.InstancePlugin): families = ["animation", "pointcache", "camera", + "proxyAbc", "renderlayer", "review", "yeticache"] diff --git a/openpype/settings/defaults/project_settings/maya.json b/openpype/settings/defaults/project_settings/maya.json index cb9af2c2b6..bfa3c9f0fb 100644 --- a/openpype/settings/defaults/project_settings/maya.json +++ b/openpype/settings/defaults/project_settings/maya.json @@ -575,6 +575,12 @@ "optional": false, "active": true }, + "ExtractProxyAlembic": { + "enabled": true, + "families": [ + "proxyAbc" + ] + }, "ExtractAlembic": { "enabled": true, "families": [ diff --git a/openpype/settings/entities/schemas/projects_schema/schemas/schema_maya_publish.json b/openpype/settings/entities/schemas/projects_schema/schemas/schema_maya_publish.json index ab8c6b885e..2c6260db30 100644 --- a/openpype/settings/entities/schemas/projects_schema/schemas/schema_maya_publish.json +++ b/openpype/settings/entities/schemas/projects_schema/schemas/schema_maya_publish.json @@ -638,6 +638,26 @@ "type": "label", "label": "Extractors" }, + { + "type": "dict", + "collapsible": true, + "key": "ExtractProxyAlembic", + "label": "Extract Proxy Alembic", + "checkbox_key": "enabled", + "children": [ + { + "type": "boolean", + "key": "enabled", + "label": "Enabled" + }, + { + "key": "families", + "label": "Families", + "type": "list", + "object_type": "text" + } + ] + }, { "type": "dict", "collapsible": true,