How to use control key when get point

Hi;
Press the control key will lock the cursor when I use the customgetpoint function, I want to change the color of point when I press control key and get the point, it is way to solve it?

PS:
I push my core now, this core have somg problem, when I press the control key and pick point, the point have not delete, but it is not important, the important thing is affter this, the cursor have lock.

import Rhino
import rhinoscriptsyntax as rs
import scriptcontext as sc
import System.Drawing.Color

def GetPointAndDelete(points,ids):
  global poi
  while True:
    def GetPointDynamicDrawFunc( sender, args ): 
      current_point = args.CurrentPoint
      for i in range(len(ids)):
        if current_point.DistanceTo(points[i])<1:
          poi=ids[i]
          args.Display.DrawLine(points[i], current_point, System.Drawing.Color.Red,3)
    def GetPointMouseEventArgs( sender, args ):
      if args.ControlKeyDown:
        sc.doc.Objects.Delete(poi)
    gp = Rhino.Input.Custom.GetPoint()
    gp.DynamicDraw += GetPointDynamicDrawFunc
    gp.MouseDown += GetPointMouseEventArgs
    gp.Get(True)
    if( gp.CommandResult() != Rhino.Commands.Result.Success ):
      return
    else:
      continue


pois = rs.GetObjects("get points")
points =[]
for i in range(len(pois)):
  point = rs.coerce3dpoint(pois[i])
  points.append(point)
GetPointAndDelete(points,pois)

@pythonuser,

i am not 100% sure i understand what you’re after but if you use CTRL in a GetPoint prompt it will lock the point picking in elevator mode and ask for a second point along the elevation line by default.

You can disable elevator mode by using:

gp.PermitElevator(0)

according to the help. To delete a point object with your script above using CTRL, i’ve changed it slightly. If the point is clicked without CTRL down, no delete happens.

import Rhino
import rhinoscriptsyntax as rs
import scriptcontext as sc
import System.Drawing.Color

def GetPointAndDelete(points,ids):
  global poi
  while True:
    def GetPointDynamicDrawFunc( sender, args ): 
      current_point = args.CurrentPoint
      for i in range(len(ids)):
        if current_point.DistanceTo(points[i])<1:
          poi=ids[i]
          args.Display.DrawLine(points[i], current_point, System.Drawing.Color.Red,3)
          sender.Tag = poi
    def GetPointMouseEventArgs( sender, args ):
      if args.ControlKeyDown:
          pass
      else:
        sender.Tag = None

    gp = Rhino.Input.Custom.GetPoint()
    gp.DynamicDraw += GetPointDynamicDrawFunc
    gp.MouseDown += GetPointMouseEventArgs
    gp.PermitElevatorMode(0)
    gp.Tag = None
    gp.Get(True)
    if( gp.CommandResult() != Rhino.Commands.Result.Success ):
      return
    else:
      if gp.Tag: rs.DeleteObject(gp.Tag)
      continue

pois = rs.GetObjects("get points")
points =[]
for i in range(len(pois)):
  point = rs.coerce3dpoint(pois[i])
  points.append(point)
GetPointAndDelete(points,pois)

c.

1 Like

Thonk you@clement.
Yes, it will lock, I means I do not want it lock, I will try your core affter het off work.

Think you @clement, I have try your core, that is it, it work good.