Skip to content

collect_nuke_instance_data

CollectInstanceData

Bases: InstancePlugin

Collect Nuke instance data

Source code in client/ayon_nuke/plugins/publish/collect_nuke_instance_data.py
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
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
class CollectInstanceData(pyblish.api.InstancePlugin):
    """Collect Nuke instance data

    """

    order = pyblish.api.CollectorOrder - 0.49
    label = "Collect Nuke Instance Data"
    hosts = ["nuke", "nukeassist"]

    settings_category = "nuke"

    # presets
    sync_workfile_version_on_families = []

    def process(self, instance):
        product_type = instance.data["productType"]

        # Get format
        root = nuke.root()
        format_ = root['format'].value()
        resolution_width = format_.width()
        resolution_height = format_.height()
        pixel_aspect = format_.pixelAspect()

        # sync workfile version
        if product_type in self.sync_workfile_version_on_families:
            self.log.debug(
                "Syncing version with workfile for '{}'".format(
                    product_type
                )
            )
            # get version to instance for integration
            instance.data['version'] = instance.context.data['version']

        instance.data.update({
            "step": 1,
            "fps": root['fps'].value(),
            "resolutionWidth": resolution_width,
            "resolutionHeight": resolution_height,
            "pixelAspect": pixel_aspect

        })

        # add creator attributes to instance
        creator_attributes = instance.data["creator_attributes"]
        instance.data.update(creator_attributes)

        # add review family if review activated on instance
        if instance.data.get("review"):
            instance.data["families"].append("review")

        # add staging dir information on instance
        staging_dir = instance.data["transientData"].get("stagingDir")
        staging_dir_persistent = instance.data["transientData"].get(
            "stagingDir_persistent", False
        )
        staging_dir_is_custom = instance.data["transientData"].get(
            "stagingDir_is_custom", False
        )
        if staging_dir:
            instance.data.update({
                "stagingDir": staging_dir,
                "stagingDir_persistent": staging_dir_persistent,
                "stagingDir_is_custom": staging_dir_is_custom,
            })

        self.log.debug("Collected instance: {}".format(
            instance.data))