// Rh Capture? public static Rhino.Geometry.Point ToNative(this SpecklePoint pt) { var myPoint = new Rhino.Geometry.Point(new Point3d(pt.Value[0], pt.Value[1], pt.Value[2])); myPoint.UserDictionary.ReplaceContentsWith(pt.Properties.ToNative()); return(myPoint); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { //Crv1 is Base Curve; //Crv2 is Dest Curve; this.ExpirePreview(true); if (Pt1 != null || Pt2 != null) { Pt1 = null; Pt2 = null; } Curve Crv1 = default(Curve), Crv2 = default(Curve); int Precise = 10000; double Param1 = 0, Param2 = 0, TempParam2 = 0, Distance = 0; if (!DA.GetData(0, ref Crv1)) { return; } if (!DA.GetData(1, ref Crv2)) { return; } if (!DA.GetData(2, ref Precise)) { return; } const int MIN = 10; const int MAX = 1000000; Crv1 = this.RebuildCurve(Crv1); Crv2 = this.RebuildCurve(Crv2); if (Precise < MIN || Precise > MAX) { Precise = 10000; } double InCrement = 1.0 / Precise; for (double i = 0; i < 1; i += InCrement) { Point3d Pt1 = Crv1.PointAt(i); Crv2.ClosestPoint(Pt1, out TempParam2); double d = Crv2.PointAt(TempParam2).DistanceTo(Pt1); if (Distance <= d) { Distance = d; Param1 = i; Param2 = TempParam2; } } Pt1 = new Rhino.Geometry.Point(Crv1.PointAt(Param1)); Pt2 = new Rhino.Geometry.Point(Crv2.PointAt(Param2)); DA.SetData(0, Param1); DA.SetData(1, Param2); DA.SetData(2, Distance); }
/// <summary> /// The timer used to defer replacement processing operations /// </summary> //private Timer _ObjectReplacedWaitTimer = null; private void ProcessObjectReplacedWaitingList(object sender, EventArgs args) { if (_ReplacedElements.Count > 0 || _ReplacedNodesWaitingList.Count > 0) { foreach (KeyValuePair <Node, RhinoReplaceObjectEventArgs> kvp in _ReplacedNodesWaitingList) { Node node = kvp.Key; RC.GeometryBase geometry = kvp.Value.NewRhinoObject.Geometry; if (geometry is RC.Point) { RC.Point rPt = (RC.Point)geometry; Vector pos = FromRC.Convert(rPt.Location); node.MoveTo(pos, true, _ReplacedElements); } } _ReplacedElements.GenerateNodes(new NodeGenerationParameters()); _ReplacedElements.Clear(); _ReplacedNodesWaitingList.Clear(); //_ObjectReplacedWaitTimer.Stop(); Core.Instance.Host.Refresh(); } }
/***************************************************/ public static BHG.Point FromRhino(this RHG.Point rhinoPoint) { if (rhinoPoint == null) { return(null); } return(new BHG.Point { X = rhinoPoint.Location.X, Y = rhinoPoint.Location.Y, Z = rhinoPoint.Location.Z }); }
public List <Point3d> GetRoadPoints() { ButtonStateCheck(ButtonState.None); RhinoApp.SendKeystrokes("Cancel", true); RhinoApp.Wait(); bool newPoint = true; List <Point3d> newpoints = new List <Point3d>(); List <Rhino.DocObjects.PointObject> newpointobjects = new List <Rhino.DocObjects.PointObject>(); while (newPoint) { newPoint = RhinoApp.RunScript("Point", false); var guid = RhinoDoc.ActiveDoc.Objects.ElementAt(0).Id; Rhino.DocObjects.PointObject pointobject = RhinoDoc.ActiveDoc.Objects.Find(guid) as Rhino.DocObjects.PointObject; newpointobjects.Add(pointobject); Rhino.Geometry.Point point = pointobject.PointGeometry; Point3d point3d = point.Location; newpoints.Add(point3d); if (!newPoint) { var result = MessageBox.Show("Yes = 끝내기 No = 이전 취소 Cancle = 취소", "도로 선택 완료", MessageBoxButton.YesNoCancel); if (result == MessageBoxResult.Cancel) { foreach (var pobj in newpointobjects) { Rhino.RhinoDoc.ActiveDoc.Objects.Delete(pobj, true); } Rhino.RhinoDoc.ActiveDoc.Views.Redraw(); } else if (result == MessageBoxResult.No) { var lastguid = RhinoDoc.ActiveDoc.Objects.ElementAt(0).Id; RhinoDoc.ActiveDoc.Objects.Delete(lastguid, true); Rhino.RhinoDoc.ActiveDoc.Views.Redraw(); newPoint = true; } } ////show/hide작업 } return(newpoints); }
/// <summary> /// Convert a Rhino point object to a Nucleus one /// </summary> /// <param name="point"></param> /// <returns></returns> public static Point Convert(RC.Point point) { if (point.IsValid) { return(new Point(Convert(point.Location))); } else { return(null); } }
private bool disposedValue = false; // To detect redundant calls protected virtual void Dispose(bool disposing) { if (!disposedValue) { if (disposing) { Pt1 = null; Pt2 = null; Dispose(true); } disposedValue = true; } }
public override BoundingBox GetBoundingBox(Rhino.Geometry.Transform xform) { if (Value == null) { return(BoundingBox.Empty); } bool IsIdentity = xform == Rhino.Geometry.Transform.Identity; var point = new Rhino.Geometry.Point(Value.Coord.ToRhino()); point.Scale(Revit.ModelUnits); var bbox = IsIdentity ? point.GetBoundingBox(true) : point.GetBoundingBox(xform); return(bbox); }
public Result RunCommand(RhinoDoc doc) { //選擇多點 var rc = RhinoGet.GetMultipleObjects("Select point", false, ObjectType.Point, out obj_refs); if (rc != Result.Success) { return(rc); } foreach (var o_ref in obj_refs) { point = o_ref.Point(); RhinoApp.WriteLine("Point: x:{0}, y:{1}, z:{2}", point.Location.X, point.Location.Y, point.Location.Z); } return(Result.Success); }
static internal Autodesk.Revit.DB.Point ToHost(this Rhino.Geometry.Point point) { return(Autodesk.Revit.DB.Point.Create(ToHost(point.Location))); }
public static Rhino.Commands.Result ExplodeHatch(Rhino.RhinoDoc doc) { const ObjectType filter = Rhino.DocObjects.ObjectType.Hatch; Rhino.DocObjects.ObjRef objref; Rhino.Commands.Result rc = Rhino.Input.RhinoGet.GetOneObject("Select hatch to explode", false, filter, out objref); if (rc != Rhino.Commands.Result.Success || objref == null) { return(rc); } Rhino.Geometry.Hatch hatch = objref.Geometry() as Rhino.Geometry.Hatch; if (null == hatch) { return(Rhino.Commands.Result.Failure); } Rhino.Geometry.GeometryBase[] hatch_geom = hatch.Explode(); if (null != hatch_geom) { for (int i = 0; i < hatch_geom.Length; i++) { Rhino.Geometry.GeometryBase geom = hatch_geom[i]; if (null != geom) { switch (geom.ObjectType) { case Rhino.DocObjects.ObjectType.Point: { Rhino.Geometry.Point point = geom as Rhino.Geometry.Point; if (null != point) { doc.Objects.AddPoint(point.Location); } } break; case Rhino.DocObjects.ObjectType.Curve: { Rhino.Geometry.Curve curve = geom as Rhino.Geometry.Curve; if (null != curve) { doc.Objects.AddCurve(curve); } } break; case Rhino.DocObjects.ObjectType.Brep: { Rhino.Geometry.Brep brep = geom as Rhino.Geometry.Brep; if (null != brep) { doc.Objects.AddBrep(brep); } } break; } } } } return(Rhino.Commands.Result.Success); }
static internal IEnumerable <Autodesk.Revit.DB.Point> ToHost(this Rhino.Geometry.Point point) { yield return(Autodesk.Revit.DB.Point.Create(ToHost(point.Location))); }
public Rhino.Geometry.Point DuplicatePointGeometry() { Rhino.Geometry.Point rc = DuplicateGeometry() as Rhino.Geometry.Point; return(rc); }
public ObjectPrimitive(Rhino.DocObjects.RhinoObject o, Rhino.Geometry.Point p) : base(p) { rhinoObject = o; }
private void setoutPutData(int i3, string p, IGH_DataAccess DA) { //Rhino.Geometry.NurbsSurface.CreateFromCorners() //Line input if (matchLine.Match(p).Value != "") { if (p.Contains(@")', 'gCPy.Line(")) { p = p.Replace("'gCPy.Line(", "'(").Replace("'", "").Replace("[", "").Replace("]", "").Replace("(", "").Replace("),", "#").Replace(")", ""); string[] lines = p.Split('#'); List <Rhino.Geometry.Line> lns = new List <Rhino.Geometry.Line>(); for (int i = 0; i < lines.Length; i++) { var thisL = lines[i].Split(','); Rhino.Geometry.Line lx = new Rhino.Geometry.Line(double.Parse(thisL[0].Trim()), double.Parse(thisL[1].Trim()), double.Parse(thisL[2].Trim()), double.Parse(thisL[3].Trim()), double.Parse(thisL[4].Trim()), double.Parse(thisL[5].Trim())); lns.Add(lx); } DA.SetDataList(i3, lns); } // Single Point input else { var numbers = matchLine.Match(p).Value.Split(','); Line lx = new Line(double.Parse(numbers[0]), double.Parse(numbers[1]), double.Parse(numbers[2]), double.Parse(numbers[3]), double.Parse(numbers[4]), double.Parse(numbers[5])); DA.SetData(i3, lx); } } //Point input else if (matchPoint.Match(p).Value != "") { // Point List input if (p.Contains(@")', 'gCPy.Point(")) { p = p.Replace("'gCPy.Point(", "'(").Replace("'", "").Replace("[", "").Replace("]", "").Replace("(", "").Replace("),", "#").Replace(")", ""); string[] points = p.Split('#'); List <Rhino.Geometry.Point3d> pts = new List <Rhino.Geometry.Point3d>(); for (int i = 0; i < points.Length; i++) { var thisP = points[i].Split(','); Rhino.Geometry.Point3d px = new Rhino.Geometry.Point3d(new Point3d(double.Parse(thisP[0].Trim()), double.Parse(thisP[1].Trim()), double.Parse(thisP[2].Trim()))); pts.Add(px); } DA.SetDataList(i3, pts); } // Single Point input else { var numbers = matchPoint.Match(p).Value.Split(','); Rhino.Geometry.Point px = new Rhino.Geometry.Point(new Point3d(double.Parse(numbers[0]), double.Parse(numbers[1]), double.Parse(numbers[2]))); DA.SetData(i3, px); } } else if (matchCircle.Match(p).Value != "") { var numbers = matchCircle.Match(p).Value.Split(','); Rhino.Geometry.Plane pl = new Plane(new Point3d(double.Parse(numbers[0]), double.Parse(numbers[1]), double.Parse(numbers[2])), new Vector3d(double.Parse(numbers[4]), double.Parse(numbers[5]), double.Parse(numbers[6])), new Vector3d(double.Parse(numbers[7]), double.Parse(numbers[8]), double.Parse(numbers[9]))); Rhino.Geometry.Circle cx = new Rhino.Geometry.Circle(pl, double.Parse(numbers[3])); DA.SetData(i3, cx); } else if (matchSurface.Match(p).Value != "") { var numbers = matchSurface.Match(p).Value.Split(','); NurbsSurface srf = NurbsSurface.CreateFromCorners(new Point3d(double.Parse(numbers[0]), double.Parse(numbers[1]), double.Parse(numbers[2])), new Point3d(double.Parse(numbers[3]), double.Parse(numbers[4]), double.Parse(numbers[5])), new Point3d(double.Parse(numbers[6]), double.Parse(numbers[7]), double.Parse(numbers[8])), new Point3d(double.Parse(numbers[9]), double.Parse(numbers[10]), double.Parse(numbers[11]))); DA.SetData(i3, srf); } else { DA.SetData(i3, p); } }
public void Dispose() { Pt1 = null; Pt2 = null; Dispose(true); }
public static Rhino.Commands.Result UnrollSurface(Rhino.RhinoDoc doc) { const ObjectType filter = Rhino.DocObjects.ObjectType.Brep | Rhino.DocObjects.ObjectType.Surface; Rhino.DocObjects.ObjRef objref; Result rc = Rhino.Input.RhinoGet.GetOneObject("Select surface or brep to unroll", false, filter, out objref); if (rc != Rhino.Commands.Result.Success) { return(rc); } Rhino.Geometry.Unroller unroll = null; Rhino.Geometry.Brep brep = objref.Brep(); if (brep != null) { unroll = new Rhino.Geometry.Unroller(brep); } else { Rhino.Geometry.Surface srf = objref.Surface(); if (srf != null) { unroll = new Rhino.Geometry.Unroller(srf); } } if (unroll == null) { return(Rhino.Commands.Result.Cancel); } unroll.AbsoluteTolerance = 0.01; unroll.RelativeTolerance = 0.01; Rhino.Input.Custom.GetObject go = new Rhino.Input.Custom.GetObject(); go.SetCommandPrompt("Select points, curves, and dots to unroll with surface"); go.GeometryFilter = Rhino.DocObjects.ObjectType.Point | Rhino.DocObjects.ObjectType.Curve | Rhino.DocObjects.ObjectType.TextDot; go.AcceptNothing(true); go.GetMultiple(0, 0); if (go.CommandResult() != Rhino.Commands.Result.Success) { return(go.CommandResult()); } for (int i = 0; i < go.ObjectCount; i++) { objref = go.Object(i); Rhino.Geometry.GeometryBase g = objref.Geometry(); Rhino.Geometry.Point pt = g as Rhino.Geometry.Point; Rhino.Geometry.Curve crv = g as Rhino.Geometry.Curve; Rhino.Geometry.TextDot dot = g as Rhino.Geometry.TextDot; if (pt != null) { unroll.AddFollowingGeometry(pt.Location); } else if (crv != null) { unroll.AddFollowingGeometry(crv); } else if (dot != null) { unroll.AddFollowingGeometry(dot); } } unroll.ExplodeOutput = false; Rhino.Geometry.Curve[] curves; Rhino.Geometry.Point3d[] points; Rhino.Geometry.TextDot[] dots; Rhino.Geometry.Brep[] breps = unroll.PerformUnroll(out curves, out points, out dots); if (breps == null || breps.Length < 1) { return(Rhino.Commands.Result.Failure); } for (int i = 0; i < breps.Length; i++) { doc.Objects.AddBrep(breps[i]); } for (int i = 0; i < curves.Length; i++) { doc.Objects.AddCurve(curves[i]); } doc.Objects.AddPoints(points); for (int i = 0; i < dots.Length; i++) { doc.Objects.AddTextDot(dots[i]); } doc.Views.Redraw(); return(Rhino.Commands.Result.Success); }
private void HandlesAddRhinoObject(object sender, RhinoObjectEventArgs e) { if (!RhinoOutput.Writing && !_Replacing) { if (e.TheObject.Attributes.HasUserData) { string data = e.TheObject.Attributes.GetUserString("SAL_ORIGINAL"); if (!string.IsNullOrEmpty(data) && data != e.ObjectId.ToString()) { Guid storedGuid = new Guid(data); if (this.Links.ContainsSecond(storedGuid)) { ModelObject mO = LinkedModelObject(storedGuid); //Create copy of object: if (mO is Element) { VertexGeometry geometry = FromRC.Convert(e.TheObject.Geometry); Element element = null; if (mO is LinearElement) { LinearElement lElement = ((LinearElement)mO).Duplicate();//Core.Instance.ActiveDocument?.Model?.Create.CopyOf((Element)mO, geometry); bool split = false; if (geometry is Curve) { Curve newCrv = (Curve)geometry; if (lElement.Geometry != null) { Curve oldCrv = lElement.Geometry; if (newCrv.Length < oldCrv.Length) { //TODO: Check end point distance to curve double maxDist = 0; foreach (Vertex v in newCrv.Vertices) { double dist = oldCrv.DistanceToSquared(v.Position); if (dist > maxDist) { maxDist = dist; } } if (maxDist < Tolerance.Distance) { split = true; } } } lElement.ReplaceGeometry(newCrv, split); } lElement.GenerateNodes(new NodeGenerationParameters()); element = lElement; } if (mO is PanelElement) { PanelElement pElement = ((PanelElement)mO).Duplicate();//Core.Instance.ActiveDocument?.Model?.Create.CopyOf((Element)mO, geometry); if (geometry is Surface) { pElement.ReplaceGeometry((Surface)geometry); } element = pElement; } RhinoOutput.SetOriginalIDUserString(e.ObjectId); if (element != null) { Links.Set(element.GUID, e.ObjectId); Core.Instance.ActiveDocument.Model.Add(element); } } else if (mO is Node) { if (e.TheObject.Geometry is RC.Point) { Node node = ((Node)mO).Duplicate(); RC.Point pt = (RC.Point)e.TheObject.Geometry; node.Position = FromRC.Convert(pt).Position; RhinoOutput.SetOriginalIDUserString(e.ObjectId); Links.Set(node.GUID, e.ObjectId); Core.Instance.ActiveDocument.Model.Add(node); } } } } } } }
public static SpecklePoint ToSpeckle(this Rhino.Geometry.Point pt) { return(new SpecklePoint(pt.Location.X, pt.Location.Y, pt.Location.Z, properties: pt.UserDictionary.Count != 0 ? pt.UserDictionary.ToSpeckle(root: pt) : null)); }
public static NXOpen.Point ToHost(Point value) { return(value.ToPoint()); }