Hi,
I am attempting to select points on a surface with a maximum distance between the grips of 200’. I have been able to write the following script, but what I really want to do is, after the first grip selection, have a red line appear to a maximum arc of 200’ and then be able to select the second grip within this arc. Does anyone know how to do this? I am a bit of a newb so please bear with me
from Rhino.RhinoDoc import ActiveDoc as rhdoc
import Rhino
import scriptcontext as sc
import rhinoscriptsyntax as rs
import Rhino.Geometry as rg
sc.doc = rhdoc
srfs = rs.GetObjects("Select surfaces to edit", 8, True)
# Turn on grips
for srf in srfs:
rs.EnableObjectGrips(srf, True)
# Maximum distance for the second grip
max_distance = 200
# Select the first grip
grip1 = rs.GetObjectGrip("Select the first grip")
# Get the location of the first grip
point1 = grip1[2]
# Create a sphere centered at the location of the first grip with the maximum distance as the radius
sphere = rg.Sphere(point1, max_distance)
# Select the second grip within the maximum distance
grip2 = rs.GetObjectGrip("Select the second grip within " + str(max_distance) + " feet of the first grip", preselect=True, select=True)
# Get the location of the second grip
point2 = grip2[2]
# Calculate the distance between the two grips
distance = point1.DistanceTo(point2)
# Check if the distance is less than or equal to the maximum distance
if distance <= max_distance:
# Output the locations of the two grips
outputx1 = point1.X
outputy1 = point1.Y
outputz1 = point1.Z
outputx2 = point2.X
outputy2 = point2.Y
outputz2 = point2.Z
else:
# Display an error message
rs.MessageBox("The second grip is too far away from the first grip. Please select a grip within " + str(max_distance) + " feet of the first grip.", 0, "Error")
# Set the outputs to None
outputx1 = None
outputy1 = None
outputz1 = None
outputx2 = None
outputy2 = None
outputz2 = None
# Output the results to the component
OUT = outputx1, outputy1, outputz1, outputx2, outputy2, outputz2
sc.doc = ghdoc