Skip to content

Updating references in the reference editor when they have been changed from external code #4207

Open
@adubois-spin

Description

@adubois-spin

Problem

We have created a widget, made accessible from the outliner, that allows the user to change the expression variables of every USD layer in the stage. The possible values for each expression variable is accessible through a combo box.

Once we change one of the layer path through this widget, Maya reacts most of the time correctly to this change by doing the update in the outliner.
The problem arise when we change an expression variable of a USD layer that contains a MayaReference, in our case we are updating an expression variable in a layer representing a rig.
In this case, the outliner updates correctly, but the Maya Reference Editor does not, it still represents the old resolved name.

Proposed solutions

In Maya USD, you already have a USD listener for the Layer Editor, the LayerTreeModel object. This object has the responsibility to update the layer editor of any USD layer change, especially through the usd_layerChanged method. A first solution would be to filter the changes here and to update the reference editor from there in the code. This would be a quick and dirty solution.

A second solution would be to create a second USD listener in the code of the Maya Reference Editor. This listener only task would be for now to update the Maya Reference that would have been changed through the USD interface.

I personally think the second solution is better in term of design but it is also more costly to implement.

Support request

We have a second problem that arise in our widget. After modifying the expression variable, we reload the USD stage in our code calling stage.Reload(). Doing so raises an error in the script editor log. The error is the following:

Detected USD threading violation. Concurrent changes to layer(s) composed in stage {adress} rooted at {path}

Do you have an idea that would allow us to not get this error?
From what I understand we made a change to the layer in a thread that is different from the changes made afterwards from a different thread.
Do you know how we could update our USD stage without violating the thread rule?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions