Skip to content

Commit

Permalink
Add sketch solver test for issue CadQuery#1127
Browse files Browse the repository at this point in the history
  • Loading branch information
voneiden committed May 20, 2023
1 parent f1533ba commit baa3786
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions tests/test_sketch.py
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,41 @@ def test_constraint_solver():

assert s7._faces.isValid()

# Issue #1127 with Distance constraint providing invalid result
constrained_distance = 2
s8 = (
# Two segments that have a distance of 1
Sketch()
.segment((1, 2), (2, 2), "top")
.segment((2, 2), (2, 1), "right")
.segment((2, 1), (1, 1), "bottom")
.segment((1, 1), (1, 2), "left")
)
s8.constrain("bottom", "FixedPoint", 0)
s8.constrain("top", "Orientation", (1, 0))
s8.constrain("right", "Orientation", (0, -1))
s8.constrain("bottom", "Orientation", (-1, 0))
s8.constrain("left", "Orientation", (0, 1))

s8.constrain("top", "right", "Coincident", None)
s8.constrain("right", "bottom", "Coincident", None)
s8.constrain("bottom", "left", "Coincident", None)
s8.constrain("left", "top", "Coincident", None)

s8.constrain("top", "bottom", "Distance", (0.5, 0.5, constrained_distance))
s8.constrain("left", "right", "Distance", (0.5, 0.5, constrained_distance))
s8.solve()

assert s8._solve_status["status"] == 4

s8.assemble()
assert s8._faces.isValid()

# 2x2=4
assert s8._faces.Area() == approx(4)




def test_dxf_import():

Expand Down

0 comments on commit baa3786

Please sign in to comment.