Grasshopper

algorithmic modeling for Rhino

(Copied from Rhino.Python; I'm told this is where more people who can help me hang out)

I'm building a series of window-blind models to be used for lighting simulation, and I'd like to be able to generate and bake them, using python and Grasshopper.
More concretely, I have a list of pairs of blind heights and angles that looks like this:

Angle Fraction Down
0 0.5
0 0.75
0 0.875
15 0.25
15 0.5
...

I'd like to set the angle and the height in my Grasshopper solution, bake it to a layer, then export that solution to an OBJ file, and repeat until all angles and heights are done.

I got an answer for baking the solution—I think—but I do not see how to synchronize  the setting of angles and heights with the baking operation.

I would like to be able to write something like:

  for ang,hgt in [...]:
# ... allow solution to work ...
# bake and export

But this is not very Grasshopper-ish and I do not see how to do it. Please let me know how!

(BTW, is there a standard way for inserting code in this visual mode editor?

Views: 1125

Replies to This Discussion

make a slider that selects a given pair, using the index of the pair.

connect everything so that it will bake the selected pair

right click on your selection slider and go to "Animate"

I'll give that a try.

Ah. Finally figured out how to upload a script--as an attachment. So here it is, for anyone who is interested.

A few notes on the script:

  1. To iterate through the blind positions, I used an integer slider with animate--this was the only way I found to do it.
  2. I converted my spreadsheet of (angle, height) pairs to two separate Grasshopper lists, then used a slider to select list elements.
  3. There seems to be no way to stall or wait; unless state is recorded in the Rhino document and checked when the script starts, the script will run multiple times.
  4. I found it useful to have a switch that would prevent the script from operating at all.
  5. The Python script blocks Grasshopper; if it loops, there is apparently no way to stop it
  6. Important to set the attributes of the inputs to the Python script widget; otherwise the script receives data it can't handle.
  7. I never did figure out how to cope with a Grasshopper tree as input to the script; I flattened it to a list instead.

 

Attachments:

Regarding number 7. this might help.

Thanks!

I got it working; since I can't figure out how to post code in a reply, I'll put it up in a new thread.

I've now tried to post twice. I give up. Look here for my post: http://python.rhino3d.com/threads/1261-Baking-Grasshopper-Solutions...

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service