I want finde the selected point to know if it´s near start or end.
I have this in Python but I want changed to c#
my Python code =>
def select():
scriptcontext.doc.Objects.UnselectAll()
getterc = GetObject()
try:
getterc.SetCommandPrompt("Please select Purlin on Start or end")
if getterc.Get() == GetResult.Object: #we wait for the result here
objref = getterc.Object(0)
id = objref.ObjectId
point = objref.SelectionPoint()
point = rs.AddPoint(point)
finally:
getterc.Dispose() #this will be called in all cases
scriptcontext.doc.Objects.UnselectAll()
return id, point
This is an example to create a line. But it gets 2 points
Exactly what you are searching for.
Rhino.Input.Custom.GetPoint gp = new Rhino.Input.Custom.GetPoint();
gp.SetCommandPrompt("Start of line");
gp.Get();
if (gp.CommandResult() != Rhino.Commands.Result.Success)
return gp.CommandResult();
Rhino.Geometry.Point3d pt_start = gp.Point();
//to add a point and get its guid.
Guid pointGuid = doc.objects.addpoint(pt_start)
It’s in vb.NET but I think you can easily translate it:
Private Function GetSrf()
Dim pt0 As Point3d
Using getPointAction As New GetPoint()
getPointAction.SetCommandPrompt("Please select point position")
If getPointAction.[Get]() <> GetResult.Point Then
RhinoApp.WriteLine("No point was selected.")
Return getPointAction.CommandResult()
End If
pt0 = getPointAction.Point()
End Using
Dim go As GetObject = New GetObject()
go.SetCommandPrompt("Select PolySrf")
go.SubObjectSelect = False
go.GroupSelect = False
go.GeometryFilter = Rhino.DocObjects.ObjectType.Brep
go.AcceptNothing(True)
If go.Get <> GetResult.Object Then
Return Result.Failure
End If
Dim surf_id As Guid = go.Object(0).ObjectId
RhinoApp.WriteLine("point {0} ", pt0)
RhinoApp.WriteLine("guid {0} ", surf_id)
Return surf_id
End Function