/// <summary> /// Add an array of 3-D points to the document /// </summary> public object AddPoints(object pointsObj) { On3dPointArray points = new On3dPointArray(); if (SampleCsRhinoScriptUtils.ConvertToOn3dPointArray(pointsObj, ref points)) { MRhinoDoc doc = RhUtil.RhinoApp().ActiveDoc(); if (null != doc) { ArrayList objectIds = new ArrayList(); for (int i = 0; i < points.Count(); i++) { MRhinoObject rhinoObj = doc.AddPointObject(points[i]); if (null != rhinoObj) { objectIds.Add(rhinoObj.ModelObjectId().ToString()); } } if (objectIds.Count > 0) { doc.Redraw(); return(objectIds.ToArray()); } } } return(null); }
/// <summary> /// Convert an object to an On3dPointArray /// </summary> public static bool ConvertToOn3dPointArray(object pointsObj, ref On3dPointArray points) { bool rc = false; int pointsCount = points.Count(); Array pointsArr = pointsObj as Array; if (null != pointsArr) { for (int i = 0; i < pointsArr.Length; i++) { On3dPoint point = new On3dPoint(); if (SampleCsRhinoScriptUtils.ConvertToOn3dPoint(pointsArr.GetValue(i), ref point)) points.Append(point); } rc = (points.Count() - pointsCount > 0); } return rc; }
///<summary> This gets called when when the user runs this command.</summary> public override IRhinoCommand.result RunCommand(IRhinoCommandContext context) { MRhinoGetObject go = new MRhinoGetObject(); go.SetCommandPrompt("Select two surfaces or polysurfacs to intersect"); go.SetGeometryFilter(IRhinoGetObject.GEOMETRY_TYPE_FILTER.surface_object); go.EnableSubObjectSelect(false); go.GetObjects(2, 2); if (go.CommandResult() != IRhinoCommand.result.success) { return(go.CommandResult()); } IOnBrep B0 = go.Object(0).Brep(); IOnBrep B1 = go.Object(1).Brep(); if (null == B0 || null == B1) { return(IRhinoCommand.result.failure); } OnCurve[] curves = null; On3dPointArray points = null; bool rc = RhUtil.RhinoIntersectBreps(B0, B1, context.m_doc.AbsoluteTolerance(), out curves, out points); if ( false == rc || null == curves || 0 == curves.Length || null == points || 0 == curves.Length ) { RhUtil.RhinoApp().Print("No intersections found.\n"); return(IRhinoCommand.result.nothing); } if (null != curves) { for (int i = 0; i < curves.Length; i++) { context.m_doc.AddCurveObject(curves[i]); } } if (null != points) { for (int i = 0; i < points.Count(); i++) { context.m_doc.AddPointObject(points[i]); } } context.m_doc.Redraw(); return(IRhinoCommand.result.success); }
/// <summary> /// Convert an object to an On3dPointArray /// </summary> static public bool ConvertToOn3dPointArray(object pointsObj, ref On3dPointArray points) { bool rc = false; int pointsCount = points.Count(); Array pointsArr = pointsObj as Array; if (null != pointsArr) { for (int i = 0; i < pointsArr.Length; i++) { On3dPoint point = new On3dPoint(); if (SampleCsRhinoScriptUtils.ConvertToOn3dPoint(pointsArr.GetValue(i), ref point)) { points.Append(point); } } rc = (points.Count() - pointsCount > 0); } return(rc); }
// Adds one or more points from a RMA.OpenNURBS.On3dPointArray object public void Add(On3dPointArray points) { if (points != null) { int point_count = points.Count(); int total_count = this.Count + point_count; this.Capacity = total_count; for (int i = 0; i < point_count; i++) { Add(points.get_ValueAt(i)); } } }
/// <summary> /// Add an array of 3-D points to the document /// </summary> public object AddPoints(object pointsObj) { On3dPointArray points = new On3dPointArray(); if (SampleCsRhinoScriptUtils.ConvertToOn3dPointArray(pointsObj, ref points)) { MRhinoDoc doc = RhUtil.RhinoApp().ActiveDoc(); if (null != doc) { ArrayList objectIds = new ArrayList(); for (int i = 0; i < points.Count(); i++) { MRhinoObject rhinoObj = doc.AddPointObject(points[i]); if (null != rhinoObj) objectIds.Add(rhinoObj.ModelObjectId().ToString()); } if (objectIds.Count > 0) { doc.Redraw(); return objectIds.ToArray(); } } } return null; }