Hi, I’ve encountered an issue when scripting setting a newly created layer as Authoring Layer that causes multiple Authoring Layers (Usd Composer 2023.2.2):
absoluteLayerPath = self.Stage.GetRootLayer().identifier
mainPathParts = absoluteLayerPath.split("/")
mainPathParts[-1] = f"SaveStates"
absoluteLayerPath = "/".join(mainPathParts)
'''User-entered layer name'''
UserEnteredSaveStateName: str = self.SaveStateSaveName.model.get_value_as_string()
layerName: str = "SaveState_" + UserEnteredSaveStateName
relativeLayerPath = f"./SaveStates/{layerName}.usd"
'''Creating directory if it doesn't exist, in an unrelated function'''
self.MakeDirectoryIfNotExists(absoluteLayerPath)
'''Creating new SaveState layer in root to turn it on as Authoring Layer, muting all other SaveStates in scene'''
absoluteLayerPath = absoluteLayerPath + f"/{layerName}.usd"
saveStateLayer: Sdf.Layer = Sdf.Layer.CreateNew(absoluteLayerPath)
'''Appending new SaveState layer's path to RootLayer's subLayerPaths before Main.usd's path, so that when editing SaveState layer set as Authoring Layer it can override Main.usd's strength'''
for idx, path in enumerate(self.Stage.GetRootLayer().subLayerPaths):
if 'Main.usd' in path:
self.Stage.GetRootLayer().subLayerPaths.insert(idx, relativeLayerPath)
break
self.SaveStatesLayers.append(saveStateLayer)
self.Stage.GetRootLayer().Save()
self.Stage.MuteAndUnmuteLayers([l.identifier for l in self.SaveStatesLayers if l != saveStateLayer], [saveStateLayer.identifier])
'''Setting newly created layer as Authoring Layer'''
omni.usd.set_edit_target_by_identifier(self.Stage, absoluteLayerPath)
That last line doesn’t switch the newly created layer to the only Authoring Layer in stage, instead it also sets RootLayer as Authoring Layer:
Trying setting Authoring Layer like so produces the same result:
omni.kit.commands.execute('SetEditTarget', layer_identifier=saveStateLayer.identifier)
When I programatically mute all SaveState layers, the muted layer remains an Authoring Layer, together with Root Layer:
How do I script switching Authoring Layer so I fix this multiple Authoring Layers problem with RootLayer being force-set as one?