Moved extrude until previous/first to extrude_until method

This commit is contained in:
Roger Maitland 2023-05-16 09:07:03 -04:00
parent 76dd8cd801
commit 70e0c14da8
2 changed files with 4 additions and 5 deletions

View file

@ -110,15 +110,11 @@ def extrude(
for face in to_extrude_faces
]
flip_direction = 1
if until is not None:
if target is None and context is None:
raise ValueError("A target object must be provided")
if target is None:
target = context.part
if until in [Until.PREVIOUS, Until.FIRST]:
flip_direction = -1
until = Until.NEXT if until == Until.PREVIOUS else Until.LAST
logger.info(
"%d face(s) to extrude on %d face plane(s)",
@ -141,7 +137,7 @@ def extrude(
Solid.extrude_until(
section=face,
target_object=target,
direction=plane.z_dir * direction * flip_direction,
direction=plane.z_dir * direction,
until=until,
)
)

View file

@ -5326,6 +5326,9 @@ class Solid(Shape, Mixin3D):
Union[Compound, Solid]: extruded Face
"""
direction = Vector(direction)
if until in [Until.PREVIOUS, Until.FIRST]:
direction *= -1
until = Until.NEXT if until == Until.PREVIOUS else Until.LAST
max_dimension = (
Compound.make_compound([section, target_object]).bounding_box().diagonal