When working with the UsdStageActor, the “Reload stage” functionality doesn’t work with USD files, only USDA files. In order to get a USD stage to fully refresh, you need to close the stage and reopen it. We’d really like to be able to take advantage of the smaller file sizes and faster load times of USD files, but we also need to be able to reload them as artists iterate on their scenes.
Steps to Reproduce
- In a blank Unreal project, enable the USD plugin, restart the engine
USDA file (works as expected)
- In a level, create a USDStageActor and open the sphere_1.usda file
- Replace or update the sphere_1.usda file with the contents of sphere_2.usda
- Reload the stage (File > Reload Stage)
- The updates can be seen in the editor
USD file (doesn’t work as expected)
- In a level, create a USDStageActor and open the sphere_1.usd file
- Replace the sphere_1.usd file with the contents of sphere_2.usd
- Reload the stage (File > Reload Stage)
- The updates aren’t shown in the editor. Completely closing and reopening the stage shows the changes
Hi Gabriel,
Unfortunately, we’ve not been able to reproduce your issue (tested in 5.5.4). After replacing sphere_1.usd with the content of sphere2_usd and reloading the stage, the sphere moved to its new location.
In your 2nd step (Replace the sphere_1.usd file with the contents of sphere_2.usd), you did not specify how it was done, but on Windows, it was not possible to delete or copy over sphere_1.usd since it was locked by the OS. Strangely, it was possible to move or rename sphere_1.usd and then rename sphere_2.usd and copy it in the same location as the previous sphere_1.usd.
Are you on Windows?
When I try with your script, after opening the resulting USD file on the UsdStageActor and try rerunning the script with the new translation value, I get an error:
Error in 'pxrInternal_v0_24__pxrReserved__::SdfLayer::_CreateNew' at line 617 in file C:\OpenUSD_src\pxr\usd\sdf\layer.cpp : 'A layer already exists with identifier 'c:/Epic Games/UE_5.5/Engine/Binaries/Win64/my_sphere.usd''
since the file is already opened in the stage actor (and locked). That means it can’t create the USD file with the same name and location.
In any case, this looks more like the USD file itself not being updated as you would expected. The “Reload Stage” functionality itself goes through a single code path, ie. it does not depend on the file format or extension.
And as mentioned in the previous reply, I was able to reload the new USD file by either moving or renaming the initial sphere_1.usd file and replacing it with the sphere_2.usd content renamed to sphere_1.usd.
Ah ok, it’s possible the mixed environments give this unexpected behavior. Is the file actually updated on Windows after you “overwrite” it from Linux?
Instead of creating a new stage and overwriting the file, you could call Usd.Stage.Open with the path to the file on Windows mapped to Linux and edit the stage that way, but that’s maybe not the workflow you want.
I’m not seeing the files I attached, so I’m re-uploading them here
Sorry, my bad for not including how I was replacing the files. I was writing the files directly with a python script. So I would run this code
`from pxr import Usd, UsdGeom, Gf, Sdf
stage = Usd.Stage.CreateNew(“sphere_1.usd”)
xform = UsdGeom.Xform.Define(stage, Sdf.Path(“/xform”))
xform.AddTranslateOp().Set(value=Gf.Vec3d(0, 0, 0))
sphere = stage.DefinePrim(“/xform/sphere”, “Sphere”)
stage.GetRootLayer().Save()`Then open the file with a UsdStageActor. I’d then update the TranslateOp value to (10, 0, 0), rerun the script, and reload the stage from Unreal.
Maybe it’s more of a Windows permissions issue than an Unreal issue?
Ah, I think that’s the problem. I’m opening Unreal and the USD stage from Windows, but I’m overwriting the files from a linux machine over the network. I’m assuming I’m actually not supposed to be editing a .usd file while it’s open within Unreal, and normally it would give me an error, but since it’s over the network, the permissions aren’t as strict.
I do get the same error as you when I try to write over the file from Windows.