Python <__main__.Class instance at ... cannot retrieve the list

I cannot retrieve a list from my class. Unfortunately I only receive the main location. However, I want to retrieve a list while looping the function inside the class.

I am not sure if I have to place te looping inside or outside the class. I want to retrieve the value list and mark the points with the values.

How can I retrieve that properly?
I think I have to rewrite it completely to make a class more suitable for Grasshopper Python.

Thanks in advance for your response.

An example of retrieving the values from a class. I cannot figure it out how it can be implemented in my script.

This pyton script is based on Syred’s script.

00 python grassfire.gh (542 Bytes)

your def showValues(grid_listValues): is kinda wrong. since you use it as a class method Python understands grid_listValues as the reference to the class instance the method is called on. That is why you get the string you get.

You probably want to set a to Grassfire.set_grid_values() which does give you a list (like you show in the panel). I suggest you call your instance grassfire as well, to keep it not confused with the class name Grassfire:

b = grassfire.set_grid_values()

Perhaps you meant to return self.set_grid_values() from your def showValues(self)

1 Like

Thank you for your response.
What I am trying to achieve is to return the ‘changed’ list after the changes I made through the class.

I inserted ‘steps’ to let the class-part Grassfire.find_path_generator run and change the values through the other functions it runs.

Unfortunately I am not able to achieve that yet. I maybe should rewrite it or learn more about classes and practice to make more smaller classes in order to make this big class functioning (I already tried a lot, but learning more might be needed).

You probably should do a comprehensive Python tutorial on classes. I think the tutorial on doc.python.org is quite good:

https://docs.python.org/2.7/tutorial/classes.html