@stevebaer and @dale Can I draw your attention to the following: when I create a Point geometry and add data to its UserDictionary, the information in the dictionary gets lost after the Point is added to the document (see command code below)
This is probably because of these lines in ObjectTable.cs:Add(GeometryBase, ObjectAttributes)
case ObjectType.Point:
return this.AddPoint(((Rhino.Geometry.Point) geometry).Location, attributes);
where only the location is used to re-direct to AddPoint. The UserDictionary info is therefore not copied to the newly added object.
There may be more cases where this is a problem?
To reproduce, run this code:
Point p = new Point(Point3d.Origin);
p.UserDictionary.Set("MY_KEY", "MY_VALUE");
Guid id = doc.Objects.Add(p);
RhinoObject obj = doc.Objects.Find(id);
bool keyFound = obj.Geometry.UserDictionary.ContainsKey("MY_KEY");
if (keyFound)
RhinoApp.WriteLine("Key found. all is good");
else
{
// I get this
RhinoApp.WriteLine("Key not found. oh dear");
}
return Result.Success;
Keep in mind that any surface you bake is added to the document as a Brep. So if you are adding user data inside of your script, make sure to create a Brep from the surface and then add the user data to the Brep before returning.
@dale
OK, Dale
And If you using the code var brep = surface.ToBrep() to convert the surface to Brep, is maybe return null (from the RhinoCommon SDK document). So I question is:
Is any surface can using ToBrep() Convert to Brep?If not,Which type of the surface can not
convert to the Brep Correctly?