API

Search…

1.6

.match

Control how families are matched amongst plug-ins and instances.

Introduction

The way instances are associated with plug-ins are via their

`families`

.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.

- 1.Intersection
- 2.Subset
- 3.Exact

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.

1

assert set(["a", "b"]).intersection(["b", "c"])

Copied!

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.

Again the concept is borrowed from set theory.

1

assert set(["a", "b"]).issubset(["a", "b", "c"])

Copied!

This can be useful when instances are specialised, such as being a

`lowpoly`

family of a `model`

, or `animation`

family of a `rig`

.Finally, there is **Exact** which captures edge-cases or otherwise highly context sensitive instances, such as an

`animation`

`rig`

in `shot05`

.The algorithm is as follows.

1

assert set(["a", "b"]) == set(["b", "a"])

Copied!

Usage

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, **subset** of the supported families model and low. If the instance does not have at least both of these, it is not a match.

`SpecificPlugin`

is associated to instances whose family(ies) are a This is different from **intersection**.

`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 1

from pyblish import api

2

3

class GenericPlugin(api.InstancePlugin):

4

# Support both models and rigs

5

families = ["model", "rig"]

6

7

def process(self, instance):

8

# Applies to both models and rigs

9

assert "parent_GRP" in instance

10

11

class SpecificPlugin(api.InstancePlugin):

12

# Support models, but only low-poly models

13

families = ["model", "low"]

14

match = api.Subset

15

16

def process(self, instance):

17

# Safe to assume it has a `polyCount` due

18

# to only capturing models.

19

assert instance.data["polyCount"] < 500

Copied!

The last possible value is

`Exact`

which means an instance only matches when families of both instance and plug-ins match exactly.1

class EdgeCasePlugin(api.InstancePlugin):

2

families = ["model", "low", "level21"]

3

match = api.Exact

4

5

def process(self, instance):

6

assert "specialMember" in instance

Copied!

Last modified 2yr ago

Copy link