Skip to content

Commit e5e0fef

Browse files
authored
Merge pull request #613 from marcus7070/wedge-center
Wedge center
2 parents 2e8d674 + be851aa commit e5e0fef

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

cadquery/cq.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3536,7 +3536,7 @@ def wedge(
35363536
yp -= dy / 2.0
35373537

35383538
if centered[2]:
3539-
zp -= dx / 2.0
3539+
zp -= dz / 2.0
35403540

35413541
w = Solid.makeWedge(dx, dy, dz, xmin, zmin, xmax, zmax, Vector(xp, yp, zp), dir)
35423542

tests/test_cadquery.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from random import choice
88
from random import random
99
from random import randrange
10+
from itertools import product
1011

1112
from pytest import approx, raises
1213

@@ -2069,6 +2070,22 @@ def testWedgeCentering(self):
20692070
self.assertEqual(1, s.solids().size())
20702071
self.assertEqual(5, s.faces().size())
20712072
self.assertEqual(5, s.vertices().size())
2073+
# check that the bottom corner is where we expect it for all possible combinations of centered
2074+
x, y, z = 10, 11, 12
2075+
b = [True, False]
2076+
expected_x = [-x / 2, 0]
2077+
expected_y = [-y / 2, 0]
2078+
expected_z = [-z / 2, 0]
2079+
for (xopt, xval), (yopt, yval), (zopt, zval) in product(
2080+
zip(b, expected_x), zip(b, expected_y), zip(b, expected_z)
2081+
):
2082+
s = (
2083+
Workplane()
2084+
.wedge(x, y, z, 2, 2, x - 2, z - 2, centered=(xopt, yopt, zopt))
2085+
.vertices("<X and <Y and <Z")
2086+
)
2087+
self.assertEqual(s.size(), 1)
2088+
self.assertTupleAlmostEquals(s.val().toTuple(), (xval, yval, zval), 3)
20722089

20732090
def testWedgePointList(self):
20742091
s = (

0 commit comments

Comments
 (0)