I am trying to break a polyline at its angles until i get 4 segments out of it. So i thought this could just be done by increasing the angle. But for some reason, if fails on one of the example polylines attached below. Here is the script:
import Rhino import rhinoscriptsyntax as rs import math def SplitPolylineAtAngle(polyline): for angle in xrange(5, 180, 5): segments = polyline.BreakAtAngles(math.radians(angle)) print "Angle:", angle, " Segments:", len(segments) if len(segments) == 4: break if len(segments) != 4: return for s in segments: rs.AddPoint(s.PointAt(0)) if __name__=="__main__": id = rs.GetObject("Polyline", rs.filter.curve, True, False) if id: polylinecurve = rs.coercecurve(id, True) rc, polyline = polylinecurve.TryGetPolyline() if rc: rc = SplitPolylineAtAngle(polyline)
File with some testing polylines: Polylines.3dm (52.1 KB)
One Polyline fails to break at the angles even when 120° is reached. Anything i´m doing wrong here ?