Grasshopper

algorithmic modeling for Rhino

Beginner at Python, come across a dead end and can't figure it out!

Hi there.

I've just begun using Python and have been following this tutorial very closely:

<iframe src="https://player.vimeo.com/video/60606151" width="500" height="262" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe> <p><a href="https://vimeo.com/60606151">06.03 Travelling Salesman - Python</a> from <a href="https://vimeo.com/exlab">exlab.org</a> on <a href="https://vimeo.com">Vimeo</a>.</p>

However, I've run into a dead end where on line 3 it says 

"Runtime error (UnboundNameException): name 'startIndex' is not defined"

I've tried changing the inputs' names on the Python inputs but have found nothing. What does the 'startIndex' being not defined means? I assume it just can't find the "startIndex" as I may have missed it in my cluster?


Some help would greatly be appreciated, I've attached my gh definition if anyone is able to look. Thanks a lot for your help guys.

Ed

Views: 842

Attachments:

Replies to This Discussion

Hi Edward

this likely means that you did not rename the input variable "startIndex" of the component to that name.GhPython provides the Python interpreter with all variables that are set as inputs, and searches the highest scope for variables with the name of the outputs.

Does it help?

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

Hi Guilio, 

Thanks a lot from your reply! Is this what you mean about the name of the input variable startIndex? Because thats what I seem to have put down but its not recognising it... would it be an issue with something inside the component? This question is so basic and I feel so silly not being able to figure it out...

See if this helps...

List of changes:
start index => startIndex
type hints of allPts, startIndex and iterations
list access of allPts

I got the attached file.
I hope this helps,

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

Attachments:

Thank you so much for your help! Didn't know about the type hints and list access on the Python, cheers.

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service