Change target layer temporarily with edit routing
What is edit routing
When modifying USD data, the modifications are written to the target layer by default. If you need to write some edits on a different layer and then return to the target layer, you can use Edit routing. Edit routing is a mechanism that allows you to temporarily change the location where your edits are written, without having to change the actual target layer in the USD Layer Editor. With edit routing, when edits are about to happen, you can specify which layer will receive the edits, and the Maya USD plug-in can temporarily change the target layer to the specified layer.
This mechanism allows advanced users to write code (scripts or plug-ins) to handle the routing. The script receives information about which USD prim is about to be changed and the name of the operation that is about to modify that prim. In the case of attribute changes, the name of the attribute is also provided. Given this information, the script can choose a specific layer among the available layers. It returns the layer it wants to target. Edit routing is divided in two categories: commands and attributes. Visit Maya USD GitHub for more information.
Enable edit routing
To work with edit routing and learn more about usage, see Github documentation topic and code from the Github repository.
The edit routing toggle will persist across Maya sessions.
Edit routing use cases
As a pipeline TD or advanced user, you can use edit routing to:
- Set up your own Edit Router by knowing the command, source layer, and routed layer.
- Set up your own Edit Router by knowing the command and source layer, and knowing when you want edits to be prevented for a specific soure layer.
When Routing Edits is enabled for the visibility command (ie. after enabling the edit routing via script, setting the visibility attribute for a prim), you will now have visibility opinions in the session layer. Now you can work in this target layer (ie. layout.usd) and be able to rename/reparent/regroup the prim without being restricted by MayaUSD Default Restrictions. After the rename/reparent/regroup, the visibility opinions will still apply to the newly edited prim and you can continue working.
Your session layer will stay in sync when removing, reparenting, or grouping prims when edit routing is enabled. When the session layer has an opinion of a prim and that prim gets removed/reparented/regrouped, the result will also happen in the session layer.
Within the edit router, the Maya SDK, UFE and MayaUsd callbacks are accessible. If the edit router needs more information, it can retrieve it by calling the provided SDK.