What script function to select a group of points by point cloud or mouse click & drag

Hi, I just started Python and am using this script that draws circles around points.

points = rs.GetPoints(“Pick points”)
radius = rs.GetInteger(“What’s the radius?”)

for point in points:
rs.AddCircle(point, radius)

However, I’d like it to allow me to select the points either by point cloud or by grouping using the mouse click & drag function. Currently, the script requires me to select these points individually by mouse click. Any help would be much appreciated.

Try:

import rhinoscriptsyntax as rs

points=rs.GetObjects("Pick points",1,preselect=True)
#points is a list of Rhino point objects
if points:
    rad=rs.GetReal("Radius?",minimum=0)
    if rad:
        #create a list of 3d points
        pts=[]
        for point in points:
            pts.append(rs.coerce3dpoint(point))
        rs.EnableRedraw(False)
        #add circles
        for pt in pts:
            rs.AddCircle(pt,rad)

You can compact the code a bit, but it’s a bit less readable/understandable:

import rhinoscriptsyntax as rs

points=rs.GetObjects("Pick points",1,preselect=True)
if points:
    rad=rs.GetReal("Radius?",minimum=0)
    if rad:
        rs.EnableRedraw(False)
        for point in points:
            rs.AddCircle(rs.coerce3dpoint(point),rad)
1 Like

Thanks Mitch, it’s much appreciated and for offering the compact version too.