Cannot deserialize Layer FromJSON()

same logic works for serialize/deserialize geometry, but fails with Layers. Any hint on what is going wrong?
thanks

import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino
import Rhino.Geometry as rg
import System
import json as json
from Rhino.RhinoDoc import ActiveDoc as doc

def pyDict2NetDict(pyDict):
    sysdict = System.Collections.Generic.Dictionary[str,str]()
    for key,item in pyDict.items():
        sysdict.Add(str(key),str(item))
    return sysdict


js = doc.Layers[0].ToJSON(Rhino.FileIO.SerializationOptions())
pyDict = json.loads(js)
sysDict =  pyDict2NetDict(pyDict)

layer = Rhino.DocObjects.Layer.FromJSON(sysDict) #line 30

image

When applied to serialize/deserialize geometry, logic works

Hi @aitorleceta,

Yes, I see that. I’ve logged the issue.

https://mcneel.myjetbrains.com/youtrack/issue/RH-62839

Thanks,

– Dale

1 Like

Ok, enough to know that JSON serialization only works for geometry. I was attempting to save a kinda “document state” (which pretended to save also data related to Layers) in a JSON file, but it will be easy to implement an alternative myself. thanks.