algorithmic modeling for Rhino
Is there a way to "nest" functions in grasshopper? Something like:
fn( fn( fn(a,b), fn(a,b) ), fn (a, b) )
I tried using delegate/ anonymous functions in C# and had some success. However, I cannot seem to go more than one level deep. This is based on an answer to someone else's question, here.
For example, this shows a working script where a function is defined in one c# node then solved in the second node. The "Make box" components pass a function to the "execute delegates" component, which then assigns variables to the anonymous function and solves based on those vars.
The next image shows how the "Execute Delegates" node only tries to solve one layer down, and so it expects two Breps, instead of knowing that it should solve "bottom up", by generating the Breps, then joining them (the join is defined as another deferred/ anonymous function, within the "Boolean Union" node. To be clear, all nodes shown are custom c# nodes.
I also attached the Grasshopper file, as seeing the code is probably helpful... Thoughts?
Tags:
I don't understand. The last C# component tries to invoke a delegate which takes two breps, but you're giving it three points. Was this supposed to work on points?
That's not the way function nesting works in C#. Delegates are only described by their signature, not their contents. Once you put one delegate inside another delegate, nobody will ever be able to figure out it's in there.
What you're after will involve you designing an entire system which maintains delegate functions separately, and can figure out on its own how to invoke them in turn and which arguments are supposed to go into each one. This is not exactly trivial.
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
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by