I would like to cycle through design options using a grasshopper python component in the following way:
for i in range(1, 15):
a = i
where a
is the name of the output.
a
would then be linked, for instance, to the diameter of a circle.
On the rhino viewport, I would expect to see the circle changing diameter at each step of the iteration.
Obviously what I show doesnt work.
I also tried using time.sleep(1)
in between each steps, as well as ghenv.Component.ExpireSolution(True)
.
Both of them fail / crash the rhino software.
Any help or pointers hugely appreciated
In Grasshopper, components output after they finish computing so in your case the last iteration will always be output. All sleep is going to do is slow down the overall computation time until the last thing is output. What you are trying to do should be done outside of the solve instance or with a timer.
diff-arch
(diff-arch)
February 3, 2020, 7:02pm
3
Check out my Python script from here:
Welcome @haehnsen ,
The problem is that the GHPython component doesn’t recompute at each loop iteration! Instead it runs your script once internally, keeping track of your desired pauses, and then returns the result(s) at the script end. It only updates itself, if it gets externally triggered, by you or an input parameter changing.
What you are trying to do isn’t possible, unless you explicitly control the way the component gets updated:
[example]
from scriptcontext import sticky
import Gras…
It might be what you are looking for.
1 Like