cadquery-freecad-module/Examples/Ex005_Extruded_Lines_and_Arcs.py
2017-09-15 22:13:39 -04:00

33 lines
1.7 KiB
Python

import cadquery as cq
# These can be modified rather than hardcoding values for each dimension.
width = 2.0 # Overall width of the plate
thickness = 0.25 # Thickness of the plate
# Extrude a plate outline made of lines and an arc
# 1. Establishes a workplane that an object can be built on.
# 1a. Uses the named plane orientation "front" to define the workplane, meaning
# that the positive Z direction is "up", and the negative Z direction
# is "down".
# 2. Draws a line from the origin to an X position of the plate's width.
# 2a. The starting point of a 2D drawing like this will be at the center of the
# workplane (0, 0) unless the moveTo() function moves the starting point.
# 3. A line is drawn from the last position straight up in the Y direction
# 1.0 millimeters.
# 4. An arc is drawn from the last point, through point (1.0, 1.5) which is
# half-way back to the origin in the X direction and 0.5 mm above where
# the last line ended at. The arc then ends at (0.0, 1.0), which is 1.0 mm
# above (in the Y direction) where our first line started from.
# 5. close() is called to automatically draw the last line for us and close
# the sketch so that it can be extruded.
# 5a. Without the close(), the 2D sketch will be left open and the extrude
# operation will provide unpredictable results.
# 6. The 2D sketch is extruded into a solid object of the specified thickness.
result = cq.Workplane("front").lineTo(width, 0) \
.lineTo(width, 1.0) \
.threePointArc((1.0, 1.5), (0.0, 1.0)) \
.close().extrude(thickness)
# Displays the result of this script
show_object(result)