Grasshopper

algorithmic modeling for Rhino

Hello everyone,

I will try to be as most clear as I can.
In a script that I am building right now, I am getting some data out of it that I want to use again at the beginning of the script. It's an iterative process.
I defined a List at the very beginning of the script where I putted the data that I want to use again. But it doesn't work and python is seeing this list as empty when I try to use it again. Here you can see basically how it works:

ListOfData = []

Class X, where I want to use this List.

Def Y, where I get the data. (Def Y is calling Class X)
In Def Y, I append the data inside ListOfData.


I really don't know how to make it!

Please understand that I don't want to share my script right now cause there is really a lot of stuff inside, and I spent a lot of time on this.

Thank you for your help,

Best,

Roger

Views: 380

Replies to This Discussion

Hi, 

i think the solution for this is the "current" and "next generation" idea for the management of your list of data..

I mean you need something like this..

listOfData = []

listOfData.append(whateverYouNeed)

gens = 5 (number of times the script will recurse)

for i in range(gens):

__nextListOfData = []

__for j in listOfData:

____newSet = FUNCTION

____nextListOfData.append(newSet)

__listOfData = nextListOfData

this should make the iteration you need..

hope it makes sense!

Hi,

Maybe you can store the information externally. In this case the sticky dictionary in scriptcontext is very useful.
For example:

import scriptcontext as sc

sc.sticky['mydata'] = []

//your script

sc.sticky['mydata'].append((generation,data))

There is a old blog entry on this approach here.

http://atelierpanda.squarespace.com/thoughts/elierbinturong.com/201...

Hope this helps you

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service