Pufferfish "Offsrf" component : screwy result

Yes, that’s expected. The function was added for R6

2 Likes

Hi Daniel

I don’t think @osuire means it that way. I sense it has to do with the code simply not working because you need many additional steps than just ctrl+c - ctrl+v the line of code into the component. Maybe a simple “how-to” from Rhino would be nice.

“How to”

Ah yes, perhaps I was projecting my own wishes a bit there. I dream of something that could automatically turn library functions into components, but I agree that it would be helpful to have a guide to the current process for turning a function that exists in RhinoCommon into a Gh component.

Others might chime in, but I’ll have a go…

2 Likes

Thank you Daniel !
You might save me a full year of studying C# right there !

So if we know the name of the function we want to call, we start typing that:


Once we open the brackets the box should pop up telling us what arguments we need to provide, ie the inputs for the function, with the one we are currently typing in highlighted in Bold. It shows the type of data required for each, and the name.
image
For the function to work we need to provide exactly those types of data in that order.
(actually some functions have overrides, so they can accept a few different sets of input types, but we can come back to that)

The names you give these inputs don’t affect the behaviour, as long as they are of the correct type.
We need to also create and name inputs for these on the Grasshopper component by right clicking the input names (adding more inputs if needed with the little + icon that appears when you zoom in)
image
We can also set the Type hint here, making sure we have all the inputs needed for the function.

When we open the script editor after doing all this, we should be able to see all these names and types we’ve just created at the top like this:


…and we can then plug them into our function
We can see from the description of the function here that it returns an array of Breps, so we can assign this to our output A by typing
A = Brep.CreateOffsetBrep(brep, distance, solid, extend, tolerance, out outBlends, out outWalls);
That’s pretty much it.

The one extra little complication here is these last 2 arguments which have the keyword ‘out’ before them. We need to create these variables first so the function can assign to them. We know they are both of type double array, so we can do this by adding this line at the start:
Brep[] outBlends,outWalls;

This is just a very short and incomplete guide, but hopefully of some use to get started with.

12 Likes

With GhPython

Offset Brep.ghpy (30 KB)

2 Likes

Hi Daniel,

Could you add an option to force crease splitting at tangents ?
The CreaseSplitting option is “Enabled” in Rhino, but it seems to be ignored here.

1 Like

Can you post the geometry?

Hi Daniel,

FYI for the brep Brep.Faces.SplitFacesAtTangents should be called.

https://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_Geometry_Collections_BrepFaceList_SplitFacesAtTangents.htm

I’m not familiar with C# for else I’d add it myself.

-Willem

Not in front of a computer right now, but if you make a random closed polyline, and fillet the corners, you will get an example.

You could do it like this:


(set the type hint to bool)

    Brep[] outBlends,outWalls;
    Brep[] offset = Brep.CreateOffsetBrep(brep, distance, solid, extend, tolerance, out outBlends, out outWalls);
    if (split && offset[0].Faces.SplitFacesAtTangents())    
      A = offset;    
    else
      A = offset;

Just tried out the Sasquatch OffsetSrf component and it did seem to work pretty well. I put a few RhinoPolyhedra objects, minus one face, through it, and got good results.

But then I tried it with the polysurface that inspired this thread. (Thread is about creating compound miters in Rhino, and having Shell and OffsetSrf both fail. But if I could draw it manually, shouldn’t we be able to get Grasshopper to do it automatically?)

Anyhow, I took the object that broke Rhino OffsetSrf and Shell and plugged it into Sasquatch OffsetSrf aaaaaand… it broke:

Here’s the definition, with previews that highlight edges and naked edges for clarity: Sasquatch Offset Srf Fail.gh (27.5 KB)

What’s weirdest to me here is that if I move the offset distance slider around, I get a variety of different failures. Sometimes the result disappears entirely.

Questions:

  1. Is there something about polysrfs with both convex and concave edges that is special and creates problems for offsets?

  2. Do convex and concave edges that share vertices make it especially tricky?

Most likely Sasquatch is just using that same method from Rhinocommon.

Do you think my hypothesis about mixed concave and convex edges creating a problem for offsetting polysrfs with planar subsrfs is right?

Ok, there you go :

Give crease a chance.gh (14.8 KB)

I struggled 10 minutes with the C# component, but at least I learned something.
Was that the intent in not posting the ready-made component ?

Anyways, thanks Baris. It works.
The Sasquatch component has a “Sharp edge” input, but it does not affect the tangent crease splitting.

In crease the volume.gh (11.0 KB)

3 Likes

Pufferfish has a “Split Kinky Surface” component that would also split that at the creases I believe, can’t remember if I included breps there.

10 minutes is not so bad for a beginner in C#, I’m sure we’ve all struggled a lot longer with much simpler things :grinning:. Good job to figure it out.

No, you didn’t. It works only for surfaces.
Moreover, it doesn’t split at tangents which is to my mind the best use case for such a component.

Rhino’s dreadful habit to make single surfaces from polylines with tangent curves requires a remedy.
In Rhino, it’s ill-named “Divide along creases” with the “Split at tangents” option.
To my knowledge, there is no equivalent in Grasshopper.

… here we go again… In my opinion…

I will keep reminding you to speak for yourself because it pissing me seriously off.
Creating single surface from polyline with tangency is something I absolutely love.