Anonymous input to ghPython?

In another question on the forum, I asked if anyone knew how to implement a simple solver that could modify an input to achieve the desired output, in my case a volume. Galapagos was suggested as a solution - and to some extent it works, but is overkill for my solution.

This could be almost trivial to do in Python, but there is a big problem: If I feed the output of my GH script as an input to my ghPython component, and then feed the output of the python script to modify the geometry, Grasshopper detects that the object is self-referencing, and won’t run, even if my script does nothing but output a fixed input.

Has anyone found a way to hide this feedback loop from grasshopper? Obviously this requires careful coding of the ghPython component, since there is a real chance of an infinite loop, but that is my problem to solve, isn’t it?

An alternative would be to have a “by-ref” wire that passes a reference to the object itself, not a value, so one could get and set values of the objects from within python code… Would be fun, but would have to wait for GH2…


1 Like

is this maybe a solution? I saw it in another thread posted by @maje90 iirc (6.5 KB)


this just made my brain explode :+1:

Cool - will play around with this idea and get back to you! Thanks!


So this worked, sort of. I realize now that I’m hitting the Grasshopper wall, perhaps because my background is programming so the Grasshopper paradigm is making this super hard, for something that feels so easy.

What I really need is the ability to write a “god script” that lets me manipulate sliders just like a human would, wait for GH to finish the processing loop, then read the results back into my script so I can run it another time. This way I could implement a proper goal seek routine, just like a human would by sliding the slider until they get the output they want… Dreaming I know…

I haven’t used it myself, but maybe this is another option to try: Hoopsnake | Food4Rhino

I’m not fully following what you have in mind, can you explain what exactly you want to build? From what you explain I’d wonder why you need sliders in the first place, can’t you just handle everything inside your custom code?

Thanks Gijs - this is a good suggestion, although sadly it looks like people are having trouble installing as it hasn’t been updated since… 2014!

I did land on the Opossum plugin, which seems to work quite well for my purposes. It does require a license key, but it is free - one just had to request it.

I was hoping to write something very similar as I don’t really need such a fancy solver for now, but it works! I am planning on having several input sliders in the future so this should work really well. (Opossum—OPtimizatiOn Solver with SUrrogate Models | Food4Rhino)