Hello
i have a validator that i will be appriciated if you take a look at it and let me know my mistakes in it.
besides it will give me an error in maya that i will write it
i’m using version 1.3.1
import pyblish.api
from maya import cmds, mel
def _get_has_history(instance):
invalid = []
for node in cmds.ls(instance, type='mesh'):
if len(cmds.listHistory(node)) > 1:
invalid.append(node)
continue
return invalid
class ClearHistoryAction(pyblish.api.Action):
label = "Clear History"
on = "failed"
icon = "wrench"
def process(self, instance):
"""Repair by deleting the history of meshes"""
invalid = _get_has_history(instance)
for each in invalid:
cmds.select(each, r=True)
mel.eval("DeleteHistory;")
self.log.info("Success on deleting history of %s" % each)
class ValidateHistory(pyblish.api.InstancePlugin):
"""Your model have History or not..!?"""
order = pyblish.api.ValidatorOrder
families = ['anr.model']
hosts = ['maya']
optional = True
label = "Detect History"
version = (0, 0, 2)
actions = [
pyblish.api.Category("Clear History"),
ClearHistoryAction
]
def process(self, instance):
invalid = _get_has_history(instance)
if invalid:
raise RuntimeError(
"Meshes found in instance[{0}] with history: {1}".format(instance, invalid))
# def repair(self, instance):
# """Repair by deleting the empty layers"""
# invalid = _get_has_history()
# for each in invalid:
# cmds.select(each, r=True)
# mel.eval("DeleteHistory;")
# self.log.info("Success on deleting history of %s" % each)
Error:
# Traceback (most recent call last):
# File "D:\__anr_pipeline\Pipeline\bin\pyblish-win\lib\pyblish\modules\pyblish-rpc\pyblish_rpc\service.py", line 119, in _dispatch
# return func(*params)
# File "D:\__anr_pipeline\Pipeline\bin\pyblish-win\lib\pyblish\modules\pyblish-rpc\pyblish_rpc\service.py", line 97, in process
# action=action)
# File "D:\__anr_pipeline\Pipeline\bin\pyblish-win\lib\pyblish\modules\pyblish-base\pyblish\plugin.py", line 414, in process
# return __explicit_process(plugin, context, instance, action)
# File "D:\__anr_pipeline\Pipeline\bin\pyblish-win\lib\pyblish\modules\pyblish-base\pyblish\plugin.py", line 430, in __explicit_process
# "Cannot process an InstancePlugin without an instance. This is a bug")
# AssertionError: Cannot process an InstancePlugin without an instance. This is a bug
thanks