Skip to content

extract_review_animation

ExtractReviewAnimation

Bases: Extractor

Extract Review by Review Animation

Source code in client/ayon_max/plugins/publish/extract_review_animation.py
 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
class ExtractReviewAnimation(publish.Extractor):
    """
    Extract Review by Review Animation
    """

    order = pyblish.api.ExtractorOrder + 0.001
    label = "Extract Review Animation"
    hosts = ["max"]
    families = ["review"]

    def process(self, instance):
        staging_dir = self.staging_dir(instance)
        ext = instance.data.get("imageFormat")
        start = int(instance.data["frameStart"])
        end = int(instance.data["frameEnd"])
        filepath = os.path.join(staging_dir, instance.name)
        self.log.debug(
            "Writing Review Animation to '{}'".format(filepath))

        review_camera = instance.data["review_camera"]
        viewport_options = instance.data.get("viewport_options", {})
        files = render_preview_animation(
            filepath,
            ext,
            review_camera,
            start,
            end,
            percentSize=instance.data["percentSize"],
            width=instance.data["review_width"],
            height=instance.data["review_height"],
            viewport_options=viewport_options)

        filenames = [os.path.basename(path) for path in files]

        tags = ["review"]
        if not instance.data.get("keepImages"):
            tags.append("delete")

        self.log.debug("Performing Extraction ...")

        representation = {
            "name": instance.data["imageFormat"],
            "ext": instance.data["imageFormat"],
            "files": filenames,
            "stagingDir": staging_dir,
            "frameStart": instance.data["frameStartHandle"],
            "frameEnd": instance.data["frameEndHandle"],
            "tags": tags,
            "preview": True,
            "camera_name": review_camera
        }
        self.log.debug(f"{representation}")

        if "representations" not in instance.data:
            instance.data["representations"] = []
        instance.data["representations"].append(representation)