algorithmic modeling for Rhino
Hello,
I'm trying to count up to a certain number and trigger or call methods at different stages of the counting.
I've tried to accomplish that with the Grasshopper timer plugged directly into the pyhton container and a boolean toggle to trigger the following script:
def counter(run):
if run == True:
counter =+ 1
else:
counter = 0
return counter
It works great, but the problem is that the timer runs the script for each iteration that it counts. I believe this is due to the fact that the Pyhton container refreshes everytime it is passed a new value?
I have like 30 functions that get called for each and every timer iteration every 500ms.
I want the timer to simply keep count, so that I can call the methods that I want at certain intervals:
if counter(run) <= 20:
"call a method"
elif counter(run) > 20 AND counter(run) <= 40:
"call the next method"
Is this even possible? Or is there a workaround?
I'm kinda lost here.
Tags:
The VB and C# components have overrides called BeforeRunScript and AfterRunScript which are called only once per solution. The VB and C# components also have an Iteration field which will be zero the first time the script runs per solution.
If python doesn't provide that, you can handle the SolutionStart or SolutionEnd events on GH_Document.
--
David Rutten
david@mcneel.com
Thanks, but how do I access GH_Document? In the python script or elsewhere?
You can access the GH_Document like so:
ghComp = ghenv.Component
ghDoc = ghComp.OnPingDocument()
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by