Architecture

Architecture

Let's take a moment to talk about the 10.000 feet view of Pyblish.
Besides plug-ins, there are two primary objects that are of interest to you.
    1.
    Context
    2.
    Instance
The Context represents the world, typically your current working file, and contains 1 or more Instance.
image
You can think of Instance as a subdivision of Context, each pertaining to a specific area of the bigger picture, such as an image sequence or a model. When publishing, you can choose to consider either the world or part of the world.
image
In some cases, it makes sense to only look at a small portion of a working file, either for precision or special treatment. For example, if your Context is a scene from Star Wars, you might treat Luke different from how you treat The Death Star.
In other cases, it makes more sense to look at the world as a whole, such as when identifying Luke midst other assets in your scene.

Cooperation

Now that you're able to write, register and coordinate plug-ins, it's time to look at how to make them cooperate.
1
import datetime
2
import pyblish.api
3
4
class CollectTime(pyblish.api.ContextPlugin):
5
order = 0
6
7
def process(self, context):
8
time = datetime.datetime.now()
9
context.data["time"] = time
10
11
class PrintTime(pyblish.api.ContextPlugin):
12
order = 1
13
14
def process(self, context):
15
time = context.data["time"]
16
print(time)
17
18
pyblish.api.register_plugin(CollectTime)
19
pyblish.api.register_plugin(PrintTime)
20
21
import pyblish.util
22
pyblish.util.publish()
Copied!
You can use this object to pass information from one plug-in to another. The Context is also accessible from the return value of publish().
1
context = pyblish.util.publish()
Copied!
Last modified 1yr ago
Copy link