this time the plugins are 100% pyblish compatible,
they run on mesh instances instead of scene
they can be registered traditional way, with pyblish.api.register_plugin_path, ex. pyblish.api.register_plugin_path(r'C:\\Projects\\maya-scene-check\\check_core')
My only critique would be to leave the word “Check” out of the name, to both reduce duplication and make the part of the name that matters more visible. They all fall under the Validate group, so it would unmistakably be a “check” even without that word.
curious if there is a better way to handle this:
when running an action on a plugin there seems to be no easy way to get access to the plugin instance, and the pyblish instances this instance runs on.
is the only way filtering through the log or storing data in the context?
class ActionFix(pyblish.api.Action):
label = "Fix"
on = "failedOrWarning"
icon = "hand-o-up" # Icon from Awesome Icon
def process(self, context, plugin):
# because pyblish doesnt support getting instances from a plugin yet
# we have to do this manually :(
# if only we would get the plugin instances when using an action
data = []
for result in context.data["results"]:
if result["error"] and result["plugin"] == plugin:
instance = result["instance"]
data.extend(instance)
func = plugin._func[0]
for mesh_name in data:
func(mesh_name, fix=True)
if the plugin instance had access to the instances it ran/failed on, as an attribute my_plugin.failed_instances
and we passed the instance of the plugin, instead of the (immutable) class/type to action.
Then the action could access the instances in it’s process method.
no i’m looking for the instances the plugin has run on., or failed on
the context contains all instances
if we have plugins of family: Mesh, and other plugins of family: Transform
then the plugins that only runs on Mesh, woulld need to filter the context instances on family to get a list of the instances they ran on.
def process(self, context, plugin):
instances_run_on = [instance for instance in context if instance.family == plugin.family]
and this is naively assuming all plugins of family X run on instance of family Y, pyblish actual filter system is more complicated. with multiple families, and Intersection, Subset or Exact.
a better way is to filter by the results
if we want to for example know the instances this plugin failed on, then we have to filter the results, by plugin, by error.
failed_instances_of_this_plugin = []
for result in context.data["results"]:
if result["error"] and result["plugin"] == plugin:
instance = result["instance"]
failed_instances_of_this_plugin .append(instance )
as far as i know pyblish has no support for this yet build in. except for the log that i filter to get the instances.
it be great if instead you could simply access failed_instances property, would make development a lot smoother/pythonic