Divide curve Python

Hi forum,

I would like to ask for help. I’m working on small script and I would like to create geometry as shown in picture number 2. Im stuck projecting points to bottom curve (as shown with blue). I think if i get bottom points, ill be able to create vertical lines (for loop). Can someone please point me right direction?

Thank you,
Dan

Tie rod.gh (5.1 KB)

I think this can just be done in Grasshopper. Use perpendicular frames, intersect with bottom curve then connect up the intersection with the original points with lines.

Curve connections.gh (7.9 KB)

Hope this help:

import rhinoscriptsyntax as rs
def vzpinadlo(start, end, height, segments):
    top_ch_pt = rs.DivideCurve(rs.AddLine(start, end),segments,True,True)
    top_ch = rs.ExplodeCurves(rs.AddPolyline(top_ch_pt))
    line = rs.AddLine(start, end)
    mid_pt = rs.DivideCurve(line , 2, True, True)
    mid_pt = rs.MoveObject(mid_pt[1], [0,0,-height])
    curve_pt = (start, mid_pt, end)
    curve = rs.AddCurve(curve_pt, degree=3)
    bot_ch = []
    for pt in top_ch_pt:
        plane = rs.CurvePerpFrame(line, rs.CurveClosestPoint(line, pt))
        intersections = rs.PlaneCurveIntersection(plane, curve)
        if intersections:
            for intersection in intersections:
                bot_ch.append(intersection[1])
    return top_ch, bot_ch, top_ch_pt, curve

top_ch, bot_ch, top_ch_pt, curve = vzpinadlo(start, end, height, segments)

Tie rod.gh (15.5 KB)

2 Likes

Works perfectly, I feel dumb :slight_smile:. I didnt know theres curve curve intersection in rhinoscriptsyntax and I was trying to import Rhino commands and couldnt get it working. Anyways, thanks for the help.

Dan.

rs.CurveMidPoint already exist you don’t need divide to find the middle point

2 Likes