Workplane.rect: test and document negative lengths (#774)
This commit is contained in:
@ -2491,10 +2491,8 @@ class Workplane(object):
|
||||
"""
|
||||
Make a rectangle for each item on the stack.
|
||||
|
||||
:param xLen: length in xDirection ( in workplane coordinates )
|
||||
:type xLen: float > 0
|
||||
:param yLen: length in yDirection ( in workplane coordinates )
|
||||
:type yLen: float > 0
|
||||
:param xLen: length in the x direction (in workplane coordinates)
|
||||
:param yLen: length in the y direction (in workplane coordinates)
|
||||
:param centered: If True, the rectangle will be centered around the reference
|
||||
point. If False, the corner of the rectangle will be on the reference point and
|
||||
it will extend in the positive x and y directions. Can also use a 2-tuple to
|
||||
@ -2511,6 +2509,9 @@ class Workplane(object):
|
||||
|
||||
Creates 4 circles at the corners of a square centered on the origin.
|
||||
|
||||
Negative values for xLen and yLen are permitted, although they only have an effect when
|
||||
centered is False.
|
||||
|
||||
Future Enhancements:
|
||||
* project points not in the workplane plane onto the workplane plane
|
||||
"""
|
||||
|
||||
@ -434,6 +434,27 @@ class TestCadQuery(BaseTest):
|
||||
)
|
||||
self.assertTupleAlmostEquals(v0, v1, 3)
|
||||
|
||||
# test negative lengths
|
||||
r0 = Workplane().rect(-x, -y, centered=False)
|
||||
self.assertTupleAlmostEquals(
|
||||
(0, 0, 0), r0.vertices(">X and >Y").val().toTuple(), 3
|
||||
)
|
||||
self.assertTupleAlmostEquals(
|
||||
(-x, -y, 0), r0.vertices("<X and <Y").val().toTuple(), 3
|
||||
)
|
||||
# test move plus negative length
|
||||
r1 = Workplane().move(x, y).rect(-x, -y, centered=False)
|
||||
self.assertTupleAlmostEquals(
|
||||
(x, y, 0), r1.vertices(">X and >Y").val().toTuple(), 3
|
||||
)
|
||||
self.assertTupleAlmostEquals(
|
||||
(0, 0, 0), r1.vertices("<X and <Y").val().toTuple(), 3
|
||||
)
|
||||
# negative length should have no effect with centered=True
|
||||
v2 = Workplane().rect(x, y).vertices(">X and >Y").val().toTuple()
|
||||
v3 = Workplane().rect(-x, -y).vertices(">X and >Y").val().toTuple()
|
||||
self.assertTupleAlmostEquals(v2, v3, 3)
|
||||
|
||||
def testLoft(self):
|
||||
"""
|
||||
Test making a lofted solid
|
||||
|
||||
Reference in New Issue
Block a user