mirror of
https://github.com/gumyr/build123d.git
synced 2025-12-06 02:30:55 -08:00
Updated with _get_context
This commit is contained in:
parent
ffc11acd90
commit
98acfc9ead
1 changed files with 69 additions and 75 deletions
|
|
@ -63,84 +63,78 @@ from build123d.build_common import (
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
||||||
# def extrude(
|
def extrude(
|
||||||
# to_extrude: Face = None,
|
to_extrude: Face = None,
|
||||||
# amount: float = None,
|
amount: float = None,
|
||||||
# until: Until = None,
|
until: Until = None,
|
||||||
# both: bool = False,
|
both: bool = False,
|
||||||
# taper: float = 0.0,
|
taper: float = 0.0,
|
||||||
# clean: bool = True,
|
clean: bool = True,
|
||||||
# mode: Mode = Mode.ADD,
|
mode: Mode = Mode.ADD,
|
||||||
# ):
|
):
|
||||||
# """Part Operation: Extrude
|
"""Part Operation: Extrude
|
||||||
|
|
||||||
# Extrude a sketch/face and combine with part.
|
Extrude a sketch/face and combine with part.
|
||||||
|
|
||||||
# Args:
|
Args:
|
||||||
# to_extrude (Face): working face, if not provided use pending_faces.
|
to_extrude (Face): working face, if not provided use pending_faces.
|
||||||
# Defaults to None.
|
Defaults to None.
|
||||||
# amount (float): distance to extrude, sign controls direction
|
amount (float): distance to extrude, sign controls direction
|
||||||
# Defaults to None.
|
Defaults to None.
|
||||||
# until (Until): extrude limit
|
until (Until): extrude limit
|
||||||
# both (bool, optional): extrude in both directions. Defaults to False.
|
both (bool, optional): extrude in both directions. Defaults to False.
|
||||||
# taper (float, optional): taper angle. Defaults to 0.
|
taper (float, optional): taper angle. Defaults to 0.
|
||||||
# clean (bool, optional): Remove extraneous internal structure. Defaults to True.
|
clean (bool, optional): Remove extraneous internal structure. Defaults to True.
|
||||||
# mode (Mode, optional): combination mode. Defaults to Mode.ADD.
|
mode (Mode, optional): combination mode. Defaults to Mode.ADD.
|
||||||
# """
|
"""
|
||||||
# if is_algcompound(to_extrude):
|
context: BuildPart = BuildPart._get_context(None)
|
||||||
# context = None
|
validate_inputs(context, None, [to_extrude])
|
||||||
# else:
|
|
||||||
# # context: BuildPart = BuildPart._get_context()
|
|
||||||
# context: BuildPart = BuildPart._current.get(None)
|
|
||||||
# # validate_inputs(context, self, sections)
|
|
||||||
# # context.validate_inputs(self, [to_extrude])
|
|
||||||
|
|
||||||
# new_solids: list[Solid] = []
|
new_solids: list[Solid] = []
|
||||||
# if not to_extrude and not context.pending_faces:
|
|
||||||
# context: BuildPart = BuildPart._get_context(self)
|
|
||||||
|
|
||||||
# if to_extrude:
|
if to_extrude:
|
||||||
# list_context = LocationList._get_context()
|
list_context = LocationList._get_context()
|
||||||
# workplane_context = WorkplaneList._get_context()
|
workplane_context = WorkplaneList._get_context()
|
||||||
# faces, face_planes = [], []
|
faces, face_planes = [], []
|
||||||
# for plane in workplane_context.workplanes:
|
for plane in workplane_context.workplanes:
|
||||||
# for location in list_context.local_locations:
|
for location in list_context.local_locations:
|
||||||
# faces.append(to_extrude.moved(location))
|
faces.append(to_extrude.moved(location))
|
||||||
# face_planes.append(plane)
|
face_planes.append(plane)
|
||||||
# else:
|
else:
|
||||||
# faces = context.pending_faces
|
faces = context.pending_faces
|
||||||
# face_planes = context.pending_face_planes
|
face_planes = context.pending_face_planes
|
||||||
# context.pending_faces = []
|
context.pending_faces = []
|
||||||
# context.pending_face_planes = []
|
context.pending_face_planes = []
|
||||||
|
|
||||||
# logger.info(
|
logger.info(
|
||||||
# "%d face(s) to extrude on %d face plane(s)",
|
"%d face(s) to extrude on %d face plane(s)",
|
||||||
# len(faces),
|
len(faces),
|
||||||
# len(face_planes),
|
len(face_planes),
|
||||||
# )
|
)
|
||||||
|
|
||||||
# for face, plane in zip(faces, face_planes):
|
for face, plane in zip(faces, face_planes):
|
||||||
# for direction in [1, -1] if both else [1]:
|
for direction in [1, -1] if both else [1]:
|
||||||
# if amount:
|
if amount:
|
||||||
# new_solids.append(
|
new_solids.append(
|
||||||
# Solid.extrude_linear(
|
Solid.extrude_linear(
|
||||||
# section=face,
|
section=face,
|
||||||
# normal=plane.z_dir * amount * direction,
|
normal=plane.z_dir * amount * direction,
|
||||||
# taper=taper,
|
taper=taper,
|
||||||
# )
|
)
|
||||||
# )
|
)
|
||||||
# else:
|
else:
|
||||||
# new_solids.append(
|
new_solids.append(
|
||||||
# Solid.extrude_until(
|
Solid.extrude_until(
|
||||||
# section=face,
|
section=face,
|
||||||
# target_object=context.part,
|
target_object=context.part,
|
||||||
# direction=plane.z_dir * direction,
|
direction=plane.z_dir * direction,
|
||||||
# until=until,
|
until=until,
|
||||||
# )
|
)
|
||||||
# )
|
)
|
||||||
|
|
||||||
# context._add_to_context(*new_solids, clean=clean, mode=mode)
|
if context is not None:
|
||||||
# super().__init__(Compound.make_compound(new_solids).wrapped)
|
context._add_to_context(*new_solids, clean=clean, mode=mode)
|
||||||
|
return Part(Compound.make_compound(new_solids).wrapped)
|
||||||
|
|
||||||
|
|
||||||
def loft(
|
def loft(
|
||||||
|
|
@ -160,7 +154,7 @@ def loft(
|
||||||
clean (bool, optional): Remove extraneous internal structure. Defaults to True.
|
clean (bool, optional): Remove extraneous internal structure. Defaults to True.
|
||||||
mode (Mode, optional): combination mode. Defaults to Mode.ADD.
|
mode (Mode, optional): combination mode. Defaults to Mode.ADD.
|
||||||
"""
|
"""
|
||||||
context: BuildPart = BuildPart._current.get(None)
|
context: BuildPart = BuildPart._get_context(None)
|
||||||
|
|
||||||
if not sections:
|
if not sections:
|
||||||
loft_wires = [face.outer_wire() for face in context.pending_faces]
|
loft_wires = [face.outer_wire() for face in context.pending_faces]
|
||||||
|
|
@ -209,7 +203,7 @@ def revolve(
|
||||||
Raises:
|
Raises:
|
||||||
ValueError: Invalid axis of revolution
|
ValueError: Invalid axis of revolution
|
||||||
"""
|
"""
|
||||||
context: BuildPart = BuildPart._current.get(None)
|
context: BuildPart = BuildPart._get_context(None)
|
||||||
|
|
||||||
# Make sure we account for users specifying angles larger than 360 degrees, and
|
# Make sure we account for users specifying angles larger than 360 degrees, and
|
||||||
# for OCCT not assuming that a 0 degree revolve means a 360 degree revolve
|
# for OCCT not assuming that a 0 degree revolve means a 360 degree revolve
|
||||||
|
|
@ -266,7 +260,7 @@ def section(
|
||||||
clean (bool, optional): Remove extraneous internal structure. Defaults to True.
|
clean (bool, optional): Remove extraneous internal structure. Defaults to True.
|
||||||
mode (Mode, optional): combination mode. Defaults to Mode.INTERSECT.
|
mode (Mode, optional): combination mode. Defaults to Mode.INTERSECT.
|
||||||
"""
|
"""
|
||||||
context: BuildPart = BuildPart._current.get(None)
|
context: BuildPart = BuildPart._get_context(None)
|
||||||
|
|
||||||
if context is not None and obj is None:
|
if context is not None and obj is None:
|
||||||
max_size = context.part.bounding_box().diagonal
|
max_size = context.part.bounding_box().diagonal
|
||||||
|
|
@ -326,7 +320,7 @@ def sweep(
|
||||||
clean (bool, optional): Remove extraneous internal structure. Defaults to True.
|
clean (bool, optional): Remove extraneous internal structure. Defaults to True.
|
||||||
mode (Mode, optional): combination. Defaults to Mode.ADD.
|
mode (Mode, optional): combination. Defaults to Mode.ADD.
|
||||||
"""
|
"""
|
||||||
context: BuildPart = BuildPart._current.get(None)
|
context: BuildPart = BuildPart._get_context(None)
|
||||||
|
|
||||||
if path is None:
|
if path is None:
|
||||||
path_wire = context.pending_edges_as_wire
|
path_wire = context.pending_edges_as_wire
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue