Grasshopper

algorithmic modeling for Rhino

Automate Sliders From Python WITHOUT Needing Full Recalculation

There are forum threads affording ways to move Grasshopper sliders from custom script components but they all seem to require a full recalculation be triggered for the entire Grasshopper script to have any affect, but that's way too slow if 90% of the GH program is initialization and creation of source geometry to then simply alter a bit or array here and there. When I use Python directly to change output values that I plug into former slider inputs, again no new solution is triggered at all so I'd have to recalculate the entire Grasshopper program which is simply not how Grasshopper normally works. How do I actually emulate a human changing a slider value one slider at a time in a way that makes Grasshopper behave normally so that only downstream flow is affected in an efficient way?

An related example would be if you have several separate programs in a Grasshopper page and you wanted to only change one of them without triggering full recalculation of them all.

At this point it's almost like a Windows mouse scripting utility is needed but if I need to do combinatorial combinations of all possible slider values, that seems quite thorny too unless I set up a pre-arranged array of values that could then simply be incremented "manually" followed by a right click to bake and then typing commands into Rhino to save to a file. UGH. That would be quite difficult to pull off since I need to control file names, but it's what I seem to need.

I'm using Python since it avoids thorny Grasshopper schemes and it allows me to access Rhino to save baked objects files.

Views: 4574

Replies to This Discussion

Looks like expiring the sliders is triggering a chain that expires your Python script, which is directly downstream. When your python is expired, Grasshopper starts your Python all over again. Your python then expires the sliders... repeat ad infinitum. Try separating your mesh script and your looping script into two separate python components.

Fundamental question, likely a general Python-in-Grasshopper one: though your script can change sliders once on its own, a timed series of changes made within Python by just repeating your slider change and slider update commands between time.sleep(2) delays fails to update until the very end so you only see and get to potentially bake and file save the very last slider settings that control Grasshopper geometry components. Related is how just having Python try to time the radius changes of a mesh sphere directly via number output does the same thing. Must I enter a list into a Python component for Grasshopper itself to march through my values? But how to then add a delay at all?

Have you looked into the looping component written by Rutten? What this does is wait for calculation to finish and then adjust a slider. This does not result in a full recalculation of the whole canvas, but only expires components downstream of the sliders - as if a human had changed them.

I have written more about them here: http://james-ramsden.com/looping-through-the-grasshopper-canvas/

He has solved the problem of getting all combinatorial values of the sliders. The Lunchbox plugin contains a 'bake' component and a 'save' component so you can automate these as part of your workflow. For generating filenames, I tend to make unique file names using the sliders with 'concatenate'.

I use this method frequently and it works very well for me - I reckon you should give it a try.

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