cadquery:svg

Examples of the cadquery:svg directive.

Development Status

Development Status:

2 - Pre-Alpha

This directive is experimental.

cadquery:svg is based on the docutils “figure” directive having similar features and syntax:

  • The image may be captioned.

  • Notes may be added below the code block.

  • Images may be referenced by name: include from file example.

The image source code is defined in either a code-block or literalinclude, meaning:

Tip

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

Simple rectangular plate

A rectangular plate

A simple rectangular plate measuring 2 × 2 × 0.5 mm.

1"""Simple rectangular plate."""
2
3import cadquery as cq
4
5result = cadquery.Workplane().box(2, 2, 0.5)

Notes:

  1. Line numbers are added with linenos.

  2. Line number 5 is emphasized with emphasize-lines.

Pillow block

SVG image exported by CadQuery.

A pillow block.

(length, height, diam, thickness, padding) = (30.0, 40.0, 22.0, 10.0, 8.0)

pillow_block = (
    cq.Workplane()
    .box(length, height, thickness)
    .faces(">Z")
    .workplane()
    .hole(diam)
    .faces(">Z")
    .workplane()
    .rect(length - padding, height - padding, forConstruction=True)
    .vertices()
    .cboreHole(2.4, 4.4, 2.1)
)

show_object(pillow_block)

Source from file

SVG image exported by CadQuery.

A simple rectangular plate measuring 2 × 2 × 0.5 mm.

"""Simple rectangular plate."""

import cadquery

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

Content variations

Code block: without caption or source

SVG image exported by CadQuery.

Code block: with both caption and source

SVG image exported by CadQuery.

A simple rectangular plate measuring 2 × 2 × 0.5 mm.

"""Simple rectangular plate."""

import cadquery as cq

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

Code block: with caption, source, and notes

SVG image exported by CadQuery.

A simple rectangular plate measuring 2 × 2 × 0.5 mm.

"""Simple rectangular plate."""

import cadquery as cq

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

Notes may follow the code-block.

  1. The model source code is loaded from a code-block directive.

  2. The model is captioned.

  3. The model source code is displayed.

  4. These are notes.

Source from file: without caption or source

SVG image exported by CadQuery.

Source from file: with both caption and source

SVG image exported by CadQuery.

A simple rectangular plate measuring 2 × 2 × 0.5 mm.

"""Simple rectangular plate."""

import cadquery

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

Source from file: with caption, source, and notes

SVG image exported by CadQuery.

A simple rectangular plate measuring 2 × 2 × 0.5 mm.

"""Simple rectangular plate."""

import cadquery

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

Notes may follow the literalinclude.

Material:

stainless steel

Finish:

brushed