Draw a perpendicular line to a point on the curve

Hi,
Greetings

I want to draw a perpendicular line of desired distance (input from the user) to a point which is on the curve.

Desired Output:
image

Can someone help me on how to achieve this task, is there any rhino python function to do this?,

I have also attached .stp file for reference.

Thanks in Advance

draw perpendicular line to point.stp (9.7 KB)

Start the line at the point and move perpendicular the desired distance.
One method using the mouse with Point Osnap:
Line command
Start of line select Perpendicular option
Start of line select Point on curve option
Select curve click on the curve
Start of line select the point
Type the desired length
Move the cursor to the desired side of the curve
Enter

I’m curious why you uploaded a .stp file rather than a .3dm file?

If you’re looking for a solution that works in python:

import rhinoscriptsyntax as rs
curve = rs.GetCurveObject("Pick a curve")[0]
point = rs.GetPointOnCurve(curve, "Point on curve")
length = rs.GetReal("Enter line length")
t = rs.CurveClosestPoint(curve, point)
plane = rs.CurveFrame(curve, t)
rs.AddLine(point, point + plane.YAxis * length)

Sumukha.py (293 Bytes)

1 Like

Hi @Mahdiyar,
Thanks for the replay,
I have a doubt, how to control the direction of the line, because some times its inside and sometimes its outside, can we have an option where user can choose in which direction the line should appear

Thanks in advance

import rhinoscriptsyntax as rs
curve = rs.GetCurveObject("Pick a curve")[0]
point = rs.GetPointOnCurve(curve, "Point on curve")
length = rs.GetReal("Enter line length", 1)
t = rs.CurveClosestPoint(curve, point)
planeNormal =rs.CurveNormal(curve)
tangent = rs.CurveTangent(curve, t)
curveNormal = rs.VectorCrossProduct(planeNormal, tangent)
rs.AddLine(point, point + curveNormal * length)

Sumukha.py (395 Bytes)

3 Likes

Thanks a lot @Mahdiyar