#Script 1:
if "count" not in sc.sticky.keys():
sc.sticky["count"] = 0
for i in range(10):
sc.sticky["count"] += 1
a = sc.sticky["count"]
print a
#Script 2:
if x >0:
del sc.sticky["count"]
print "final x = ",x
But the first script still counts 10 times, not 5:
This part of your code is flawed because it only runs exactly once, when “count” is not yet in the sticky dictionary, and also only outputs data (e.g. 10) that first time.
if "count" not in sc.sticky.keys():
sc.sticky["count"] = 0
for i in range(10):
sc.sticky["count"] += 1
a = sc.sticky["count"]
print a
When you rerun the component, you should notice that your output is now None.
Are you attempting to make something like a counter that will trigger an other component once it hits a certain value?
I want to create a loop with termination condition, The “Anemone” wastes a lot of time when there is a lot of computation, "Galapagos Evolutionary Solver " cannot be calculated automatically when the input data changes.
I tried global variables, but the data in them is still only output once same, and cannot work with grasshopper, I want the next solution will run recursively within the current solution. So like you noticed, I used two GhPythonScript, although it didn’t work as I expected.[
It’s still not exactly clear to me what you attempt to achieve, but I don’t think that recursion can be achieved with Grasshopper components. You need a recursive function within on of the scripting components to accomplish that.
Probably, yes. If you can further explain what your goal is, I can maybe give further advice.
That’s rather hard to do, if even feasible, since the solver isn’t meant to be externally triggered.
I’ve come across issues like this in the past and usually I came to the conclusion that it was best to simply implement it all within the scripting component. Given that this is not an easy task, but it’s an opportunity to learn and setup everything like you want it.
There also are many examples out there on how to do an evolutionary solver in Python.
I can use do this in one PythonScript only, but I can’t creat loop with components, that’s my need, otherwise I must convert all the components that I need into python and write all into a script.