LarryL
August 6, 2024, 4:07pm
1
@dale , would you expect the logic below to preserve the brep face data? Thanks!
protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
// Create a box brep
var boxBrep = Brep.CreateFromBox(new BoundingBox(new Point3d(-0.5, -0.5, -0.5), new Point3d(0.5, 0.5, 0.5)));
boxBrep.Faces[0].UserDictionary["TestKey"] = "TestValue";
foreach (var pair in boxBrep.Faces[0].UserDictionary)
RhinoApp.WriteLine($"Key = {pair.Key}, Value = {pair.Value}");
var options = new Rhino.FileIO.SerializationOptions()
{
WriteUserData = true
};
var jsonString = boxBrep.ToJSON(options);
var brepFromJson = Rhino.Runtime.CommonObject.FromJSON(jsonString) as Brep;
foreach (var pair in brepFromJson.Faces[0].UserDictionary)
RhinoApp.WriteLine($"Key = {pair.Key}, Value = {pair.Value}");
return Result.Success;
}
dale
(Dale Fugier)
August 6, 2024, 4:39pm
2
Hi @LarryL ,
Since ArchivableDictionary
is not part of openNURBS, I would think not.
@stevebaer should know more about this.
– Dale
stevebaer
(Steve Baer)
August 6, 2024, 4:55pm
3
This should work, but I see in the case of brep faces the dictionary is not getting saved. If you store the dictionary on the top level Brep then the data does properly serialize.
1 Like
LarryL
August 6, 2024, 4:57pm
4
Thanks @dale , @stevebaer , I also found if I store the data on the dictionary of the underlysurface of the face it also gets saved.
Is this something that could be rectified in a future SR (assuming you view it as something that needs rectification )
stevebaer
(Steve Baer)
August 6, 2024, 4:59pm
5
It’s hard to say at this point since I haven’t done any real digging. File I/O code is always something we need to be very careful about which is why I’m hesitant to just state “yes, we’ll fix it”