In addition to running a plug-in once for every instance as in the previous example, it can sometimes be useful to define "classes" of instances that a common set of plug-ins can operate on.
Here, a "class of instances" is known as a family and a plug-in may support one or more families, which is another requirement attribute, like hosts.
import pyblish.apiitems = ["john.person","door.prop"]classCollectInstances(pyblish.api.ContextPlugin): order =0defprocess(self,context):for item in items: name, suffix = item.split(".") instance = context.create_instance(name) instance.data["families"]= [suffix]classPrintPersons(pyblish.api.InstancePlugin): order =1 families = ["person"]defprocess(self,instance):print("Person is: %s"% instance)classPrintProps(pyblish.api.InstancePlugin): order =1 families = ["prop"]defprocess(self,instance):print("The prop is: %s"% instance)pyblish.api.register_plugin(CollectInstances)pyblish.api.register_plugin(PrintPersons)pyblish.api.register_plugin(PrintProps)import pyblish.utilpyblish.util.publish()# The person is "john"# The prop is "door"
If you pay special attention to the final output, you can see that "john" was processed by PrintPersons, whereas "door" got processed by PrintProps.