Control how families are matched amongst plug-ins and instances.
The way instances are associated with plug-ins are via their
Instances and plug-ins may support one or more families, and instances matching one or more of these families are said to be associated with it.
An instance may be associated via a plug-in in 1 of 3 ways.
By default, an instance of any family within the supported families of a plug-in is a match. This is called Intersection and stems from basic set theory.
assert set(["a", "b"]).intersection(["b", "c"])
This is useful in the most general case, of one plug-in supporting many different - possibly unrelated - families. Such as one plug-in supporting both models and rigs, say for an established naming convention across both families.
Subset on the other hand means the families of an Instance must be a subset of the supported families of any plug-in.
Again the concept is borrowed from set theory.
assert set(["a", "b"]).issubset(["a", "b", "c"])
This can be useful when instances are specialised, such as being a
lowpoly family of a
animation family of a
Finally, there is Exact which captures edge-cases or otherwise highly context sensitive instances, such as an
The algorithm is as follows.
assert set(["a", "b"]) == set(["b", "a"])
Decide whether your plug-in targets many unrelated families, or specialises in a few, then associate an algorithm with this plug-in.
In this example,
SpecificPlugin is associated to instances whose family(ies) are a subset of the supported families model and low. If the instance does not have at least both of these, it is not a match.
This is different from
GenericPlugin, where only one of the families of an instance need to match any of the supported families of a plug-in. This is called intersection.
from pyblish import apiclass GenericPlugin(api.InstancePlugin):# Support both models and rigsfamilies = ["model", "rig"]def process(self, instance):# Applies to both models and rigsassert "parent_GRP" in instanceclass SpecificPlugin(api.InstancePlugin):# Support models, but only low-poly modelsfamilies = ["model", "low"]match = api.Subsetdef process(self, instance):# Safe to assume it has a `polyCount` due# to only capturing models.assert instance.data["polyCount"] < 500
The last possible value is
Exact which means an instance only matches when families of both instance and plug-ins match exactly.
class EdgeCasePlugin(api.InstancePlugin):families = ["model", "low", "level21"]match = api.Exactdef process(self, instance):assert "specialMember" in instance