diff --git a/openpype/hosts/maya/plugins/publish/validate_scene_set_workspace.py b/openpype/hosts/maya/plugins/publish/validate_scene_set_workspace.py index 174bc44a6fd..1c9de6861eb 100644 --- a/openpype/hosts/maya/plugins/publish/validate_scene_set_workspace.py +++ b/openpype/hosts/maya/plugins/publish/validate_scene_set_workspace.py @@ -4,6 +4,7 @@ import pyblish.api import openpype.api +from openpype.lib.profiles_filtering import filter_profiles def is_subdir(path, root_dir): @@ -25,7 +26,7 @@ def is_subdir(path, root_dir): return True -class ValidateSceneSetWorkspace(pyblish.api.ContextPlugin): +class ValidateSceneSetWorkspace(pyblish.api.InstancePlugin): """Validate the scene is inside the currently set Maya workspace""" order = openpype.api.ValidatePipelineOrder @@ -34,8 +35,11 @@ class ValidateSceneSetWorkspace(pyblish.api.ContextPlugin): version = (0, 1, 0) label = 'Maya Workspace Set' - def process(self, context): + publish_from_published_workfiles = False + def process(self, instance): + + context = instance.context scene_name = cmds.file(query=True, sceneName=True) if not scene_name: raise RuntimeError("Scene hasn't been saved. Workspace can't be " @@ -44,4 +48,35 @@ def process(self, context): root_dir = cmds.workspace(query=True, rootDirectory=True) if not is_subdir(scene_name, root_dir): - raise RuntimeError("Maya workspace is not set correctly.") + + if not self.publish_from_published_workfiles: + raise RuntimeError("Maya workspace is not set correctly.") + else: + settings = context.data.get('project_settings') + template_name_profiles = settings.get('global') \ + .get('publish') \ + .get('IntegrateAssetNew') \ + .get('template_name_profiles') + task_name = context.data["anatomyData"]["task"]["name"] + task_type = context.data["anatomyData"]["task"]["type"] + key_values = { + "families": "workfile", + "tasks": task_name, + "hosts": context.data["hostName"], + "task_types": task_type + } + profile = filter_profiles( + template_name_profiles, + key_values, + logger=self.log + ) + anatomy = context.data.get('anatomy') + anatomy_filled = anatomy.format( + instance.data.get('anatomyData') + ) + pub_workfile_path = anatomy_filled.get( + profile["template_name"] + ).get("folder") + + if not is_subdir(scene_name, pub_workfile_path): + raise RuntimeError("Maya workspace is not set correctly.") diff --git a/openpype/settings/defaults/project_settings/maya.json b/openpype/settings/defaults/project_settings/maya.json index 52b8db058c5..1f188d45c59 100644 --- a/openpype/settings/defaults/project_settings/maya.json +++ b/openpype/settings/defaults/project_settings/maya.json @@ -206,6 +206,9 @@ "redshift_render_attributes": [], "renderman_render_attributes": [] }, + "ValidateSceneSetWorkspace": { + "publish_from_published_workfiles": false + }, "ValidateModelName": { "enabled": false, "database": true, 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 5a47d688b5e..71b7b2d8ea6 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 @@ -229,6 +229,20 @@ } ] }, + { + "type": "dict", + "collapsible": true, + "key": "ValidateSceneSetWorkspace", + "label": "Validate Workspace", + "is_group": true, + "children": [ + { + "type": "boolean", + "key": "publish_from_published_workfiles", + "label": "Allow publishing form published workfiles" + } + ] + }, { "type": "collapsible-wrap", "label": "Model",