Let me just elaborate on my reasoning for suggesting we do it this way.
At the moment, we've got a number of plug-ins that we are more or less polishing/making perfect. The problem is that we can't know what perfect is until they actually get used. Ideally, that would be by your audience; the artists.
If we can't have that, then the next best thing is to put ourselves in the guinea pig cage.
The best way to do that is by first clarifying the problem (i.e. building the broken asset) and getting feedback on when we've actually solved it (i.e. implementing the validator that finds the error).
In a nutshell; this is what test-driven development is all about. In programming terms, you could write a full software this way before ever hitting a line of code. For example.
$ dir Volume in drive C has no label. Volume Serial Number is 8287-EFA2 Directory of C:\ 06/03/2015 14:33 <DIR> Program Files 05/07/2014 12:07 <DIR> Windows
Bam, we've just written
dir. From here, all we have to do is to write the code that outputs this exact thing and when it does, we're done. :)
In plug-in terms, it's exactly like I mentioned. We construct an asset, as realistically as possible, containing an error that we're looking to catch; like the
.mb suffix. We can then both see what we've got to start with, and we can easily illustrate where we're going. Once the plug-in has been written, and
.mb files are not publishable anymore, we can move on, knowing that it works as opposed to hoping that it will.
Let's see if this is a better way of working.
We want to make sure that the maya scene being validated does not contain any audio files.
I've added the following scenes:
Desired output when it fails
mafiles. For certain kinds of assets, it is looked upon to commit to the subversion system, files that contain audio files and that is the reason to have the plugin.
from pyblish_maya.lib import maintained_selection import pyblish_tdm.utilities as utilities import pyblish.api from maya import cmds class SelectSuperMinifigGameInstances(pyblish.api.Selector): hosts = ["maya"] def process_context(self, context): """Produce instances of family Super_Minifig_Game_AR.AR""" current_file = cmds.file(sceneName=True, query=True) family = utilities.family_from_path(current_file) if not family == 'Super_Minifig_Game_AR.AR': return asset_name = utilities.name_from_path(current_file) instance = context.create_instance(name=asset_name) instance.set_data("family", family) with maintained_selection(): cmds.select(cmds.ls(type=["dagNode", "objectSet", "audio"]), noExpand=True) for node in cmds.file(exportSelected=True, preview=True, constructionHistory=True, force=True): child = utilities.MayaNode(node) child.type = cmds.nodeType(node) # Determine if current node is a user set userSet = False if child.type == 'objectSet': userSet = True for attr in ['verticesOnlySet', 'renderableOnlySet']: if cmds.objExists(node + "." + attr): if cmds.getAttr(node + "." + attr): userSet = False break child.data['userSet'] = userSet instance.add(child) instance.set_data("Selector", type(self).__name__)
import pyblish.api as pyblish @pyblish.log class ValidateNoAudio(pyblish.Validator): """Ensure that there are no audio nodes in the scene""" hosts = ['maya'] families = ['Super_Minifig_Game_AR.AR'] def process_instance(self, instance): audio_nodes = list() for node in instance: if node.type == 'audio': audio_nodes.append(node) if audio_nodes: raise pyblish.ValidationError("Audio nodes found in the" "scene: %s\n" % audio_nodes)
$ cd project\publised_asset $ svn commit --all