/// <summary> /// get plot 과 set boundary 분리함. /// 재활용 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Btn_GetPlot_Click(object sender, RoutedEventArgs e) { Hide(); ButtonStateCheck(ButtonState.None); var gcc = new GetObject(); gcc.SetCommandPrompt("select closed curve"); gcc.GeometryFilter = Rhino.DocObjects.ObjectType.Curve; gcc.GeometryAttributeFilter = GeometryAttributeFilter.ClosedCurve; gcc.SubObjectSelect = false; gcc.Get(); if (gcc.CommandResult() != Result.Success) { Show(); return; } if (null == gcc.Object(0).Curve()) { Show(); return; } Curve boundary = gcc.Object(0).Curve(); SetCurve(boundary); }
protected override Result RunCommand(RhinoDoc doc, RunMode mode) { var go = new GetObject(); go.SetCommandPrompt("Select block to explode"); go.GeometryFilter = ObjectType.InstanceReference; go.Get(); if (go.CommandResult() != Result.Success) { return(go.CommandResult()); } if (!(go.Object(0).Object() is InstanceObject iref)) { return(Result.Failure); } var xform = Transform.Identity; var rc = ExplodeBlockHelper(doc, iref, xform); if (rc) { doc.Objects.Delete(go.Object(0), false); doc.Views.Redraw(); } return(Result.Success); }
protected override Result RunCommand(RhinoDoc doc, RunMode mode) { GetObject go = new GetObject(); go.SetCommandPrompt("Select two curves for planar curve containment test"); go.GeometryFilter = ObjectType.Curve; go.GeometryAttributeFilter = GeometryAttributeFilter.ClosedCurve; go.SubObjectSelect = false; go.GetMultiple(2, 2); if (go.CommandResult() != Result.Success) { return(go.CommandResult()); } Rhino.Geometry.Curve curveA = go.Object(0).Curve(); Rhino.Geometry.Curve curveB = go.Object(1).Curve(); if (null == curveA || null == curveB) { return(Result.Failure); } Plane planeA, planeB; if (!curveA.IsPlanar() || !curveA.TryGetPlane(out planeA)) { RhinoApp.WriteLine("Curve A is not planar."); return(Result.Success); } if (!curveB.IsPlanar() || !curveB.TryGetPlane(out planeB)) { RhinoApp.WriteLine("Curve B is not planar."); return(Result.Success); } double tol = Rhino.RhinoMath.ZeroTolerance; RegionContainment rc = Curve.PlanarClosedCurveRelationship(curveA, curveB, planeA, tol); switch (rc) { case RegionContainment.Disjoint: RhinoApp.WriteLine("There is no common area between the two regions."); break; case RegionContainment.MutualIntersection: RhinoApp.WriteLine("The two curves intersect. No full containment relationship exists."); break; case RegionContainment.AInsideB: RhinoApp.WriteLine("Region bounded by curveA (first curve) is inside of curveB (second curve)."); break; case RegionContainment.BInsideA: RhinoApp.WriteLine("Region bounded by curveB (second curve) is inside of curveA (first curve)."); break; } return(Result.Success); }
protected override Result RunCommand(RhinoDoc doc, RunMode mode) { var go0 = new GetObject(); go0.SetCommandPrompt("Select surface or polysurface to subtract from"); go0.GeometryFilter = ObjectType.Surface | ObjectType.PolysrfFilter; go0.SubObjectSelect = false; go0.Get(); if (go0.CommandResult() != Result.Success) { return(go0.CommandResult()); } var brep0 = go0.Object(0).Brep(); if (null == brep0) { return(Result.Failure); } var go1 = new GetObject(); go1.SetCommandPrompt("Select surface or polysurface to subtract with"); go1.GeometryFilter = ObjectType.Surface | ObjectType.PolysrfFilter; go1.SubObjectSelect = false; go1.EnablePreSelect(false, true); go1.DeselectAllBeforePostSelect = false; go1.Get(); if (go1.CommandResult() != Result.Success) { return(go1.CommandResult()); } var brep1 = go1.Object(0).Brep(); if (null == brep1) { return(Result.Failure); } var tolerance = doc.ModelAbsoluteTolerance; var out_breps = Brep.CreateBooleanDifference(brep0, brep1, tolerance); if (null != out_breps && out_breps.Length > 0) { foreach (var b in out_breps) { doc.Objects.AddBrep(b); } doc.Objects.Delete(go0.Object(0).ObjectId, true); doc.Objects.Delete(go1.Object(0).ObjectId, true); } doc.Views.Redraw(); return(Result.Success); }
protected override Result RunCommand(RhinoDoc doc, RunMode mode) { var go = new GetObject(); go.SetCommandPrompt("Select two curves for intersection test"); go.GeometryFilter = ObjectType.Curve; go.GetMultiple(2, 2); if (go.CommandResult() != Result.Success) { return(go.CommandResult()); } var curve0 = go.Object(0).Curve(); var curve1 = go.Object(1).Curve(); if (null == curve0 || null == curve1) { return(Result.Failure); } var tolerance = doc.ModelAbsoluteTolerance; var ccx_events = Intersection.CurveCurve(curve0, curve1, tolerance, tolerance); foreach (var ccx in ccx_events) { var rhobject_id = Guid.Empty; if (ccx.IsPoint) { rhobject_id = doc.Objects.AddPoint(ccx.PointA); } else if (ccx.IsOverlap) { var curve = curve0.Trim(ccx.OverlapA); if (null != curve) { rhobject_id = doc.Objects.AddCurve(curve); } } if (rhobject_id != Guid.Empty) { var rhobject = doc.Objects.Find(rhobject_id); if (null != rhobject) { rhobject.Select(true); } } } doc.Views.Redraw(); return(Result.Success); }
protected override Result RunCommand(RhinoDoc doc, RunMode mode) { var go = new GetObject(); go.SetCommandPrompt("Select objects to isolate"); go.GroupSelect = true; go.SubObjectSelect = false; go.GetMultiple(1, 0); if (go.CommandResult() != Result.Success) { return(go.CommandResult()); } for (int i = 0; i < go.ObjectCount; i++) { var obj = go.Object(i).Object(); if (null != obj) { obj.Select(true); } } doc.Views.RedrawEnabled = false; RhinoApp.RunScript("_-Invert", false); string script = string.Format("_-Hide {0}", SampleCsCommandsPlugIn.Instance.IsolateIndex); RhinoApp.RunScript(script, false); SampleCsCommandsPlugIn.Instance.IsolateIndex++; if (go.ObjectsWerePreselected) { for (int i = 0; i < go.ObjectCount; i++) { var obj = go.Object(i).Object(); if (null != obj) { obj.Select(true); } } } doc.Views.RedrawEnabled = true; return(Result.Success); }
public GH_GetterResult LoadFromSelection(out PointCloud pc) { var go = new GetObject(); go.GeometryFilter = Rhino.DocObjects.ObjectType.Point | Rhino.DocObjects.ObjectType.PointSet; if (go.GetMultiple(1, 0) == Rhino.Input.GetResult.Cancel) { pc = null; return(GH_GetterResult.cancel); } pc = new PointCloud(); for (int i = 0; i < go.ObjectCount; i++) { var obj = go.Object(i); var rhObj = obj.Object(); if (rhObj.ObjectType == ObjectType.Point) { var pt = obj.Point().Location; var col = rhObj.Attributes.ObjectColor; pc.Add(pt, col); } else if (rhObj.ObjectType == ObjectType.PointSet) { using (PointCloud cloud = obj.PointCloud()) { foreach (var item in cloud.AsEnumerable()) { pc.Add(item.Location, item.Normal, item.Color); } } } } return(GH_GetterResult.success); }
protected override Result RunCommand(RhinoDoc doc, RunMode mode) { // TODO: complete command. GetObject gpath = new GetObject(); gpath.SetCommandPrompt("get the pathp"); gpath.GeometryFilter = Rhino.DocObjects.ObjectType.Curve; gpath.SubObjectSelect = false; gpath.Get(); if (gpath.CommandResult() != Rhino.Commands.Result.Success) { return(gpath.CommandResult()); } Rhino.DocObjects.ObjRef my_objref = gpath.Object(0); Rhino.DocObjects.RhinoObject my_obj = my_objref.Object(); if (my_obj == null) { return(Rhino.Commands.Result.Failure); } int path_number = my_obj.Geometry.UserDictionary.Getint("path_number", -1); RhinoApp.WriteLine("the number of the object is {0}", path_number); return(Result.Success); }
protected override Result RunCommand(RhinoDoc doc, RunMode mode) { var go = new GetObject(); go.SetCommandPrompt("Select curves to extract min/max radius points"); go.GeometryFilter = ObjectType.Curve; go.GetMultiple(1, 0); if (go.CommandResult() != Result.Success) { return(go.CommandResult()); } for (var i = 0; i < go.ObjectCount; i++) { var curve = go.Object(i).Curve(); if (null != curve) { var points = new List <Point3d>(); if (GetMinMaxRadiusPoints(curve, points)) { doc.Objects.AddPoints(points); } } } doc.Views.Redraw(); return(Result.Success); }
protected override Result RunCommand(RhinoDoc doc, RunMode mode) { var go = new GetObject(); go.SetCommandPrompt("Select mesh"); go.GeometryFilter = ObjectType.Mesh; go.Get(); if (go.CommandResult() != Result.Success) return go.CommandResult(); var mesh = go.Object(0).Mesh(); if (null == mesh) return Result.Failure; var unwelded_count = 0; for (var topei = 0; topei < mesh.TopologyEdges.Count; topei++) { if (IsUweldedMeshEdge(mesh, topei)) { RhinoApp.WriteLine("Edge({0}) is unwelded", topei); unwelded_count++; } } RhinoApp.WriteLine("Unwelded edge count = {0}", unwelded_count); return Result.Success; }
protected override Result RunCommand(RhinoDoc doc, RunMode mode) { var gm = new GetObject(); gm.SetCommandPrompt("Select mesh"); gm.GeometryFilter = ObjectType.Mesh; gm.Get(); if (gm.CommandResult() != Result.Success) { return(gm.CommandResult()); } var gp = new GetObject(); gp.SetCommandPrompt("Select polyline"); gp.GeometryFilter = ObjectType.Curve; gp.EnablePreSelect(false, true); gp.DeselectAllBeforePostSelect = false; gp.Get(); if (gm.CommandResult() != Result.Success) { return(gp.CommandResult()); } var mesh = gm.Object(0).Mesh(); if (null == mesh) { return(Result.Failure); } var curve = gp.Object(0).Curve(); if (null == curve) { return(Result.Failure); } var polyline_curve = curve as PolylineCurve; if (null == polyline_curve) { RhinoApp.Write("Curve is not a polyline"); return(Result.Nothing); } int[] face_ids; var points = Rhino.Geometry.Intersect.Intersection.MeshPolyline(mesh, polyline_curve, out face_ids); if (points.Length > 0) { foreach (var pt in points) { doc.Objects.AddPoint(pt); } doc.Views.Redraw(); } return(Result.Success); }
protected override Result RunCommand(RhinoDoc doc, RunMode mode) { // TODO: complete command. RhinoApp.WriteLine("The {0} command is under construction.", EnglishName); GetObject gbrep = new GetObject(); gbrep.SetCommandPrompt("get the brep"); gbrep.GeometryFilter = Rhino.DocObjects.ObjectType.Brep; gbrep.SubObjectSelect = false; gbrep.Get(); if (gbrep.CommandResult() != Rhino.Commands.Result.Success) { return(gbrep.CommandResult()); } Rhino.DocObjects.ObjRef my_objref = gbrep.Object(0); Rhino.DocObjects.RhinoObject my_obj = my_objref.Object(); if (my_obj == null) { return(Rhino.Commands.Result.Failure); } Brep brep = my_objref.Brep(); if (brep == null) { return(Result.Failure); } my_obj.Select(false); RhinoApp.WriteLine("the name of the object is {0}", brep.UserDictionary.GetString("name")); return(Result.Success); }
protected override Result RunCommand(RhinoDoc doc, RunMode mode) { var gm = new GetObject(); gm.SetCommandPrompt("Select open mesh"); gm.GeometryFilter = ObjectType.Mesh; gm.GeometryAttributeFilter = GeometryAttributeFilter.OpenMesh; gm.Get(); if (gm.CommandResult() != Result.Success) { return(gm.CommandResult()); } var mesh = gm.Object(0).Mesh(); if (mesh == null) { return(Result.Failure); } var polylines = mesh.GetNakedEdges(); foreach (var polyline in polylines) { doc.Objects.AddPolyline(polyline); } return(Result.Success); }
/// <summary> /// This function selects points /// </summary> /// <param name="message"></param> /// <param name="pointer"></param> public static void XSelectPoints(string message, out Point3dList pointer) { // variables are: // string message // out Point3dList points - the out won't be recognized unless you have Rhino.Collections and the 'out parameters // have to be filled in the function. // don't need a doc because we won't write anything to the document table, only reading. pointer = new Point3dList(); var go = new GetObject(); go.GeometryFilter = Rhino.DocObjects.ObjectType.Point; go.SetCommandPrompt(message); go.GetMultiple(1, 0); if (go.CommandResult() != Result.Success) { return; } for (var i = 0; i < go.ObjectCount; i++) { var point = go.Object(i).Point(); if (null != point) { pointer.Add(point.Location); } } }
protected override Result RunCommand(RhinoDoc doc, RunMode mode) { var go = new GetObject(); go.SetCommandPrompt("Select closed, planar curves for containment test"); go.GeometryFilter = ObjectType.Curve; go.GeometryAttributeFilter = GeometryAttributeFilter.ClosedCurve; go.GetMultiple(2, 2); if (go.CommandResult() != Result.Success) { return(go.CommandResult()); } var plane = go.View().ActiveViewport.ConstructionPlane(); var tol = doc.ModelAbsoluteTolerance; var crvs = new Curve[2]; for (var i = 0; i < 2; i++) { var rh_ref = go.Object(i); var rh_obj = rh_ref.Object(); crvs[i] = rh_ref.Curve(); if (null == rh_obj || null == crvs[i]) { return(Result.Failure); } if (!crvs[i].IsPlanar(tol)) { RhinoApp.WriteLine("Curve is not planar"); rh_obj.Select(true); doc.Views.Redraw(); return(Result.Failure); } } var result = Curve.PlanarClosedCurveRelationship(crvs[0], crvs[1], plane, tol); switch (result) { case RegionContainment.Disjoint: RhinoApp.WriteLine("There is no common area between the two regions."); break; case RegionContainment.MutualIntersection: RhinoApp.WriteLine("The two curves intersect. There is therefore no full containment relationship either way."); break; case RegionContainment.AInsideB: RhinoApp.WriteLine("The region bounded by the first curve is inside of the second curve."); break; case RegionContainment.BInsideA: RhinoApp.WriteLine("The region bounded by the second curve is inside of the second first."); break; } return(Result.Success); }
/// <summary> /// This function selects some curves /// </summary> /// /// public static bool XSelectCurves(string message, out CurveList curves) { curves = new CurveList(); var gc = new GetObject(); gc.SetCommandPrompt(message); gc.GeometryFilter = Rhino.DocObjects.ObjectType.Curve; gc.GetMultiple(1, 0); if (gc.CommandResult() != Result.Success) { return(false); } for (var i = 0; i < gc.ObjectCount; i++) { var curve = gc.Object(i).Curve(); if (null != curve) { curves.Add(curve); } } return(true); }
protected override Result RunCommand(RhinoDoc doc, RunMode mode) { GetObject go = new GetObject(); go.SetCommandPrompt("Select surfaces, polysurfaces, or meshes"); go.GroupSelect = true; go.SubObjectSelect = false; go.EnableClearObjectsOnEntry(false); go.EnableUnselectObjectsOnExit(false); go.DeselectAllBeforePostSelect = false; bool bHavePreselectedObjects = false; for (; ;) { GetResult res = go.GetMultiple(1, 0); if (res == GetResult.Option) { go.EnablePreSelect(false, true); continue; } else if (res != GetResult.Object) { return(Result.Cancel); } if (go.ObjectsWerePreselected) { bHavePreselectedObjects = true; go.EnablePreSelect(false, true); continue; } break; } BoundingBox box = BoundingBox.Empty; for (int i = 0; i < go.ObjectCount; i++) { RhinoObject rhinoObject = go.Object(i).Object(); if (null != rhinoObject) { box.Union(rhinoObject.Geometry.GetBoundingBox(true)); } rhinoObject.Select(false); } if (box.IsValid) { RFContext.ClippingBox = new Box(box); //RFContext.Clip = true; return(Result.Success); } return(Result.Nothing); }
public static Result DupMeshBoundary(RhinoDoc doc) { var gm = new GetObject(); gm.SetCommandPrompt("Select open mesh"); gm.GeometryFilter = ObjectType.Mesh; gm.GeometryAttributeFilter = GeometryAttributeFilter.OpenMesh; gm.Get(); if (gm.CommandResult() != Result.Success) { return(gm.CommandResult()); } var mesh = gm.Object(0).Mesh(); if (mesh == null) { return(Result.Failure); } var polylines = mesh.GetNakedEdges(); foreach (var polyline in polylines) { doc.Objects.AddPolyline(polyline); } return(Result.Success); }
protected override Result RunCommand(RhinoDoc doc, RunMode mode) { var go = new GetObject(); go.SetCommandPrompt("Select objects"); go.GroupSelect = true; go.GetMultiple(1, 0); if (go.CommandResult() != Result.Success) { return(go.CommandResult()); } for (var i = 0; i < go.ObjectCount; i++) { var obj_ref = go.Object(i); var obj = obj_ref.Object(); if (null != obj) { var value = obj.Attributes.GetUserString(SampleCsUserStringData.Key); if (!string.IsNullOrEmpty(value)) { RhinoApp.WriteLine(string.Format("<{0}> {1}", SampleCsUserStringData.Key, value)); } } } return(Result.Success); }
protected override Result RunCommand(RhinoDoc doc, RunMode mode) { var go = new GetObject(); go.SetCommandPrompt("Select polygon meshes to unweld"); go.GeometryFilter = ObjectType.Mesh; go.GetMultiple(1, 0); if (go.CommandResult() != Result.Success) { return(go.CommandResult()); } foreach (var obj_ref in go.Objects()) { var old_mesh = obj_ref.Mesh(); if (null != old_mesh) { var new_mesh = UnweldMesh(old_mesh); if (null != new_mesh && new_mesh.IsValid) { doc.Objects.Replace(go.Object(0), new_mesh); } } } doc.Views.Redraw(); return(Result.Success); }
public static Result ExtendCurve(RhinoDoc doc) { ObjRef[] boundary_obj_refs; var rc = RhinoGet.GetMultipleObjects("Select boundary objects", false, ObjectType.AnyObject, out boundary_obj_refs); if (rc != Result.Success) { return(rc); } if (boundary_obj_refs == null || boundary_obj_refs.Length == 0) { return(Result.Nothing); } var gc = new GetObject(); gc.SetCommandPrompt("Select curve to extend"); gc.GeometryFilter = ObjectType.Curve; gc.GeometryAttributeFilter = GeometryAttributeFilter.OpenCurve; gc.DisablePreSelect(); gc.Get(); if (gc.CommandResult() != Result.Success) { return(gc.CommandResult()); } var curve_obj_ref = gc.Object(0); var curve = curve_obj_ref.Curve(); if (curve == null) { return(Result.Failure); } double t; if (!curve.ClosestPoint(curve_obj_ref.SelectionPoint(), out t)) { return(Result.Failure); } var curve_end = t <= curve.Domain.Mid ? CurveEnd.Start : CurveEnd.End; var geometry = boundary_obj_refs.Select(obj => obj.Geometry()); var extended_curve = curve.Extend(curve_end, CurveExtensionStyle.Line, geometry); if (extended_curve != null && extended_curve.IsValid) { if (!doc.Objects.Replace(curve_obj_ref.ObjectId, extended_curve)) { return(Result.Failure); } doc.Views.Redraw(); } else { RhinoApp.WriteLine("No boundary object was intersected so curve not extended"); return(Result.Nothing); } return(Result.Success); }
protected override Result RunCommand(RhinoDoc doc, RunMode mode) { var go = new GetObject(); //GetObject is more general, and allows you to select any type of object. go.GeometryFilter = Rhino.DocObjects.ObjectType.Point; //user can only select points go.GetMultiple(1, 0); if (go.CommandResult() ! = Result.Success) { return(go.CommandResult()); } // if statement above is just a check to tell us what to do if the command is a success/failure var points = new List <Point>(go.ObjectCount); // now we have a list, we just have to save them. Let's use a different type of array using // the System.Collections namespace. The size of the array will be the size of the ObjectCount list. for (var i = 0; i < go.ObjectCount; i++) { var point = go.Object(i).Point(); if (null != point) { } } RhinoApp.WriteLine("The user selected {0} points successfully", points.Count.ToString()); return(Result.Success); }
/// <summary> /// This function selects breps /// </summary> /// /// public static bool XSelectBreps(string message, out RhinoList <Brep> breps) { breps = new RhinoList <Brep>(); int i; var gc = new GetObject(); gc.SetCommandPrompt("Select some Breps"); gc.EnablePreSelect(true, true); gc.GeometryFilter = Rhino.DocObjects.ObjectType.Brep; gc.GetMultiple(1, 0); //we do our double check to make sure the user selected something if (gc.CommandResult() != Result.Success) { return(false); } for (i = 0; i < gc.ObjectCount; i++) { var brep = gc.Object(i).Brep(); if (null != brep) { breps.Add(brep); } } return(true); }
public static GetObject GetRhinoObjects(string prompt, ObjectType geometryFilter) { GetObject go = new GetObject(); go.SetCommandPrompt(prompt); go.GeometryFilter = geometryFilter; go.GroupSelect = false; go.SubObjectSelect = false; go.EnableClearObjectsOnEntry(false); go.EnableUnselectObjectsOnExit(false); go.DeselectAllBeforePostSelect = false; bool bHavePreselectedObjects = true; for (; ;) { GetResult res = go.GetMultiple(1, 0); if (res == GetResult.Option) { go.EnablePreSelect(false, true); continue; } else if (res != GetResult.Object) { return(go); } if (go.ObjectsWerePreselected) { bHavePreselectedObjects = true; go.EnablePreSelect(false, true); continue; } break; } if (bHavePreselectedObjects) { // Normally, pre-selected objects will remain selected, when a // command finishes, and post-selected objects will be unselected. // This this way of picking, it is possible to have a combination // of pre-selected and post-selected. So, to make sure everything // "looks the same", lets unselect everything before finishing // the command. for (int i = 0; i < go.ObjectCount; i++) { RhinoObject rhinoObject = go.Object(i).Object(); if (null != rhinoObject) { rhinoObject.Select(false); } } } return(go); }
protected override Result RunCommand(RhinoDoc doc, RunMode mode) { var go = new GetObject(); go.SetCommandPrompt("Select curve"); go.GeometryFilter = ObjectType.Curve; go.Get(); if (go.CommandResult() != Result.Success) { return(go.CommandResult()); } var curve = go.Object(0).Curve(); if (null == curve) { return(Result.Failure); } // Get start and end point the easy way //RhinoApp.WriteLine("Start point = {0}", curve.PointAtStart); //RhinoApp.WriteLine("End point = {0}", curve.PointAtEnd); // Get start, mid, and end points double t; Point3d point; if (curve.NormalizedLengthParameter(0.0, out t)) { point = curve.PointAt(t); doc.Objects.AddPoint(point); if (curve.IsClosed) { RhinoApp.WriteLine("Start/End point = {0}", point); } else { RhinoApp.WriteLine("Start point = {0}", point); } } if (curve.NormalizedLengthParameter(0.5, out t)) { point = curve.PointAt(t); doc.Objects.AddPoint(point); RhinoApp.WriteLine("Mid point = {0}", point); } if (!curve.IsClosed && curve.NormalizedLengthParameter(1.0, out t)) { point = curve.PointAt(t); doc.Objects.AddPoint(point); RhinoApp.WriteLine("End point = {0}", point); } doc.Views.Redraw(); return(Result.Success); }
protected override Result RunCommand(RhinoDoc doc, RunMode mode) { RhinoApp.WriteLine("안녕하세요 방만드는기계 입니다."); // Polyline outline = new Polyline(); Polyline coreLine = new Polyline(); Polyline landing = new Polyline(); GetObject getPolyline = new GetObject(); getPolyline.SetCommandPrompt("외곽선,코어,랜딩 입력해주세요"); getPolyline.GeometryFilter = Rhino.DocObjects.ObjectType.Curve; getPolyline.GeometryAttributeFilter = GeometryAttributeFilter.ClosedCurve; getPolyline.SubObjectSelect = false; getPolyline.GetMultiple(3, 0); if (getPolyline.CommandResult() != Result.Success) { RhinoApp.WriteLine("달라고!"); return(getPolyline.CommandResult()); } else { RhinoApp.WriteLine("입력받았습니다."); } if (null == getPolyline.Object(0).Curve()) { RhinoApp.WriteLine("없잖아!"); return(getPolyline.CommandResult()); } List <Polyline> testPoly = new List <Polyline>(); foreach (var i in getPolyline.Objects()) { testPoly.Add(CurveTools.ToPolyline(i.Curve())); } outline = testPoly[0]; coreLine = testPoly[1]; landing = testPoly[2]; List <Polyline> rooms = Debugger.DebugRoom(outline, coreLine, landing); foreach (Polyline i in rooms) { doc.Objects.AddCurve(i.ToNurbsCurve()); } doc.Views.Redraw(); RhinoApp.WriteLine("최선을 다했습니다만..."); return(Result.Success); }
protected override Result RunCommand(RhinoDoc doc, RunMode mode) { GetObject go = new GetObject(); go.SetCommandPrompt("Select closed curve for seam adjustment"); go.GeometryFilter = ObjectType.Curve; go.GeometryAttributeFilter = GeometryAttributeFilter.ClosedCurve; go.SubObjectSelect = false; go.Get(); if (go.CommandResult() != Result.Success) { return(go.CommandResult()); } Curve curve = go.Object(0).Curve(); if (null == curve) { return(Result.Failure); } GetPoint gp = new GetPoint(); gp.SetCommandPrompt("New seam location"); gp.Constrain(curve, false); gp.Get(); if (gp.CommandResult() != Result.Success) { return(gp.CommandResult()); } Point3d point = gp.Point(); Curve new_curve = curve.DuplicateCurve(); double t = Rhino.RhinoMath.UnsetValue; if (new_curve.ClosestPoint(point, out t)) { if (new_curve.ChangeClosedCurveSeam(t)) { doc.Objects.Replace(go.Object(0), new_curve); } } return(Result.Success); }
protected override Result RunCommand(RhinoDoc doc, RunMode mode) { int i; CurveList selectedcurves = new CurveList(); int divnr = 10; Point3d[] divptarray; //declares variable as a standard array in .NET, for use with the out overload below. // step one, select curves -------------------------- var gc = new GetObject(); gc.SetCommandPrompt("Select curves to divide into 10 sections (start+end points added)"); gc.GeometryFilter = ObjectType.Curve; gc.GetMultiple(1, 0); if (gc.CommandResult() != Result.Success) { return(gc.CommandResult()); } //enter the loop for (i = 0; i < gc.ObjectCount; i++) { var curve = gc.Object(i).Curve(); if (null != curve && !curve.IsShort(RhinoMath.ZeroTolerance)) { selectedcurves.Add(curve); } // ADD THE CURVE TO THE CURVES LIST, expanding dynamically through the loop } if (selectedcurves.Count < 1) { return(Result.Failure); } //step 2, divide curves ---------------------------------- for (i = 0; i < selectedcurves.Count; i++) { double[] parameters = selectedcurves[i].DivideByCount(divnr, true, out divptarray); UsefulFunctions.XDrawPoints(divptarray, doc); UsefulFunctions.XDrawCurveTangents(parameters, selectedcurves[i], doc); } return(Result.Success); }
protected override Result RunCommand(RhinoDoc doc, RunMode mode) { // TODO: complete command. MyRhino5rs11project8PlugIn p = MyRhino5rs11project8PlugIn.Instance; if (p.if_painted_object_set_ == false) { RhinoApp.WriteLine("No mesh"); return(Result.Failure); } Mesh my_mesh = p.painted_object_; DijkstraGraph my_graph = p.graph; GetObject gcurve = new GetObject(); gcurve.SetCommandPrompt("Get nurbscurve"); gcurve.GeometryFilter = Rhino.DocObjects.ObjectType.Curve; gcurve.SubObjectSelect = false; gcurve.Get(); if (gcurve.CommandResult() != Result.Success) { return(gcurve.CommandResult()); } ObjRef curve_objref = gcurve.Object(0); RhinoObject curve_obj = curve_objref.Object(); Curve selected_curve = curve_objref.Curve(); NurbsCurve nurbs_curve = selected_curve.ToNurbsCurve(); Guid path_id = selected_curve.UserDictionary.GetGuid("PathID"); IEnumerable <RhinoObject> path_objref = doc.Objects.GetObjectList(ObjectType.Curve); foreach (RhinoObject path in path_objref) { doc.Objects.Delete(path, true); } List <NurbsCurve> new_path_list = new List <NurbsCurve>(); new_path_list = my_graph.DijkstraPath_DeletePath(path_id); ObjectAttributes my_attributes = new ObjectAttributes(); my_attributes.ObjectColor = Color.Yellow; my_attributes.ColorSource = ObjectColorSource.ColorFromObject; my_attributes.PlotWeightSource = ObjectPlotWeightSource.PlotWeightFromObject; my_attributes.PlotWeight = 2.0; //doc.Objects.Delete(my_objref1, true); for (int i = 0; i < new_path_list.Count; i++) { Guid PathID = new_path_list[i].UserDictionary.GetGuid("PathID"); my_attributes.ObjectId = PathID; doc.Objects.Add(new_path_list[i], my_attributes); } doc.Views.Redraw(); return(Result.Success); }
protected override Result RunCommand(RhinoDoc doc, RunMode mode) { var go = new GetObject(); go.SetCommandPrompt("Select holes"); go.GeometryFilter = ObjectType.BrepLoop; go.GeometryAttributeFilter = GeometryAttributeFilter.InnerLoop; go.GetMultiple(1, 0); if (go.CommandResult() == Result.Success) { for (var i = 0; i < go.ObjectCount; i++) { var obj_ref = go.Object(i); var ci = obj_ref.GeometryComponentIndex; if (ci.ComponentIndexType != ComponentIndexType.BrepLoop) { return(Result.Failure); } var brep = obj_ref.Brep(); if (null == brep) { return(Result.Failure); } var loop = brep.Loops[ci.Index]; if (null == loop) { return(Result.Failure); } for (var lti = 0; lti < loop.Trims.Count; lti++) { var ti = loop.Trims[lti].TrimIndex; var trim = brep.Trims[ti]; if (null != trim) { var edge = brep.Edges[trim.Edge.EdgeIndex]; if (null != edge) { // TODO: do somethign with edge curve. // In this case, we'll just add a copy to the document. var curve = edge.DuplicateCurve(); if (null != curve) { doc.Objects.AddCurve(curve); } } } } } } doc.Views.Redraw(); return(Result.Success); }