Runtime error (IndexOutOfRangeException): index out of range: 0 Traceback: line 3, in script

hello, I am using python grasshopper . I had wrote in the script “print my_list[0] "
but I have get an error which is " Runtime error (IndexOutOfRangeException): index out of range: 0
Traceback:
line 3, in script”

any help plzz
Fatima

Please add the file or enough screenshots to help people figure out your problem.

hello, I am using python grasshopper . I had wrote in the script “print my_list[0] "
but I have get an error which is " Runtime error (IndexOutOfRangeException): index out of range: 0
Traceback:
line 3, in script”

any help plzz
Fatima

From what I see, you don’t have any input on that list, so printing it’s element “0” would result an error.

Another possible problem is, you have to specify type for this input. Right-Click on the input “my_list” and choose List Access.

See the last post in this thread:

Oh… first of all thank you for your fast response.
It is working now.
1)I have other errors which is related to aggregate command as shown in Fig 1 (notice that before writing :" a = aggregate(brep, pointSet2)" , when I click test it give me that Execution completed successfully.the error only appear when I wrote a=…)
Runtime error (IndexOutOfRangeException): index out of range: 2
Traceback:
line 32, in aggregate, “”
line 53, in script

  1. I have also another error as shown in pic 2 which is
    Runtime error (SyntaxErrorException): unexpected indent
    File “”, line 69
    a = recursiveAggregation(brep, iteration, count)

    ^
    SyntaxError: unexpected indent

thank you very much for your help
Fatima

here are the files @piac
for the mentioned errors and thank youu
Puthon 1.1.3dm (28.7 KB)
to dr mustafa.gh (11.4 KB)

fatima

What is your goal?
What are you trying to create at the end?

Actually I am following a tutorial and I am applying the same steps.

  1. in the aggregate command the goal is to rotate the object based on certain plane and set point, when I wrote “return” everything is okay as shown in pic 1, but when I wrote a=… to see the results, an error appear as shown in pic 2

  2. in the recursiveAggregation command the goal is to copy each time the object and put it in different orientation consecutively to have many copied object

Thank you
Fatima

@architectbelok,

Fatima, could you add a link to this tutorial you’re following, or upload the file if it is in a PDF or whatever.

See, I am not a python guru, and simply reading the code cannot really figure out what you’re trying to do.

@piac, as you’re the GH+python guru, could you take a look?

Dear IVELIN,
thank you so much for yout time and help.I really appreciate it.
here is the link for the tutorial that I am following it

and here are the description of the errors
( I have already send the file in this discussion it contains 3 python script each one is related to each error mentioned below)

Error 1)  when I want to get the points of a surface of an object brep, I should have in the output 5 pints including the center, but I am just having to points…I do not know why {as shown in the python surface point script file }

Error 2)  I have other errors which is related to aggregate command{ and as shown in the python aggregate script file}

 (notice that before writing :" a = aggregate(brep, pointSet2)" , when I click test it give me that Execution completed successfully.the error only appear when I wrote a=…)
Runtime error (IndexOutOfRangeException): index out of range: 2
Traceback:
line 32, in aggregate, “”
line 53, in script 

Error 3)  have also another error which is

Runtime error (SyntaxErrorException): unexpected indent
File “”, line 69
a = recursiveAggregation(brep, iteration, count)

^
SyntaxError: unexpected indent

Hope to reply I soon as possible plzzz

Thank you very much

– 

Best Regards

Fatima Belok/Architect

PhD candidate

Hi Fatima,

did you read the Python 101?
I would start with something simple, like the examples that are in that fantastic PDF:

https://www.rhino3d.com/download/ironpython/5.0/rhinopython101

Thanks,

Giulio


Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com

Dear Giulio,
thank you for your reply , I have read something related to this and for sure I will check this one .
But Please I nees to solve these 3 errors because I am working on these command now. So kindly if you have time have a look on them.
I am really thankful for your help
Best Regards
Fatima Belok

Hi,

in the allPts function the last line is improperly indented. “return” should be on the same column as “for” five lines above. Like this:

    for line in lines:
        pt = rs.CurveEndPoint (line) 
        allPts.append (pt) 
        # point append mean the list of point
        
    return allPts

line 69 also has a leading space that should be removed.

Indentation is very import in Python.

Dear Alain,
Thank you so much for your reply, But I have try it but still not working as you can see below
could you help me please?
Thank youu
Best Regards
Fatima Belok



The error message tells you exactly what is wrong. The def of the function recursiveAggregation takes four arguments, but you call it with only three. You need to fix that.

1 Like