Very out of practice with rhinocommon, please forgive if I’m missing something obvious. On a rhino compute server, I’m trying to create a File3dm
, add some geometry, and then send the serialized json for that file off into the internet:
var file = new File3dm();
var sphere = new Sphere(Plane.WorldXY, 1.5);
var id = file.Objects.AddSphere(sphere);
Console.WriteLine(id);
Console.WriteLine(JsonConvert.SerializeObject(sphere));
Console.WriteLine(JsonConvert.SerializeObject(file));
First console statement gives me the guid, as expected:
3e750df1-4fc4-43a5-9222-a2ad1883379e
Second gives me some familiar json, also expected:
{
"IsValid":true,
"BoundingBox":{
"IsValid":true,
"Min":{
"X":-1.5,
"Y":-1.5,
"Z":-1.5
},
"Max":{
"X":1.5,
"Y":1.5,
"Z":1.5
},
"Center":{
"X":0.0,
"Y":0.0,
"Z":0.0
},
"Area":54.0,
"Volume":27.0,
"Diagonal":{
"X":3.0,
"Y":3.0,
"Z":3.0
}
},
"Diameter":3.0,
"Radius":1.5,
"EquitorialPlane":{
"Origin":{
"X":0.0,
"Y":0.0,
"Z":0.0
},
"OriginX":0.0,
"OriginY":0.0,
"OriginZ":0.0,
"XAxis":{
"X":1.0,
"Y":0.0,
"Z":0.0
},
"YAxis":{
"X":0.0,
"Y":1.0,
"Z":0.0
},
"ZAxis":{
"X":0.0,
"Y":0.0,
"Z":1.0
},
"Normal":{
"X":0.0,
"Y":0.0,
"Z":1.0
},
"IsValid":true
},
"EquatorialPlane":{
"Origin":{
"X":0.0,
"Y":0.0,
"Z":0.0
},
"OriginX":0.0,
"OriginY":0.0,
"OriginZ":0.0,
"XAxis":{
"X":1.0,
"Y":0.0,
"Z":0.0
},
"YAxis":{
"X":0.0,
"Y":1.0,
"Z":0.0
},
"ZAxis":{
"X":0.0,
"Y":0.0,
"Z":1.0
},
"Normal":{
"X":0.0,
"Y":0.0,
"Z":1.0
},
"IsValid":true
},
"Center":{
"X":0.0,
"Y":0.0,
"Z":0.0
},
"NorthPole":{
"X":9.18454765366783E-17,
"Y":0.0,
"Z":1.5
},
"SouthPole":{
"X":9.18454765366783E-17,
"Y":0.0,
"Z":-1.5
}
}
And the last one, our problem child, seems to just give me an empty File3dm:
{
"StartSectionComments":null,
"Notes":{
"Notes":null,
"IsVisible":false,
"IsHtml":false,
"WindowRectangle":"0, 0, 0, 0"
},
"ApplicationName":null,
"ApplicationUrl":null,
"ApplicationDetails":null,
"CreatedBy":null,
"LastEditedBy":null,
"Created":"0001-01-01T00:00:00",
"LastEdited":"0001-01-01T00:00:00",
"Revision":0,
"Settings":{
"ModelUrl":null,
"ModelBasepoint":{
"X":0.0,
"Y":0.0,
"Z":0.0
},
"ModelAbsoluteTolerance":0.001,
"ModelAngleToleranceRadians":0.017453292519943295,
"ModelAngleToleranceDegrees":1.0,
"ModelRelativeTolerance":0.01,
"PageAbsoluteTolerance":0.001,
"PageAngleToleranceRadians":0.017453292519943295,
"PageAngleToleranceDegrees":1.0,
"PageRelativeTolerance":0.01,
"ModelUnitSystem":2,
"PageUnitSystem":2
},
"Manifest":[
{
}
],
"Objects":[
{
}
],
"Materials":[
],
"AllMaterials":[
],
"Linetypes":[
],
"AllLinetypes":[
],
"Layers":[
],
"AllLayers":[
],
"AllGroups":[
],
"DimStyles":[
],
"AllDimStyles":[
],
"HatchPatterns":[
],
"AllHatchPatterns":[
],
"InstanceDefinitions":[
],
"AllInstanceDefinitions":[
],
"Views":[
],
"AllViews":[
],
"NamedViews":[
],
"AllNamedViews":[
],
"NamedConstructionPlanes":[
],
"AllNamedConstructionPlanes":[
],
"PlugInData":[
],
"Strings":{
"Count":0,
"DocumentUserTextCount":0
}
}
“Objects”, in this case, notably not empty, but giving me an empty object. This is what I get for every geometry type I’ve tried. If I add multiple geometries, I get multiple empty objects.
Is there a step I’m missing, if I want the geometry to exist in the final json object? I’m not above serializing each bit of geometry on its own and building the json string manually, but I don’t think that’s a great move.