Get curve mid-point using curve name

Hi!

i’m trying to implement a small script wherein i have for example n curves.
I have assigned names to the curves using the “Name” Field under ‘Properties’…101,102,103…and so on
I would now like to start a polyline command and specify the mid-points of all lines in sequence of naming.
How can this be achieved?

Thanks!

Hi Enrico,

Below is a script that should work.
The lines starting with a # are commensta describing what the line below does.
Let me know if it helps:

import rhinoscriptsyntax as rs


#define a  the method
def polyline_through_mids():
    
    #let user select objects restricted to curves (filter 4)
    curve_objects = rs.GetObjects('get curves', filter = 4) 
    if not curve_objects: return #no selection made
    
    #sort the objects by object name 
    curve_objects.sort(key = lambda curve: rs.ObjectName(curve))
    
    #create a list of midpoints 
    mid_points = [rs.CurveMidPoint(curve) for curve in curve_objects]
    
    #create a polyline from the points
    rs.AddPolyline(mid_points)
    
#run the method
polyline_through_mids()

Willem

Thank Willem! It works great!