diff --git a/openpype/hosts/maya/api/lib.py b/openpype/hosts/maya/api/lib.py index 22803a2e3a..a79e7ade0c 100644 --- a/openpype/hosts/maya/api/lib.py +++ b/openpype/hosts/maya/api/lib.py @@ -33,6 +33,7 @@ from openpype.pipeline import ( registered_host, ) from openpype.pipeline.context_tools import get_current_project_asset +from openpype.lib.profiles_filtering import filter_profiles self = sys.modules[__name__] @@ -3812,3 +3813,47 @@ def get_all_children(nodes): iterator.next() # noqa: B305 return list(traversed) + + +def get_capture_preset(task_name, task_type, subset, project_settings, log): + """Get capture preset for playblasting. + + Logic for transitioning from old style capture preset to new capture preset + profiles. + + Args: + task_name (str): Task name. + take_type (str): Task type. + subset (str): Subset name. + project_settings (dict): Project settings. + log (object): Logging object. + """ + filtering_criteria = { + "hosts": "maya", + "families": "review", + "task_names": task_name, + "task_types": task_type, + "subset": subset + } + + plugin_settings = project_settings["maya"]["publish"]["ExtractPlayblast"] + if plugin_settings["profiles"]: + profile = filter_profiles( + plugin_settings["profiles"], + filtering_criteria, + logger=log + ) + capture_preset = profile.get("capture_preset") + else: + log.warning("No profiles present for Extract Playblast") + + # Backward compatibility for deprecated Extract Playblast settings + # without profiles. + if capture_preset is None: + log.debug( + "Falling back to deprecated Extract Playblast capture preset " + "because no new style playblast profiles are defined." + ) + capture_preset = plugin_settings["capture_preset"] + + return capture_preset diff --git a/openpype/hosts/maya/plugins/create/create_review.py b/openpype/hosts/maya/plugins/create/create_review.py index 972b3a0160..eb68bbb257 100644 --- a/openpype/hosts/maya/plugins/create/create_review.py +++ b/openpype/hosts/maya/plugins/create/create_review.py @@ -8,7 +8,6 @@ from openpype.hosts.maya.api import ( ) from openpype.settings import get_project_settings from openpype.pipeline import get_current_project_name, get_current_task_name -from openpype.lib.profiles_filtering import filter_profiles from openpype.client import get_asset_by_name @@ -40,29 +39,21 @@ class CreateReview(plugin.Creator): data = OrderedDict(**self.data) project_name = get_current_project_name() - profiles = get_project_settings( - project_name - )["maya"]["publish"]["ExtractPlayblast"].get("profiles") - - preset = None - if profiles: - asset_doc = get_asset_by_name(project_name, data["asset"]) - task_name = get_current_task_name() - task_type = asset_doc["data"]["tasks"][task_name]["type"] - - filtering_criteria = { - "hosts": "maya", - "families": "review", - "task_names": task_name, - "task_types": task_type, - "subset": data["subset"] - } - profile = filter_profiles( - profiles, filtering_criteria, logger=self.log + asset_doc = get_asset_by_name(project_name, data["asset"]) + task_name = get_current_task_name() + preset = lib.get_capture_preset( + task_name, + asset_doc["data"]["tasks"][task_name]["type"], + data["subset"], + get_project_settings(project_name), + self.log + ) + if os.environ.get("OPENPYPE_DEBUG") == "1": + self.log.debug( + "Using preset: {}".format( + json.dumps(preset, indent=4, sort_keys=True) + ) ) - preset = profile["capture_preset"] if profile else None - else: - self.log.warning("No profiles present for extract playblast.") # Option for using Maya or asset frame range in settings. frame_range = lib.get_frame_range() @@ -73,25 +64,12 @@ class CreateReview(plugin.Creator): data["fps"] = lib.collect_animation_data(fps=True)["fps"] - data["review_width"] = self.Width - data["review_height"] = self.Height - data["isolate"] = self.isolate data["keepImages"] = self.keepImages - data["imagePlane"] = self.imagePlane data["transparency"] = self.transparency - data["panZoom"] = self.panZoom - - if preset: - if os.environ.get("OPENPYPE_DEBUG") == "1": - self.log.debug( - "Using preset: {}".format( - json.dumps(preset, indent=4, sort_keys=True) - ) - ) - data["review_width"] = preset["Resolution"]["width"] - data["review_height"] = preset["Resolution"]["height"] - data["isolate"] = preset["Generic"]["isolate_view"] - data["imagePlane"] = preset["Viewport Options"]["imagePlane"] - data["panZoom"] = preset["Generic"]["pan_zoom"] + data["review_width"] = preset["Resolution"]["width"] + data["review_height"] = preset["Resolution"]["height"] + data["isolate"] = preset["Generic"]["isolate_view"] + data["imagePlane"] = preset["Viewport Options"]["imagePlane"] + data["panZoom"] = preset["Generic"]["pan_zoom"] self.data = data diff --git a/openpype/hosts/maya/plugins/publish/extract_playblast.py b/openpype/hosts/maya/plugins/publish/extract_playblast.py index 0ce5aa883e..78a8106444 100644 --- a/openpype/hosts/maya/plugins/publish/extract_playblast.py +++ b/openpype/hosts/maya/plugins/publish/extract_playblast.py @@ -7,7 +7,6 @@ import capture from openpype.pipeline import publish from openpype.hosts.maya.api import lib -from openpype.lib.profiles_filtering import filter_profiles from maya import cmds @@ -68,33 +67,14 @@ class ExtractPlayblast(publish.Extractor): # get cameras camera = instance.data["review_camera"] - host_name = instance.context.data["hostName"] - family = instance.data["family"] task_data = instance.data["anatomyData"].get("task", {}) - task_name = task_data.get("name") - task_type = task_data.get("type") - subset = instance.data["subset"] - - filtering_criteria = { - "hosts": host_name, - "families": family, - "task_names": task_name, - "task_types": task_type, - "subset": subset - } - - if self.profiles: - profile = filter_profiles( - self.profiles, filtering_criteria, logger=self.log - ) - capture_preset = profile.get("capture_preset") - else: - self.log.warning("No profiles present for Extract Playblast") - - # Backward compatibility for deprecated Extract Playblast settings - # without profiles. - if capture_preset is None: - capture_preset = self.capture_preset + capture_preset = lib.get_capture_preset( + task_data.get("name"), + task_data.get("type"), + instance.data["subset"], + instance.context.data["project_settings"], + self.log + ) preset = lib.load_capture_preset(data=capture_preset) diff --git a/openpype/hosts/maya/plugins/publish/extract_thumbnail.py b/openpype/hosts/maya/plugins/publish/extract_thumbnail.py index cd4e4694ba..e2125e7c44 100644 --- a/openpype/hosts/maya/plugins/publish/extract_thumbnail.py +++ b/openpype/hosts/maya/plugins/publish/extract_thumbnail.py @@ -7,7 +7,6 @@ import capture from openpype.pipeline import publish from openpype.hosts.maya.api import lib -from openpype.lib.profiles_filtering import filter_profiles from maya import cmds @@ -29,35 +28,14 @@ class ExtractThumbnail(publish.Extractor): camera = instance.data["review_camera"] - host_name = instance.context.data["hostName"] - family = instance.data["family"] task_data = instance.data["anatomyData"].get("task", {}) - task_name = task_data.get("name") - task_type = task_data.get("type") - subset = instance.data["subset"] - - filtering_criteria = { - "hosts": host_name, - "families": family, - "task_names": task_name, - "task_types": task_type, - "subset": subset - } - - if self.profiles: - profile = filter_profiles( - self.profiles, filtering_criteria, logger=self.log - ) - capture_preset = profile.get("capture_preset") - else: - self.log.warning("No profiles present for Extract Playblast") - - # Backward compatibility for deprecated Extract Playblast settings - # without profiles. - if capture_preset is None: - maya_settings = instance.context.data["project_settings"]["maya"] - plugin_settings = maya_settings["publish"]["ExtractPlayblast"] - capture_preset = plugin_settings["capture_preset"] + capture_preset = lib.get_capture_preset( + task_data.get("name"), + task_data.get("type"), + instance.data["subset"], + instance.context.data["project_settings"], + self.log + ) preset = lib.load_capture_preset(data=capture_preset)