import cadquery as cq #main cadquery library
from cadqueryhelper import shape # The shape library this document is about
part = shape.arrow() # Generate a solid using it's default values
cq.exporters.export(part,'stl/arrow.stl') # write the file to an stil file
if part.metadata:
print(part.metadata) # print the parts bounding box
The code above:
- Imports the required libraries.
- Generates a solid using default setting.
- Exports the solid to a file.
- Prints the parts metadata to the console.
Metadata / bounding box (Deprecated)
- Length is along the X axis
- Width is along the Y axis
- Height is along the Z axis
- Shapes are centered along the X, Y, and Z axis.
- length
- width
- height
- inner_height
result = shape.arch_pointed(
length=30,
width=5,
height=50,
inner_height=25
)
- length
- width
- height
result = shape.arch_round(length=30, width=5, height=50)
- length
- inner_length
- width
- width_outset
- height
result = shape.arrow(
length=10,
inner_length=5,
width=5,
width_outset=2,
height=3
)
result = shape.arrow(width_outset=-1)
- length:float = 200
- width:float = 250
- height:float = 150
- thickness:float = 4
- operation:str = 'fillet' #chamfer, fillet
- operation_dist:float = 20
import cadquery as cq
from cadqueryhelper.shape import backdrop
result = backdrop(
length = 200,
width = 250,
height = 150,
thickness = 2,
operation= 'fillet',#'chamfer', 'fillet', None
operation_dist = 20
)
- length
- width
- height
- inner_width
- alt
result = shape.chevron(
length=10,
width=7,
height=2,
inner_width=3,
alt=False
)
alt = shape.chevron(
length=10,
width=7,
height=2,
inner_width=3,
alt=True
)
- radius - base
- radius_top
- height
result = shape.cone(radius=1, radius_top=0, height=2)
- length - Length between the two mid points
- width - Distance between the top and base
- height - Extruded height of the face, can be falsy
- top_length - Length of the top
- base_length - Length of the base
- mid_offset - Middle points distance from the width center. Can be positive or negative.
result = shape.coffin(
length = 30,
width = 36,
height =10,
top_length = 20,
base_length = 20,
mid_offset = 5
)
- length
- width
- height
- cross_length
- cross_width
- x_translate - Distance of length crossbeam from center.
- y_translate - Distance of width crossbeam from center.
result = shape.cross(
length=10,
width=10,
height=2,
cross_length=1,
cross_width=1,
x_translate=0,
y_translate=0
)
result = shape.cross(
cross_length=2,
cross_width=2,
x_translate=-1,
y_translate=2.5
)
- length
- width
- height
- side_width = 1
- corner_chamfer = 0
chape = shape.corner_join(
length = 10,
width = 6,
height = 5,
side_width = 1,
corner_chamfer = 1
)
- length
- width
- height
result = shape.cube(length=5, width=5, height=5)
- radius
- height
result = shape.cylinder(radius=2.5, height=5)
- length
- width
- height
result = shape.diamond(length=10, width=5, height=3)
- length
- width
- height
- web_thickness
- flange_thickness
- join_distance
result = shape.i_beam(
length=30,
width=5,
height=10,
web_thickness=2,
flange_thickness=2,
join_distance=1.3
)
- width:float = 10,
- height:float = 10,
- base_height:float = 2,
- middle_width_inset:float = -2,
- middle_height:float = 2,
- top_width_inset:float = -1
import cadquery as cq
from cadqueryhelper.shape import jersey_barrier
result = jersey_barrier(
length=75,
width = 20,
height = 25,
base_height = 4,
middle_width_inset = -4,
middle_height = 2,
top_width_inset = -1
)
- length
- width
- height
- x_dist
- y_dist
result = shape.lightning(
length = 25,
width = 50,
height = 5,
x_dist = 3,
y_dist = 6
)
- count
- height
- ring_params - list of ring param dictionaries
- radius
- start_angle
ring_params = []
ring_params.append({"radius": 150, "start_angle":0})
ring_params.append({"radius":100,"start_angle":30})
ring_params.append({"radius":30,"start_angle":80})
result = shape.pinwheel(count = 10, height = 3, ring_params = ring_params)
- shape:cq.Workplane = cq.Workplane("XY").circle(5),
- pts:list[tuple[int,int]] = [(0,0), (20,-20), (50,-20), (50,-30)]
import cadquery as cq
from cadqueryhelper.shape import pipe
test_shape = cq.Workplane('XY').rect(4,8)
pst = pts = [(0,0), (20,-20), (50,-20), (50,-30)]
result = pipe(test_shape, pts)
![](image/shape/41.png)<br />
* [source](../src/cadqueryhelper/shape/pipe.py)
* [example](../example/shape/pipe.py)
* [stl](../stl/shape_pipe.stl)
- length
- width
- height
- inner_height
result = shape.rail(length=6, width=1, height=5, inner_height=1.5)
- radius
- sides
- height
result = shape.regular_polygon(radius=10, sides=6, height=5)
- width
- offset
- height
result = shape.rhombus(width=10, offset=4, height=5)
- radius
result = shape.sphere(radius=5)
- outer_radius
- inner_radius
- points
- height
result = shape.star(
outer_radius=10,
inner_radius=5,
points=5,
height=3
)
- length:float|None = 75
- width:float = 25
- height:float = 25
- top_width:float = 10
import cadquery as cq
from cadqueryhelper.shape import trapezoid
result = trapezoid(
length = 75,
width = 25,
height = 25,
top_width = 10
)
Note - if given a length of zero or None will instead return the trapezoid wires.
import cadquery as cq
from cadqueryhelper.shape import trapezoid
result = trapezoid(
length = None,
width = 25,
height = 25,
top_width = 10
)
- shape:cq.Workplane,
- workplane_axis:str = "YZ", #'XY', 'YZ', 'XZ'
- radius:float = 1,
- angle:float = 0,
- rotation_angle:float = 0
import cadquery as cq
from cadqueryhelper.shape import vase
from cadqueryhelper.wave import sine
shape_wave = sine(
length=80,
width=20,
height=0,
segment_length=15,
inner_width=5
)
result = vase(
shape_wave,
workplane_axis = "YZ",
radius = 10,
angle=0,
rotation_angle=0