protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
foreach (var rh_obj in doc.Objects)
{
// Try casting the object's geometry as a LinearDimension
var dim = rh_obj.Geometry as Rhino.Geometry.LinearDimension;
if (null != dim)
{
// Dimensions are planar objects, and their reference points
// are 2d points on the dimension's plane.
var dim_points = new Point2d[5];
dim_points[0] = dim.Arrowhead1End;
dim_points[1] = dim.Arrowhead2End;
dim_points[2] = dim.ExtensionLine1End;
dim_points[3] = dim.ExtensionLine2End;
dim_points[4] = dim.TextPosition;
// Get a 3d point by evaluating the 2d points on the
// dimension's plane
var points = new Point3d[5];
for (var i = 0; i < dim_points.Length; i++)
{
var pt = dim_points[i];
points[i] = dim.Plane.PointAt(pt.X, pt.Y);
}
// Add the points
doc.Objects.AddPoints(points);
}
}
doc.Views.Redraw();
return Result.Success;
}