[EMSUSD-1251] MayaUsdProxy node not refreshing properly
- Dominant language
- Wolfram Language
- Stars
- 905
- Forks
- 223
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 17
Description
**Describe the bug**
I am attempting to load a usd stage inside a MayaUsdProxy node using python code, however the stage doesn't appear to load under certain circumstances. Specifically when the anonymous session/root layer has unsaved edits, and you perform a save operation directly prior to setting the proxy filePath attribute.
**Steps to reproduce**
1) Create an empty MayaUsdProxy node in the scene root (Create->USD->Stage with New Layer)
2) Expand the proxy to its shape and add an xform (right-click on stageShape1->Add New Prim->Xform
3) Run this code all in one execution. (saves the file out then sets the proxy filepath to a predefined usd file, which I've attached)
```
cmds.file(
"/tmp/save_test.ma",
type="mayaAscii",
force=True,
exportAll=True,
preserveReferences=True,
exportUnloadedReferences=True
)
cmds.setAttr("stageShape1.filePath", "/tmp/cube.usda", type="string")
```
After doing this, the proxy filepath attribute appears to be populated, but the usd file itself did not get loaded. The proxy's root layer is still pointing to an anonymous layer:

**Expected behavior**
I expect that any existing root layer (anonymous or not) gets cleared out and replaced by the layer specified by the filepath.
**Attachments**
[cube.zip](https://github.com/Autodesk/maya-usd/files/9067477/cube.zip)
**Specs (if applicable):**
- CentOS 7.9
- Maya version 2022.3
- Maya USD commit: 0.18
- Pixar USD commit: 21.08
**Additional context**
Things seem to work fine when I omit the save operation in the code. And they work fine when I execute the code separately and sequentially. And it works fine if there are no edits on the anonymous session or root layer. It just so happens that I need it to work under this perfect storm of a scenario..
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.