Skip to content

Commit

Permalink
Fixing Issue #475
Browse files Browse the repository at this point in the history
  • Loading branch information
gumyr committed Jun 12, 2024
1 parent f469937 commit ad55863
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 25 deletions.
15 changes: 3 additions & 12 deletions src/build123d/operations_part.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,8 @@ def revolve(
"""Part Operation: Revolve
Revolve the profile or pending sketches/face about the given axis.
Note that the most common use case is when the axis is in the same plane as the
face to be revolved but this isn't required.
Args:
profiles (Face, optional): 2D profile(s) to revolve.
Expand Down Expand Up @@ -460,18 +462,7 @@ def revolve(
p_list.extend(profile.faces())
profile_list = p_list

new_solids = []
for profile in profile_list:
# axis origin must be on the same plane as profile
face_plane = Plane(profile)
if not face_plane.contains(axis.position):
raise ValueError(
"axis origin must be on the same plane as the face to revolve"
)
if not face_plane.contains(axis):
raise ValueError("axis must be in the same plane as the face to revolve")

new_solids.append(Solid.revolve(profile, angle, axis))
new_solids = [Solid.revolve(profile, angle, axis) for profile in profile_list]

new_solid = Compound(new_solids)
if context is not None:
Expand Down
28 changes: 15 additions & 13 deletions tests/test_build_part.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,19 +412,21 @@ def test_revolve_with_axis(self):
self.assertLess(test.part.volume, 244 * pi * 20, 5)
self.assertGreater(test.part.volume, 100 * pi * 20, 5)

def test_invalid_axis_origin(self):
with BuildPart():
with BuildSketch():
Rectangle(1, 1, align=(Align.MIN, Align.MIN))
with self.assertRaises(ValueError):
revolve(axis=Axis((1, 1, 1), (0, 1, 0)))

def test_invalid_axis_direction(self):
with BuildPart():
with BuildSketch():
Rectangle(1, 1, align=(Align.MIN, Align.MIN))
with self.assertRaises(ValueError):
revolve(axis=Axis.Z)
# Invalid test
# def test_invalid_axis_origin(self):
# with BuildPart():
# with BuildSketch():
# Rectangle(1, 1, align=(Align.MIN, Align.MIN))
# with self.assertRaises(ValueError):
# revolve(axis=Axis((1, 1, 1), (0, 1, 0)))

# Invalid test
# def test_invalid_axis_direction(self):
# with BuildPart():
# with BuildSketch():
# Rectangle(1, 1, align=(Align.MIN, Align.MIN))
# with self.assertRaises(ValueError):
# revolve(axis=Axis.Z)


class TestSection(unittest.TestCase):
Expand Down

0 comments on commit ad55863

Please sign in to comment.