/// <summary> /// Add an array of 3-D points to the document /// </summary> public object AddPoints(object pointsObj) { List <Rhino.Geometry.Point3d> points = new List <Rhino.Geometry.Point3d>(); if (SampleRhinoHelpers.ConvertToPoint3dList(pointsObj, ref points)) { Rhino.RhinoDoc doc = Rhino.RhinoDoc.ActiveDoc; if (null != doc) { ArrayList objectIds = new ArrayList(); for (int i = 0; i < points.Count(); i++) { System.Guid objectId = doc.Objects.AddPoint(points[i]); if (!objectId.Equals(System.Guid.Empty)) { objectIds.Add(objectId.ToString()); } } if (objectIds.Count > 0) { doc.Views.Redraw(); return(objectIds.ToArray()); } } } return(null); }
/// <summary> /// Add a 3-D point to the document /// </summary> public object AddPoint(object pointObj) { Rhino.Geometry.Point3d point = new Rhino.Geometry.Point3d(); if (SampleRhinoHelpers.ConvertToPoint3d(pointObj, ref point)) { Rhino.RhinoDoc doc = Rhino.RhinoDoc.ActiveDoc; if (null != doc) { System.Guid objectId = doc.Objects.AddPoint(point); if (!objectId.Equals(System.Guid.Empty)) { doc.Views.Redraw(); return(objectId.ToString()); } } } return(null); }
/// <summary> /// Converts an object to a list of Rhino.Geometry.Point3d /// </summary> static public bool ConvertToPoint3dList(object pointsObj, ref List <Rhino.Geometry.Point3d> points) { bool rc = false; int pointsCount = points.Count; Array pointsArr = pointsObj as Array; if (null != pointsArr) { for (int i = 0; i < pointsArr.Length; i++) { Rhino.Geometry.Point3d point = new Rhino.Geometry.Point3d(); if (SampleRhinoHelpers.ConvertToPoint3d(pointsArr.GetValue(i), ref point)) { points.Add(point); } } rc = (points.Count - pointsCount > 0); } return(rc); }