The PerpendicularDirSelector
class is a DirectionSelector
implementation that allows users to select a direction perpendicular to a specified reference direction.
PerpendicularDirSelector(reference_dir)
reference_dir
: The reference direction to which the selected direction will be perpendicular.get_directions(prompt)
This method prompts the user to select a direction perpendicular to the reference direction. The prompt string can be specified as an argument.
get_directions(prompt=None)
prompt
: (optional) The prompt string to display to the user.Returns a list of FreeCAD.Vector
objects representing the selected direction(s).
can_reverse()
This method returns True
if the selector allows reversing the selected direction, False
otherwise.
can_reverse()
Returns a boolean value.
reverse()
This method reverses the selected direction. The method has no effect if can_reverse()
returns False
.
reverse()
import cadquery as cq
# Define a box shape
box = cq.Workplane("XY").box(1, 1, 1)
# Define a reference direction perpendicular to the XY plane
ref_dir = cq.Vector(0, 0, 1)
# Initialize the selector with the reference direction
selector = cq.PerpendicularDirSelector(ref_dir)
# Prompt the user to select a direction perpendicular to the reference direction
dir = selector.get_directions("Select a direction perpendicular to the XY plane")
# Extrude the shape in the selected direction
result = box.extrude(dir)