gumyr / build123d

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

Better error checking #13

Closed gumyr closed 1 year ago

gumyr commented 1 year ago
with BuildPart() as hole:
    Rectangle(small, small, mode=Mode.ADD)

Classes should check to see if they are in the appropriate context.

with BuildSketch() as hole:
    Rectangle(small, small, mode=Mode.ADD)
    with Locations((25, 0)):
        Rectangle(tiny, tiny, mode=Mode.SUBTRACT)

with BuildPart() as part2:
    with BuildSketch() as outline:
        Rectangle(large, large, mode=Mode.ADD)
        Add(hole, mode=Mode.SUBTRACT)
    Extrude(amount=5)

_add_to_context should check to see if an instance of the Builder has been passed in and raise an exception with something like: "did you mean .sketch?"

gumyr commented 1 year ago

_add_to_context should also look for Iterators as input and return something like "did you mean *".

gumyr commented 1 year ago

Closed with commit: https://github.com/gumyr/build123d/commit/148e971e70a70d28cf2a7c2e814ca20c23c06ed3