Offset trimmed surface

I am using the following code to visualise thickness of Breps and their faces (comments on how this could be done otherwise or better welcome):

Brep getThickenedSurfaceBrep(BrepFace face, double thickness, double eccentricity) {
    double tol = RhinoDoc.ActiveDoc.ModelAbsoluteTolerance;
    Surface offset = face.Offset(eccentricity, RhinoDoc.ActiveDoc.ModelAbsoluteTolerance);
    BrepFace offsetFace = offset.ToBrep().Faces[0];

    Brep thick = Brep.CreateFromOffsetFace(offsetFace, thickness / 2, tol, bothSides: true, 
createSolid: true);
    return thick;
}

The issue is that trimmed faces are back to their untrimmed state as soon as I use the Offset method. How can I create this offset solid from a trimmed face?

Its the ToBrep method as well as face.Offset that will untrim the face.

Can’t you just feed your face variable to Brep.CreateFromOffsetFace ?

You seem to be trying to offset the face twice so both times I would use Brep.CreateFromOffsetFace, but don’t use ToBrep in between if you want to preserve the trim definitions

.

I do it like this because Brep.CreateFromOffsetFace offsets the surface in place, while I want to be able to have eccentricity applied, therefore I first move the surface by the eccentricity.

You asked why your trimmed brepface was losing reverting to its untrimmed

Both of these lines in your code will result in the loss of the face trims:

    Surface offset = face.Offset(eccentricity, RhinoDoc.ActiveDoc.ModelAbsoluteTolerance);
    BrepFace offsetFace = offset.ToBrep().Faces[0];

That means you cannot use those functions if you don’t want to lose the trim boundaries. You have to do it a different way.

If you use face.Offset() it will offset the underlying surface and the trim boundaries are lost.

The first offset needs to be done with Brep.CreateFromOffsetFace() as does the second offset. You should extract the face from the brep result of the first offset to get the face to input for the second offset.

That was enlightening, this is how I made it work, thanks for the input:

Brep getThickenedSurfaceBrep(BrepFace face, double thickness, double eccentricity) {
    double tol = RhinoDoc.ActiveDoc.ModelAbsoluteTolerance;
    Brep offset = Brep.CreateFromOffsetFace(face, eccentricity, tol, bothSides: false, createSolid: false);
    BrepFace offsetFace = offset.Faces.First();

    Brep thick = Brep.CreateFromOffsetFace(offsetFace, thickness / 2, tol, bothSides: true, createSolid: true);
    return thick;
}