Pufferfish "Offsrf" component : screwy result

I wonder why the Pufferfish “Offsrf” component gives me such a strange result while the Rhino equivalent works fine.
Isn’t it the same underlying low-level tool (or whatever programmers call this) ?


Screwy Solid offset.gh (46.5 KB)

Taking an even more basic example :

In Fusion :

I’m stricken by how Rhino can accomplish prowess on complex geometry, and somehow fail to do basic stuff like that.

Try Sasquatch Offset Brep

2 Likes

Hi !
Thanks, I wasn’t aware of Sasquatch ; I’ll give it a try.

I finally used the GH Offset Surface component and built all the side walls.
That allowed me to have split at tangents which is not the case here.

2 Likes

Hi @osuire, Pufferfish is not meant to offset polysurfaces that way, only polysurface faces which is a different thing according to Rhinocommon, that’s why I named it offset surface and described that it can offset polysurface faces. I’ve explained that in a few topics that you’ve been in :slight_smile:

The actual offset Brep wasn’t added until Rhino 6 (Pufferfish supports rhino 5). You can find it in many plugins like Parakeet. Also it is directly in Rhinocommon as a one liner here (R6 only) Brep.CreateOffsetBrep Method (Brep, Double, Boolean, Boolean, Boolean, Double, Brep[], Brep[])

Apologies again if the description may have thrown you off!

Hi Michael,

Now I remember. Ugh…
The problem is that I need this functionality in GH, and the polysurfaces I deal with will “Offset solid” kind of OK in Rhino.

OK, here’s my mini-rant to programmers who point egg-heads like me to Rhinocommon code.
I tried many times copy-pasting these in C# components, but there’s always something wrong or missing.
See, that’s exactly why I hate traditional coding : the goddamn syntax and all the little nerdy tidbits that allow it to actually work.

So if you don’t mind, could you please encase this Rhinocommon function (or class, or sub-program, or whatever you super coders call it) inside a little C# component that I can readily use ?

:pray:

1 Like

Here you go
brepoffset.gh (5.7 KB)
I agree it would be very nice if there was an easier way to turn a single function into a gh script component. Just creating and naming all the inputs and setting their type hints is quite a lot of clicking for something that could perhaps be automatic.

3 Likes

In R5, this error from C# component:

  1. Error (CS0117): ‘Rhino.Geometry.Brep’ does not contain a definition for ‘CreateOffsetBrep’ (line 71)

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;