for example, if i select a point (pt_a) on line2/curve2, i should get a perpendicular point (pt_b) which is perpendicular to pt_a lying on line1/curve1.
if there is no perpendicular point, then the point that is nearer to perpendicular should be chosen
Can you suggest me, if there is any function in python that can achieve my task, or can you suggest me procedure i can follow to achieve this task
(the line back from the closest point to the base curve is generally also perpendicular to the base curve except where the test object does not have a possible perpendicular, then it is the nearest point)
import rhinoscriptsyntax as rs
id = rs.GetObject("Select a curve")
if id:
point = rs.GetPoint("Pick a test point")
if point:
param = rs.CurveClosestPoint(id, point)
closestPt = rs.EvaluateCurve(id, param)
rs.AddPoint(closestPt)
import rhinoscriptsyntax as rs
import Rhino.Geometry as rg
crvA = rs.GetObject("Select a curve")
point =rs.GetPointOnCurve(crvA, "Pick a test point")
param = rs.CurveClosestPoint(crvA, point)
PtA = rs.EvaluateCurve(crvA, param)
tanVec = rs.CurveTangent(crvA, param)
norVec = rs.VectorCrossProduct(tanVec, rs.CurveNormal(crvA))
crvB = rs.GetObject("Select a curve")
result = rg.Intersect.Intersection.CurveLine(rs.coercecurve(crvB), rg.Line(PtA,norVec+PtA),0.1,0.1)
for pt in result:
rs.AddPoint(pt.PointA)