Skip to content

play_in_rv

PlayInExistingRVAction

Bases: _BasePlayInRVAction

Open representations in already running network connected OpenRV.

Source code in client/ayon_openrv/plugins/load_actions/global/play_in_rv.py
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
class PlayInExistingRVAction(_BasePlayInRVAction):
    """Open representations in already running network connected OpenRV."""
    identifier = "openrv.play-in-existing-rv"
    label = "Open in Existing RV"

    def execute_action(
        self,
        selection: LoaderActionSelection,
        data: dict[str, Any],
        form_values: dict[str, Any],
    ) -> LoaderActionResult | None:
        repre_entities = self._get_representations(selection, data)
        if not repre_entities:
            return LoaderActionResult(
                "Failed to find representations in AYON.",
                success=False,
            )

        rv_connector = RVConnector()
        if not rv_connector.is_connected:
            return LoaderActionResult(
                "No existing OpenRV connection found."
                " Make sure OpenRV is running and network connected.",
                success=False,
            )

        # The project is sent with the event: the running session can be in
        # another project than the representations come from.
        payload = json.dumps([
            {
                "objectName": repre_entity["name"],
                "representation": repre_entity["id"],
                "project_name": selection.project_name,
            }
            for repre_entity in repre_entities
        ])
        # This also retries the connection
        with rv_connector:
            rv_connector.send_event(
                "ayon_load_container",
                payload,
                shall_return=False
            )

        return LoaderActionResult("Sent to OpenRV.", success=True)

PlayInRVAction

Bases: _BasePlayInRVAction

Open representations in a new OpenRV instance.

A new instance is always started, on a network port no other session uses, even when an OpenRV session is already running. Use 'Open in Existing RV' to add representations to the running session.

Source code in client/ayon_openrv/plugins/load_actions/global/play_in_rv.py
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
class PlayInRVAction(_BasePlayInRVAction):
    """Open representations in a new OpenRV instance.

    A new instance is always started, on a network port no other session
    uses, even when an OpenRV session is already running. Use 'Open in
    Existing RV' to add representations to the running session.
    """
    identifier = "openrv.play-in-rv"
    label = "Open in RV"

    def execute_action(
        self,
        selection: LoaderActionSelection,
        data: dict[str, Any],
        form_values: dict[str, Any],
    ) -> LoaderActionResult | None:
        addon = self._context.get_addons_manager().get("openrv")
        if addon is None:
            return LoaderActionResult(
                "OpenRV is not available in the current AYON bundle.",
                success=False,
            )

        repre_entities = self._get_representations(selection, data)
        if not repre_entities:
            return LoaderActionResult(
                "Failed to find representations in AYON.",
                success=False,
            )

        try:
            addon.open_representations_in_new_rv(
                selection.project_name, repre_entities
            )
        except Exception as error:
            self.log.warning(
                "Failed to open representations in a new OpenRV instance.",
                exc_info=True,
            )
            return LoaderActionResult(str(error), success=False)

        return LoaderActionResult(
            "Opened in a new OpenRV instance.", success=True
        )