I m looking a way to automate the process of unrolling curves in one direction.
I give below an example and i have also attached the 3dm file.unroll_crv_1d.3dm (60.9 KB)
The original curves are shown below.
The goal is to unroll them on the Z-axis:
Then i measure the length of each segment of the blue lines and create a 1-D line .
Finally i connect the end points of each segment with the longitudinal curves (red)
I have written the following code that unroll all lines which are selected but does it individually.
import rhinoscriptsyntax as rs
import Rhino.Geometry.Line as Line
curves = rs.GetObjects("Pick some curves", rs.filter.curve)
expanded_crvs = []
for curve in curves:
crv_length = rs.CurveLength(curve)
start_point = rs.CurveStartPoint(curve)
end_point = rs.CurveEndPoint(curve)
#expanded point and projected on xz plane
start_point_new = [start_point[0],0,start_point[2]]
end_point_new = [start_point[0],0,start_point[2]-crv_length]
#add all new curves in list
expanded_crvs.append([start_point_new,end_point_new])
Furthermore, suggestions and advices on the code above are more than welcome.
Does anyone know how to sort the expanded_crvs based on the Z-coordinate?
Furthermore, how can I maintain the layer and the name for each segment?