Skip to content

set_context_placeholder

SetContextMayaPlaceholderPlugin

Bases: MayaPlaceholderPlugin

Set context variables for the workfile build. This placeholder allows the workfile build process to set context variables dynamically.

Source code in client/ayon_maya/plugins/workfile_build/set_context_placeholder.py
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
73
74
75
76
77
78
79
class SetContextMayaPlaceholderPlugin(MayaPlaceholderPlugin):
    """Set context variables for the workfile build.
    This placeholder allows the workfile build process to
    set context variables dynamically.

    """

    identifier = "maya.set_context"
    label = "Set Context Settings"

    use_selection_as_parent = False

    def get_placeholder_options(self, options=None):
        options = options or {}
        return [
            BoolDef("fps",
                    label="Set FPS",
                    tooltip="Set FPS context variable "
                            "based on the scene settings",
                    default=options.get("fps", True),
            ),
            BoolDef(
                "resolution",
                label="Set Resolution",
                tooltip="Set Resolution context variable "
                        "based on the scene settings",
                default=options.get("resolution", True),
            ),
            BoolDef(
                "frame_range",
                label="Set Frame Range",
                tooltip="Set Frame Range context variable "
                        "based on the scene settings",
                default=options.get("frame_range", True),
            ),
            BoolDef(
                "colorspace",
                label="Set Colorspace",
                tooltip="Set Colorspace context variable "
                        "based on the scene settings",
                default=options.get("colorspace", True),
            ),
            BoolDef(
                "scene_units",
                label="Set Scene Units",
                tooltip="Set Scene Units context variable "
                        "based on the scene settings",
                default=options.get("scene_units", True),
            )
        ]

    def populate_placeholder(self, placeholder):
        self.set_context_settings(placeholder)
        if not placeholder.data.get("keep_placeholder", True):
            self.delete_placeholder(placeholder)

    def set_context_settings(self, placeholder):
        """Set context settings for the placeholder.

        Args:
            placeholder (dict): placeholder data
        """
        placeholder_context_data = {
            "fps": placeholder.data.get("fps", True),
            "resolution": placeholder.data.get("resolution", True),
            "frame_range": placeholder.data.get("frame_range", True),
            "colorspace": placeholder.data.get("colorspace", True),
            "scene_units": placeholder.data.get("scene_units", True),
        }
        set_context_settings(**placeholder_context_data)

set_context_settings(placeholder)

Set context settings for the placeholder.

Parameters:

Name Type Description Default
placeholder dict

placeholder data

required
Source code in client/ayon_maya/plugins/workfile_build/set_context_placeholder.py
66
67
68
69
70
71
72
73
74
75
76
77
78
79
def set_context_settings(self, placeholder):
    """Set context settings for the placeholder.

    Args:
        placeholder (dict): placeholder data
    """
    placeholder_context_data = {
        "fps": placeholder.data.get("fps", True),
        "resolution": placeholder.data.get("resolution", True),
        "frame_range": placeholder.data.get("frame_range", True),
        "colorspace": placeholder.data.get("colorspace", True),
        "scene_units": placeholder.data.get("scene_units", True),
    }
    set_context_settings(**placeholder_context_data)