Quantcast
Channel: Scripting - McNeel Forum
Viewing all articles
Browse latest Browse all 5938

IronPython losing connection to scriptcontext.doc

$
0
0

I have a simple Python script that is causing an error Grasshopper. I can get the same script to work by moving the line generating the error out the loop.

This works:

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)

This does not work:

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)

The error has the following message:

Runtime error (Python Exception): Unable to add polyline to document

Traceback:
line 563, in AddPolyline,
“C:\Users\graha\AppData\Roaming\McNeel\Rhinoceros\7.0\Plug-ins\IronPython (814d908a-e25c-493d-97e9-ee3861957f49)\settings\lib\rhinoscript\curve.py” line 10, in script

I believe that the error case should be a valid Python script, even though it’s less efficient than the working case. In any case, I don’t believe that moving line 10 should an error.

I have attached the two versions of the Grasshopper scripts, as well as my Rhino installation information.

AddPolyline_Working.gh (2.8 KB)

AddPolyline_Error.gh (2.8 KB)

Rhino System Information.txt (2.7 KB)

3 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 5938

Trending Articles