@kyle_faulkner wrote:
I’m playing around with the script posted in the forum here and I am trying to add a command line option.
When running the script, changing an option triggers the GetPoint event, even though I don’t select a point with a mouse click. Also, the resulting point is always this:
-1.23432101234321E+308,-1.23432101234321E+308,-1.23432101234321E+308
Is there a way to prevent this from happening? Maybe I have something out of order.
import Rhino import scriptcontext import rhinoscriptsyntax as rs from System.Drawing import Color def DoSomething(): radius = 5 optionRad = Rhino.Input.Custom.OptionDouble(radius, True, 0.5) mesh_id = rs.GetObject("Select mesh", 32, True, False) if not mesh_id: return mesh = rs.coercemesh(mesh_id, True) plane = Rhino.Geometry.Plane.WorldXY tolerance = scriptcontext.doc.ModelAbsoluteTolerance radius = 4.0 gp = Rhino.Input.Custom.GetPoint() gp.Constrain(mesh, False) gp.Tag = None gp.SetCommandPrompt("Point on mesh") gp.AddOptionDouble("Radius", optionRad) radius = optionRad.CurrentValue def GetPointDynamicDrawFunc(sender, args): plane.Origin = args.CurrentPoint circle = Rhino.Geometry.Circle(plane, radius) curve = circle.ToNurbsCurve() rc = Rhino.Geometry.Curve.ProjectToMesh(curve, mesh, plane.ZAxis, tolerance) if rc.Count != 0: args.Display.DrawCurve(rc[0], Color.Red, 3) sender.Tag = rc[0] gp.DynamicDraw += GetPointDynamicDrawFunc getres = gp.Get() if gp.CommandResult() != Rhino.Commands.Result.Success: return None if gp.Tag: crv_id = scriptcontext.doc.Objects.AddCurve(gp.Tag) rs.SelectObject(crv_id) gp.Dispose() if __name__=="__main__": DoSomething()
Posts: 2
Participants: 2