GetPoint result on option change

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:


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)


if __name__=="__main__":

Hi @kyle_faulkner,

When adding command options, you will want to call Get() inside of a while loop. This way, you you can check for option and take the appropriate action. Then call Get() again.

import Rhino
import scriptcontext as sc

def Test():
    toggle_val = False
    toggle_opt = Rhino.Input.Custom.OptionToggle(toggle_val, "False", "True")

    gp = Rhino.Input.Custom.GetPoint()
    gp.SetCommandPrompt("Pick a point")

    while True:
        gp.AddOptionToggle("Add", toggle_opt)
        res = gp.Get()
        if res == Rhino.Input.GetResult.Option:
            toggle_val = toggle_opt.CurrentValue
        if res != Rhino.Input.GetResult.Point:
    if toggle_val:

– Dale

Thank you. This was greatly helpful. The check for whether or not an option change was made is a great piece that i think will be helpful for some of my other scripts