// Returns a new RMA.OpenNURBS.On3dPointArray object public On3dPointArray ToPointArray() { int count = this.Count; On3dPointArray points = new On3dPointArray(count); for (int i = 0; i < count; i++) { points.Append(this[i]); } return(points); }
/// <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> /// 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); }
///<summary> /// This gets called when when the user runs this command. ///</summary> public override IRhinoCommand.result RunCommand(IRhinoCommandContext context) { MRhinoGetFileDialog dlg = new MRhinoGetFileDialog(); if (dlg.DisplayFileDialog(IRhinoGetFileDialog.file_dialog_type.open_text_file_dialog)) { string filename = dlg.FileName(); string line = ""; RhUtil.RhinoApp().Print(string.Format("Opening file {0}.\n", filename)); char[] delim = new char[2]; delim[0] = ','; delim[1] = '\0'; On3dPointArray points = new On3dPointArray(8); StreamReader reader = new StreamReader(filename); line = reader.ReadLine(); while (line != null && line.Length > 0) { string[] substrs = line.Split(delim); if (substrs.Length == 3) { On3dPoint p = new On3dPoint(); p.x = double.Parse(substrs[0]); p.y = double.Parse(substrs[1]); p.z = double.Parse(substrs[2]); points.Append(p); } line = reader.ReadLine(); } OnNurbsCurve curve = RhUtil.RhinoInterpCurve(3, points, null, null, 1); context.m_doc.AddCurveObject(curve); reader.Close(); } context.m_doc.Redraw(); return(IRhinoCommand.result.success); }
///<summary> /// This gets called when when the user runs this command. ///</summary> public override IRhinoCommand.result RunCommand(IRhinoCommandContext context) { MRhinoGetFileDialog dlg = new MRhinoGetFileDialog(); if (dlg.DisplayFileDialog(IRhinoGetFileDialog.file_dialog_type.open_text_file_dialog)) { string filename = dlg.FileName(); string line = ""; RhUtil.RhinoApp().Print(string.Format("Opening file {0}.\n", filename)); char[] delim = new char[2]; delim[0] = ','; delim[1] = '\0'; On3dPointArray points = new On3dPointArray(8); StreamReader reader = new StreamReader(filename); line = reader.ReadLine(); while(line != null && line.Length > 0) { string[] substrs = line.Split(delim); if(substrs.Length == 3) { On3dPoint p = new On3dPoint(); p.x = double.Parse(substrs[0]); p.y = double.Parse(substrs[1]); p.z = double.Parse(substrs[2]); points.Append(p); } line = reader.ReadLine(); } OnNurbsCurve curve = RhUtil.RhinoInterpCurve(3, points, null, null, 1); context.m_doc.AddCurveObject(curve); reader.Close(); } context.m_doc.Redraw(); return IRhinoCommand.result.success; }