I've encountered a bug in the Autodesk Viewer LayerManager extension that breaks the restoreState functionality. I am saving the state of a multilayer DWG file using getState and re-applying that state using restoreState. When i restore state, most or all of the layers are hidden, even if they weren't when i saved the state.
It looks like this is an issue with how the state is being saved and interpreted. I dug into the state JSON and found the list of visible layers (state.objectSet[0].isolated
) in this form:
["0","1","2","3","4","5"]
After some experimenting i found out that the LayerManager is expecting either the integer indices of the layers or the string names of the layers. Something like:
[0,1,2,3,4,5]
or
["layer0","layer1","layer2","layer3","layer4","layer5"]
(assuming those are the names of each layer)
So the current implementation breaks because it looks for layers with the names "0", "1", "2", etc. no matter what the actual layer names are.
I am wondering if there is a way to fix or work around this. A temporary solution is to parse the state JSON and cast the layer numbers to integers but that is a bit of a hack.