For loop error GHPython in Rhino 5.13


(Avishek Das) #1

Hello all,

I am new to Python scripting in rhino and for now following a simple tutorial from ThinkParametric. I have understood the basic of it. but the problem I am facing to use a for loop withing Ghpython component. I have tried writing a simple loop in other GHpython component and it runs totally ok. but somehow here it gives an error:
Runtime error (ArgumentTypeException): list is not callable
Traceback:
_ line 33, in script_

here in line 33 the for loop starts. I am attaching the files here. if you could please have a look and suggest some solution.

Thank you
20180610_Curvature Optimization_01.gh (3.9 KB)
20180610_Curvature Optimization_01.3dm (157.4 KB)


(Giulio Piacentino) #2

The error means that you have a list and you are calling it ().

For example:

mylist = []
mylist()

I hope this helps, thanks,

Giulio


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


(Avishek Das) #3

Hi Giulio,

I honestly don’t think I have understand your solution. I am i guess not capable of understanding that. for some reason I never could run a For Loop inside the GHPython Node with other script pieces existing. So what I did finally was to use a While Loop to do the job for the For loop and it solved the issue. Will it be possible for you to see the GH file for once?

Thank you for your response.


(Alain Cormier) #5

Hi,

You’re redefining the Python range function to be a list:

range = ghcomp.Range(1, sample)

(Avishek Das) #6

Thanks a lot Alain. So silly of me to overlook that. I will update it and let you know if it works.
Totally makes sense now!

Thanks a lot.


(Avishek Das) #7

It works now! Thank you both! Got the concept of list now!!