Grasshopper

algorithmic modeling for Rhino

It is actually a very simple question. I want to incrementally put a variable into a list. But every time i change the slider, the list got refreshed like the picture showing below. Any idea of how to do that only by using Python? Many Thanks XD:

Views: 2713

Replies to This Discussion

Hi Nezumi.

Try this:

if r:
    recL.append(v)
else:
    recL = []

a = recL

You can set a certain value to a variable, and then allow it's change by using the boolean toggle.

Attachments:

Hi Djordje,

Thank you for helping me out!!! Is it because global variable is unecessary to declare in python?

Thank you!

We do not have a function or class in here (where you would have to take care of the variable scope), just a regular procedural code. So every variable is a global one.
The trick is to use the flow control: you reference a variable, recL = [], and then by changing the flow control you do futher changes to recL.

Wao, it is amazin. As a beginner , this trick is realy helpful for me. 

Thanx!XD

This thread also has some nifty approaches to storing persistent data using the GHPython component.

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service