import Rhino
import scriptcontext
import rhinoscriptsyntax as rs
if __name__ == "__main__":
# Get Curve:
crv = rs.coercegeometry(rs.GetObject("Select Curve Object"))
# Settings:
angle_tol = Rhino.RhinoMath.ToRadians(5.0)
min_edge = 0.0
max_edge = 0 # =ignore
# Make into "PolyLine Curve"
plinecrv = crv.ToPolyline( 0, 0, angle_tol, 0.0, 0.0, 0.01, min_edge, max_edge, True)
# Makeinto "PolyLine"
rc, polyline = plinecrv.TryGetPolyline()
if not rc:
print("error")
txt = ""
for pt in polyline:
txt += "M3, {0[0]:.6f}, {0[1]:.6f}, {0[2]:.6f}\n".format((pt.X, pt.Y, pt.Z)) # even with out the '\n'
print(txt)
# print(txt)
When print(txt)
statement is within loop:
RunPythonScript [start]
Executing File
M3, 0.000000, 0.000000, -4.000000
M3, 0.000000, 0.000000, -4.000000
M3, 0.545227, 0.000000, -2.643087
M3, 0.000000, 0.000000, -4.000000
M3, 0.545227, 0.000000, -2.643087
M3, 0.805229, 0.000000, -2.068123
M3, 0.000000, 0.000000, -4.000000
M3, 0.545227, 0.000000, -2.643087
M3, 0.805229, 0.000000, -2.068123
M3, 1.057129, 0.000000, -1.558757
...
when it is outside the loop:
RunPythonScript [start]
Executing File
Now, here is where is get really strange:
the above was produced, when using this crv:

when i use this crv:

it works!
RunPythonScript [start]
Executing File
M3, 3.000000, 0.000000, 3.000000
M3, 3.119690, 0.000000, 2.205078
M3, 3.198509, 0.000000, 1.843140
M3, 3.289551, 0.000000, 1.503906
M3, 3.392494, 0.000000, 1.186646
M3, 3.507019, 0.000000, 0.890625
M3, 3.632805, 0.000000, 0.615112
M3, 3.769531, 0.000000, 0.359375
M3, 3.916878, 0.000000, 0.122681
M3, 4.074524, 0.000000, -0.095703
M3, 4.242149, 0.000000, -0.296509
M3, 4.419434, 0.000000, -0.480469
M3, 4.606056, 0.000000, -0.648315
M3, 4.801697, 0.000000, -0.800781
M3, 5.006035, 0.000000, -0.938599
M3, 5.218750, 0.000000, -1.062500
M3, 5.439522, 0.000000, -1.173218
M3, 5.668030, 0.000000, -1.271484
M3, 5.903954, 0.000000, -1.358032
M3, 6.146973, 0.000000, -1.433594
M3, 6.653015, 0.000000, -1.554688
M3, 7.183594, 0.000000, -1.640625
M3, 7.736145, 0.000000, -1.697266
M3, 8.308105, 0.000000, -1.730469
M3, 9.500000, 0.000000, -1.750000
M3, 10.738770, 0.000000, -1.746094
M3, 12.003906, 0.000000, -1.765625
M3, 12.639954, 0.000000, -1.798828
M3, 13.274902, 0.000000, -1.855469
M3, 13.906189, 0.000000, -1.941406
M3, 14.531250, 0.000000, -2.062500
M3, 15.147522, 0.000000, -2.224609
M3, 15.752441, 0.000000, -2.433594
M3, 16.049843, 0.000000, -2.557495
M3, 16.343445, 0.000000, -2.695313
M3, 16.632927, 0.000000, -2.847778
M3, 16.917969, 0.000000, -3.015625
M3, 17.198250, 0.000000, -3.199585
M3, 17.473450, 0.000000, -3.400391
M3, 17.743248, 0.000000, -3.618774
M3, 18.007324, 0.000000, -3.855469
M3, 18.265358, 0.000000, -4.111206
M3, 18.517029, 0.000000, -4.386719
M3, 18.762016, 0.000000, -4.682739
M3, 19.000000, 0.000000, -5.000000
WHAT???
is this some (really strange) memory thing?