In Rhino there is a Bounce command, I’m looking for the exact same thing but in Grasshopper (Rhino 8). I saw some very old GH attempts somewhere on the Internet but they do not work for me. Is there a component that I might have just missed?
I just want to get a line bounced out of a surface.
Hi, sorry I know it should be easy in Grasshopper and it turns out it really is. Sometimes I try to solve problems in GH but end up complicating them. I just asked if there is a bounce component, you gave me a good, short solution made out of multiple components. Thank you.
@laurent_delrieu
Thanks for the component. It mostly solves the problem. However, Bounce command operates on an unsorted list of surfaces and rays can bounce multiple times from the same surface.
Using C# component surfaces must be ordered, which is only easy in simple scenarios. I can obtain multiple bounces by repeating surface inputs, but again it’s only feasible in simple cases.
My use case was simple, so I didn’t add complexity, it could be quite simple to bounce until a ray escape, also it could be better to use all sort of geometry as input (plane, surface, BRep, mesh,…).
I took shortcuts with the Anemone loop, assuming two planar surfaces with a single ray bouncing off the bottom surface first, even if it passes through the top surface. The loop could be modified to work with an unsorted list of curved surfaces. Multiple rays might be handled with nested loops, the outer loop going through a list of rays, one at a time.
However, creating a flexible test bench is almost more complicated than the Anemone loop, unless a static set of surfaces (and rays) is created in Rhino.
Not to be too picky, but that would make it an ultimate solution. Also, right now this component is not very suited to situations where there is only one bounce. Of course, I can fix that with some script after the last bounce point is determined by the C# script.
I think a more general answer would be the following:
If you don‘t find a Rhino function inside Grasshopper, then you might be lucky and find a corresponding feature in the Rhinocommon Api. But the Api does is not align to the commands, nor does it allow you to do exactly the same, unfortunately. But its close. Grasshopper in comparison is even less than Rhinocommon.
Calling an api function is not difficult if you have a basic understanding of programming. Its rather knowing the api. Therefore, if you plan to do more in Grasshopper, it definitely helps to read and play with Rhinocommon.
You would be surprised how many plugins heavily rely on simple api calls. So under the hood the majority of work is still McNeels credit, although I admit that it requires a bit of expertise to know where things are…
However, doing this I realized there is quite a big issue. Both Kevin’s C# component and Rhino’s Bounce command do not account for holes in the surfaces. You can see that the round hole is ignored.
This is not my point. The majority of components are calling Rhinocommon. You are doing almost exactly the same if you connect components on the canvas. You only lack the full „access“.
Creating a „Ray“ instance and feed it into function which performs this „bounce“ is close to zero effort. Knowing Rhinocommon is a big plus in Grasshopper. That is all I‘m saying.