Skip to content

collect_frames

Collector plugin for frames data on ROP instances.

CollectFrames

Bases: HoudiniInstancePlugin

Collect all frames which would be saved from the ROP nodes

Source code in client/ayon_houdini/plugins/publish/collect_frames.py
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 CollectFrames(plugin.HoudiniInstancePlugin):
    """Collect all frames which would be saved from the ROP nodes"""

    # This specific order value is used so that
    # this plugin runs after CollectRopFrameRange
    order = pyblish.api.CollectorOrder + 0.1
    label = "Collect Frames"
    families = ["camera", "vdbcache", "imagesequence", "ass",
                "redshiftproxy", "review", "pointcache", "fbx",
                "model", "bgeo", "image_rop"]

    log: logging.Logger

    def process(self, instance: pyblish.api.Instance):

        # CollectRopFrameRange computes `start_frame` and `end_frame`
        #  depending on the trange value.
        start_frame = instance.data["frameStartHandle"]
        end_frame = instance.data["frameEndHandle"]
        frame_step = instance.data["byFrameStep"]

        # Evaluate the file name at the first frame.
        ropnode: hou.Node = hou.node(instance.data["instance_node"])  # ty: ignore[invalid-assignment]  # we know the path is valid
        output_parm = lib.get_output_parameter(ropnode)

        if start_frame != end_frame and output_parm.isTimeDependent():

            if frame_step % 1.0 == 0:
                frames = range(start_frame, end_frame+1)
            else:
                frames = float_range(start_frame, end_frame, frame_step)

            files = [str(output_parm.evalAtFrame(frame)) for frame in frames]
            staging_dir = os.path.dirname(files[0])
            files = [os.path.basename(file) for file in files]

        else:
            files = str(output_parm.evalAtFrame(start_frame))
            staging_dir = os.path.dirname(files)
            files = os.path.basename(files)

        self.log.debug(f"Collected Frames: {files} in {staging_dir}")
        instance.data.update({
            "frames": files,
            "stagingDir": staging_dir,
        })

float_range(start, end, step)

Simple float range generator.

Source code in client/ayon_houdini/plugins/publish/collect_frames.py
16
17
18
19
20
21
22
23
24
def float_range(start: float, end: float, step: float) -> list[float]:
    """Simple float range generator."""
    if step == 0:
        raise ValueError("step must be non-zero")

    num_steps = int((end - start) / step)
    if num_steps < 0:
        return []
    return [start + i * step for i in range(num_steps + 1)]