Runtime error (PythonException): Unable to add polyline to document

I’m following this video, 4.1_Points | Rhino3D.Education … towards the end, I receive the error in italics below … can anyone tell me why its happening and how to fix it?

import rhinoscriptsyntax as rs

all_pts =
for j in range(30):
if j %2 == 0:
pts = rs.AddPoint(j, 4, 0)
else :
pts = rs.AddPoint(j, 10, 0)
all_pts.append(pts)
pl = rs.AddPolyline(all_pts)

Runtime error (PythonException): Unable to add polyline to document

Traceback:

  • line 563, in AddPolyline, "C:\Users\mdj\AppData\Roaming\McNeel\Rhinoceros\7.0\Plug-ins\
  • line 10, in script*

4.1_Points.gh (9.7 KB)

moved to grasshopper category

Hi MJD

first a tip: to format he code when pasting encapdulate it between 3 ticks like so:
image

I think you have the indentation wrong and the last line needs to be without indentation:

import rhinoscriptsyntax as rs

all_pts = []
for j in range(30):
    if j%2 == 0:
        pts = rs.AddPoint(j, 4, 0)
    else :
        pts = rs.AddPoint(j, 10, 0)
    all_pts.append(pts)
pl = rs.AddPolyline(all_pts)

Does this help?

Yes, @Willem , thank you!