The polarLine()
method is a function in the Workplane
class of the CadQuery library, which allows you to create a sketch line that originates from a specified point and extends by a specified distance at a specified angle.
The syntax for the polarLine()
method is as follows:
polarLine(distance, angle)
Parameters:
distance
(float or int): The distance from the origin point to the endpoint of the line.angle
(float or int): The angle in degrees between the x-axis and the line.Both parameters are required for the function to work.
The polarLine()
method returns a Workplane
object that represents the sketch line.
To use the polarLine()
method, you must first create a Workplane
object that contains a point. You can then call the polarLine()
method on the Workplane
object, passing in the desired distance and angle.
For example, to create a horizontal line that extends 10 units from a point at (5,5), you could do the following:
import cadquery as cq
# Create a workplane object and add a point at (5,5)
w = cq.Workplane()
origin = (5,5)
w = w.center(origin)
# Create the polar line
line = w.polarLine(10, 0)
# Display the result
show_object(line)
This will display a horizontal line that extends 10 units from the point (5,5).
The polarLine()
method in CadQuery allows you to create sketch lines with ease by specifying a distance and angle from a point. This is a powerful feature that can greatly simplify the process of creating complex models in 3D CAD software.