gumyr / build123d

A python CAD programming library
Apache License 2.0
395 stars 72 forks source link

Face added to part gives different results when added to BuildPart vs BuildSketch #385

Open MatthiasJ1 opened 7 months ago

MatthiasJ1 commented 7 months ago
from build123d import *

slot1 = SlotOverall(45, 38)
slot2 = SlotOverall(60, 4)

with BuildPart() as p1:
    with BuildSketch(): add(slot1)
    with BuildSketch(Plane.XY.offset(100)): add(slot2)
    loft()

with BuildPart() as p2:
    add(slot1)
    with BuildSketch(Plane.XY.offset(100)): add(slot2)
    loft()

s

Additionally, generating the part using in Algebra mode also gives a slightly different result.

loft([slot1, Pos(0,0,100)*slot2])

s2

gumyr commented 7 months ago

BuildSketch automatically orients all Faces so their normal's are "up" - in p2 add(slot1) doesn't do this so the normal is "down". The loft algorithm is sensitive to Face normals so the results are different because loft is working with different Faces. This is one of the weird things that the builders try to hide from the user but you've worked around that.

MatthiasJ1 commented 7 months ago

I checked and all of the normals are up. Either way, in testing your theory I tried all combinations of original and flipped face normals and the outcome is unchanged.