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
result = cadquery.Workplane().box(2, 2, 0.5)
Assembly
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
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
"""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.
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
result = cadquery.Workplane().box(2, 2, 0.5)
Align left
result = cadquery.Workplane().box(2, 2, 0.5)
Align right
result = cadquery.Workplane().box(2, 2, 0.5)