gumyr / build123d

A python CAD programming library
Apache License 2.0
402 stars 75 forks source link

Face not coplanar with Sketch #187

Closed jdegenstein closed 1 year ago

jdegenstein commented 1 year ago
from build123d import *

with BuildPart() as p:
    Box(10,10,10)

with BuildSketch(p.part.faces().sort_by(Axis.Z)[-1]) as s:
    Offset(p.part.faces().sort_by(Axis.Z)[-1],amount=-1)

gives the error ValueError: Face not coplanar with sketch in relation to the call to Offset()

gumyr commented 1 year ago

Commit 3d6414d06b01970771ff695ea55cc74e14778175 realigns all faces add to a Sketch to its local Plane.XY which allows faces to be added without the coplanar error. Here is a slightly move difficult version of the above:

with BuildPart() as p:
    Box(10, 10, 10)
    front = p.part.faces().sort_by(Axis.X)[-1]
    with BuildSketch(front) as s:
        offset(front, amount=-1)
    extrude(amount=-1, mode=Mode.SUBTRACT)

image

It's still possible to get into trouble by adding non co-planar edges as determining the plane they come from is problematic. Note that if the edges are built in BuildLine all the translation is done for the user automatically.

jdegenstein commented 1 year ago

Thanks gumyr!