Skip to content

create_render

Create render.

CreateRenderlayer

Bases: BlenderCreator

Single baked camera.

Source code in client/ayon_blender/plugins/create/create_render.py
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
class CreateRenderlayer(plugin.BlenderCreator):
    """Single baked camera."""

    identifier = "io.openpype.creators.blender.render"
    label = "Render"
    product_type = "renderlayer"
    icon = "eye"

    def create(
        self, product_name: str, instance_data: dict, pre_create_data: dict
    ):
        try:
            # Run parent create method
            collection = super().create(
                product_name, instance_data, pre_create_data
            )

            prepare_rendering(collection)
        except Exception:
            # Remove the instance if there was an error
            bpy.data.collections.remove(collection)
            raise

        # TODO: this is undesiderable, but it's the only way to be sure that
        # the file is saved before the render starts.
        # Blender, by design, doesn't set the file as dirty if modifications
        # happen by script. So, when creating the instance and setting the
        # render settings, the file is not marked as dirty. This means that
        # there is the risk of sending to deadline a file without the right
        # settings. Even the validator to check that the file is saved will
        # detect the file as saved, even if it isn't. The only solution for
        # now it is to force the file to be saved.
        if not bpy.data.filepath:
            version_up_current_workfile()
        else:
            filepath = version_up(bpy.data.filepath)
            save_file(filepath, copy=False)

        return collection

    def get_instance_attr_defs(self):
        defs = lib.collect_animation_defs(self.create_context)

        return defs