Collection of 15 reusable plugins for maya validation

here are 15 reusable plugins for maya validation

mostly mesh checks, works based on long names.
also created a matching collector to get all longnames for all meshes

see issue on orginal repo regarding discussion of the new feature

untill the PR is in, for now you can get the repo on my fork: https://github.com/hannesdelbeke/maya_scene_check
simply add maya-scene-check to your env so you can import check_core

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')

1 Like

Genius!

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.

:white_check_mark: Done
Pushed a commit that removes the checks from the name

(I was just reusing what the author named it.)

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.

def process(self, context, plugin):
    plugin.failed_instances

The context is a list of instances, is that what you’re looking for?

for instance in context:
  print("hello %s" % instance.data["name"])

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