How to "elegantly" match BrepFace normal with surface face direction?

So Curve.OffsetNormalToSurface() is offsetting consistently to one side and not following random surface U,Vs?

Hi @Asterisk,

Curve.OffsetNormalToSurface works with surfaces. If you pass it a Brep face, it will just evaluate the face’s underlying surface.

– Dale

offset = edge.OffsetNormalToSurface(brepface, -off) # note negative offset to offset opposite of normal

Where brepface is:


After flipping U and V:

Same results if I do

offset = edge.OffsetNormalToSurface(face.ToNurbsSurface(), -off)

Is it a bug? I need U,Vs to not matter. Or “fix” 'em to match surface face orientation with a couple of code lines if possible. @dale

Sorry if I revive this old topic.

did you find a workaround for that one? I’m bumping in the exact same problem.


doesn’t seem to make a difference between v(0,0,1) and v(0,0,-1) as output.
If I flip the surface, the offsetted crv would stay in the same place.

I then made this:

public Curve OffsetNormal(Surface S, Curve C, double D)
    Point3d cCenter = C.GetBoundingBox(true).Center;
    double u,v = 0.0;
    S.ClosestPoint(cCenter, out u, out v);
    Vector3d normal = S.NormalAt(u, v);
    C.Transform(Transform.Translation(normal * D));
    return C;

which would give me the same result.

how would i access the “real” direction without being forced to do both directions and compare them.

please notice that the brepface and the surface can have reversed normals. you can check this by

does this help ? kind regards -tom


I solved it by not using edge.OffsetNormalToSurface()

            brepoff = Rhino.Geometry.Brep.CreateFromOffsetFace(face, -offset, 0.001, False, False)
            dist = abs(offset) + 1
            for i in brepoff.Edges:
                tstPt = i.PointAt(i.NormalizedLengthParameter(0.5)[1])
                chk = round(refpt.DistanceTo(tstPt), 3)
                if chk < dist: edgeoff, dist = i, chk
            newflange = Rhino.Geometry.Brep.CreateFromLoft(
                [edge, edgeoff],
1 Like

Thank you, this did it!

Thank you both, guys. I came to the same conclusion, but was too tired yesterday to finish the workaround. Thanks!!