Skip to content

Commit

Permalink
Add option to publish from published workfile
Browse files Browse the repository at this point in the history
  • Loading branch information
jlorrain committed Dec 20, 2021
1 parent 40ed1de commit 0d060a7
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import pyblish.api
import openpype.api
from openpype.lib.profiles_filtering import filter_profiles


def is_subdir(path, root_dir):
Expand All @@ -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
Expand All @@ -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 = True

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 "
Expand All @@ -44,4 +48,31 @@ 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[profile["template_name"]]["folder"]

if not is_subdir(scene_name, pub_workfile_path):
raise RuntimeError("Maya workspace is not set correctly.")
3 changes: 3 additions & 0 deletions openpype/settings/defaults/project_settings/global.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
"optional": false,
"active": true
},
"ValidateSceneSetWorkspace": {
"publish_from_published_workfiles": false
},
"ValidateIntent": {
"enabled": false,
"profiles": []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,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": "dict",
"label": "Validate Intent",
Expand Down

0 comments on commit 0d060a7

Please sign in to comment.