///<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 surface"); go.SetGeometryFilter(IRhinoGetObject.GEOMETRY_TYPE_FILTER.surface_object); go.EnableSubObjectSelect(false); go.GetObjects(1, 1); if (go.CommandResult() != IRhinoCommand.result.success) { return(go.CommandResult()); } IOnSurface srf = go.Object(0).Surface(); if (null == srf) { return(IRhinoCommand.result.failure); } IOnNurbsSurface ns = srf.NurbsSurface(); if (null == ns) { RhUtil.RhinoApp().Print("Not a NURBS surface.\n"); return(IRhinoCommand.result.nothing); } On3dPoint cv = new On3dPoint(); string str = string.Empty; for (int u = 0; u < ns.CVCount(0); u++) { for (int v = 0; v < ns.CVCount(1); v++) { if (ns.GetCV(u, v, ref cv)) { str = string.Empty; RhUtil.RhinoFormatPoint(cv, ref str); RhUtil.RhinoApp().Print(string.Format("CV({0},{1}) = {2}\n", u, v, str)); } } } return(IRhinoCommand.result.success); }
///<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 curve"); go.SetGeometryFilter(IRhinoGetObject.GEOMETRY_TYPE_FILTER.curve_object); go.EnableSubObjectSelect(false); go.GetObjects(1, 1); if (go.CommandResult() != IRhinoCommand.result.success) { return(go.CommandResult()); } IOnCurve curve = go.Object(0).Curve(); if (null == curve) { return(IRhinoCommand.result.failure); } // Several types of OnCurve objects can have the form of a polyline, // including OnLineCurve, a degree 1 OnNurbsCurve, ON_PolylineCurve, // and ON_PolyCurve (whose segments form a polyline). OnCurve.IsPolyline // tests a curve to see if it can be represented as a polyline. ArrayOn3dPoint points = new ArrayOn3dPoint(64); int point_count = curve.IsPolyline(points); if (point_count > 0) { string point_str = string.Empty; for (int i = 0; i < point_count; i++) { point_str = string.Empty; RhUtil.RhinoFormatPoint(points[i], ref point_str); RhUtil.RhinoApp().Print(string.Format("Point {0} = {1}\n", i, point_str)); } } return(IRhinoCommand.result.success); }