public static class RhinoGeometryBaseObjectExtensions
{
public static G3_Text GetG3Text(this GeometryBase geometryBase, double? offsetX = default, double? offsetY = default)
{
if (geometryBase != null && geometryBase is AnnotationBase text)
{
return text.GetG3Text(offsetX, offsetY);
}
return default;
}
public static G3_Text GetG3Text(this AnnotationBase annotation, double? offsetX = default, double? offsetY = default)
{
if (annotation != null)
{
return new G3_Text
{
label = annotation.PlainText,
height = annotation.TextHeight,
width = annotation.TextModelWidth,
point = new g3.Vector2d(annotation.GetBoundingBox(true).Center.X, annotation.GetBoundingBox(true).Center.Y),
originPoint = new g3.Vector2d(annotation.Plane.Origin.X, annotation.Plane.Origin.Y),
rotationDegrees = Rhino.RhinoMath.ToDegrees(Rhino.Geometry.Vector3d.VectorAngle(Rhino.Geometry.Vector3d.XAxis, annotation.Plane.XAxis, Rhino.Geometry.Plane.WorldXY)),
rotationRadians = Rhino.Geometry.Vector3d.VectorAngle(Rhino.Geometry.Vector3d.XAxis, annotation.Plane.XAxis, Rhino.Geometry.Plane.WorldXY),
fontSize = 10,
color = annotation.MaskColor
};
}
return default;
}
}
below is an operational code calls the ext methods above:
var layers = file3dm.AllLayers.ToList();
foreach (var layer in layers)
{
var rhinoObjects = file3dm.Objects.FindByLayer(layer);
foreach (var rhinoObject in rhinoObjects)
{
G3_Entity g3_entity;
switch (rhinoObject.Geometry.ObjectType)
{
case ObjectType.Annotation:
g3_entity = rhinoObject.Geometry.GetG3Text();
break;
case ObjectType.Detail:
g3_entity = rhinoObject.Geometry.GetG3Text();
break;
default:
break;
}
}
}
Please note Snippet G3_Text is my internal processing object I am creating from Rhino GeometryBase object if it is AnnotationBase…
Above code works alright on Windows but not giving me any text out when deployed to AWS Lambda or Linux (Ubuntu I have tested with). Rest geometries works ok…