Bases: Extractor, OptionalPyblishPluginMixin
Silhouette shapes extractor
Source code in client/ayon_nuke/plugins/publish/extract_silhouette_shapes.py
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75 | class ExtractSilhouetteShapes(publish.Extractor,
OptionalPyblishPluginMixin):
"""Silhouette shapes extractor"""
label = 'Extract Silhouette Shapes'
order = pyblish.api.ExtractorOrder
families = ["matteshapes"]
hosts = ["nuke"]
settings_category = "nuke"
def process(self, instance):
first_frame = int(nuke.root()["first_frame"].getValue())
last_frame = int(nuke.root()["last_frame"].getValue())
self.log.debug(f"instance.data: `{instance.data}`")
shape_node = instance.data["transientData"]["node"]
product_name = instance.data["productName"]
staging_dir = self.staging_dir(instance)
# create file name and path
filename = f"{product_name}.fxs"
attr_values = self.get_attr_values_from_data(instance.data)
filepath = os.path.join(staging_dir, filename)
with maintained_selection():
# select shapes node
select_nodes([shape_node])
silhouetteFxsExporter(
filepath,
first_frame,
last_frame,
bakeshapes=attr_values.get("bake_shapes", False)
)
# create representation data
if "representations" not in instance.data:
instance.data["representations"] = []
representation = {
'name': "fxs",
'ext': "fxs",
'files': filename,
"stagingDir": staging_dir,
"frameStart": first_frame,
"frameEnd": last_frame
}
instance.data["representations"].append(representation)
@classmethod
def get_attribute_defs(cls):
return [
BoolDef(
"bake_shapes",
label="Bake Shapes",
default=False,
)
]
|