mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-27 06:12:19 +01:00
support to fix the task in validate context in maya
This commit is contained in:
parent
5686730e33
commit
ec34bc463f
1 changed files with 19 additions and 8 deletions
|
|
@ -38,17 +38,20 @@ class ValidateInstanceInContext(pyblish.api.InstancePlugin,
|
|||
return
|
||||
|
||||
folder_path = instance.data.get("folderPath")
|
||||
context_folder_path = self.get_context_folder_path(instance)
|
||||
if folder_path != context_folder_path:
|
||||
task = instance.data.get("task")
|
||||
context = self.get_context(instance)
|
||||
if (folder_path, task) != context:
|
||||
context_label = "{} > {}".format(*context)
|
||||
instance_label = "{} > {}".format(folder_path, task)
|
||||
raise PublishValidationError(
|
||||
message=(
|
||||
"Instance '{}' publishes to different folder than current"
|
||||
"Instance '{}' publishes to different context than current"
|
||||
" context: {}. Current context: {}".format(
|
||||
instance.name, folder_path, context_folder_path
|
||||
instance.name, instance_label, context_label
|
||||
)
|
||||
),
|
||||
description=(
|
||||
"## Publishing to a different folder\n"
|
||||
"## Publishing to a different context data\n"
|
||||
"There are publish instances present which are publishing "
|
||||
"into a different folder than your current context.\n\n"
|
||||
"Usually this is not what you want but there can be cases "
|
||||
|
|
@ -64,14 +67,22 @@ class ValidateInstanceInContext(pyblish.api.InstancePlugin,
|
|||
|
||||
@classmethod
|
||||
def repair(cls, instance):
|
||||
context_folder_path = cls.get_context_folder_path(instance)
|
||||
context_folder_path, context_task = cls.get_context(
|
||||
instance)
|
||||
instance_node = instance.data["instance_node"]
|
||||
cmds.setAttr(
|
||||
"{}.folderPath".format(instance_node),
|
||||
context_folder_path,
|
||||
type="string"
|
||||
)
|
||||
cmds.setAttr(
|
||||
"{}.task".format(instance_node),
|
||||
context_task,
|
||||
type="string"
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def get_context_folder_path(instance):
|
||||
return instance.context.data["folderPath"]
|
||||
def get_context(instance):
|
||||
"""Return asset, task from publishing context data"""
|
||||
context = instance.context
|
||||
return context.data["folderPath"], context.data["task"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue