cadquery-vtk

Examples of the cadquery-vtk directive.

Tip

View the reStructuredText source of this page by following the View page source link in the header.

Simple rectangular plate

roll
MB1
pan
MB2
zoom
MB3
rotate
shift+MB1
result = cadquery.Workplane().box(2, 2, 0.5)

Assembly

roll
MB1
pan
MB2
zoom
MB3
rotate
shift+MB1
cone = cq.Solid.makeCone(1, 0, 2)

assembly = cq.Assembly()
assembly.add(
    cone,
    loc=cq.Location((0, 0, 0), (1, 0, 0), 180),
    name="cone0",
    color=cq.Color("green"),
)
assembly.add(cone, name="cone1", color=cq.Color("blue"))

show_object(assembly)

Sketch

roll
MB1
pan
MB2
zoom
MB3
rotate
shift+MB1
import cadquery as cq

result = (
    cq.Sketch()
    .trapezoid(4, 3, 90)
    .vertices()
    .circle(0.5, mode="s")
    .reset()
    .vertices()
    .fillet(0.25)
    .reset()
    .rarray(0.6, 1, 5, 1)
    .slot(1.5, 0.4, mode="s", angle=90)
)

Source from file

roll
MB1
pan
MB2
zoom
MB3
rotate
shift+MB1
"""Simple rectangular plate."""

import cadquery

result = cadquery.Workplane().box(2, 2, 0.5)

Options

Default color

The color option defines the default color of the VTK.js render.

roll
MB1
pan
MB2
zoom
MB3
rotate
shift+MB1
result = cadquery.Workplane().box(2, 2, 0.5)

Size and alignment

Set the size using the width and height options.

Set horizontal alignment using the align option.

Center

roll
MB1
pan
MB2
zoom
MB3
rotate
shift+MB1
result = cadquery.Workplane().box(2, 2, 0.5)

Align left

roll
MB1
pan
MB2
zoom
MB3
rotate
shift+MB1
result = cadquery.Workplane().box(2, 2, 0.5)

Align right

roll
MB1
pan
MB2
zoom
MB3
rotate
shift+MB1
result = cadquery.Workplane().box(2, 2, 0.5)