Sheets & Views
📄 DrawingSheet & ISO 5457 Borders
The DrawingSheet class manages paper-space dimensions, margins, title blocks, revision tables, and views.
Standard Sheet Sizes
SheetSize enum supports standard ISO 216 paper sizes in both portrait and landscape:
SheetSize.A0_LANDSCAPE,SheetSize.A0_PORTRAIT(\(1189 \times 841\text{ mm}\))SheetSize.A1_LANDSCAPE,SheetSize.A1_PORTRAIT(\(841 \times 594\text{ mm}\))SheetSize.A2_LANDSCAPE,SheetSize.A2_PORTRAIT(\(594 \times 420\text{ mm}\))SheetSize.A3_LANDSCAPE,SheetSize.A3_PORTRAIT(\(420 \times 297\text{ mm}\))SheetSize.A4_LANDSCAPE,SheetSize.A4_PORTRAIT(\(297 \times 210\text{ mm}\))
from build123d_techdraw import DrawingSheet, SheetSize
sheet = DrawingSheet(
sheet_size=SheetSize.A3_LANDSCAPE,
left_margin=20.0, # 20mm left margin for binder punching (ISO standard)
right_margin=10.0,
top_margin=10.0,
bottom_margin=10.0,
)
Centering Marks & Alphanumeric Grid Zones
DrawingSheet automatically generates:
- Centering marks at the midpoint of each border (ISO 5457).
- Alphanumeric grid zones (\(A\)–\(H\) vertically, \(1\)–\(8\) horizontally) along the inner frame to facilitate coordinates referencing in large assemblies.
🪟 SheetView & Projections
A SheetView represents a 2D orthographic or isometric projection placed onto a sheet.
View Types
ViewType.FRONT: Projection along \(+Y\)ViewType.TOP: Projection along \(+Z\)ViewType.RIGHT: Projection along \(+X\)ViewType.LEFT: Projection along \(-X\)ViewType.BOTTOM: Projection along \(-Z\)ViewType.REAR: Projection along \(-Y\)ViewType.ISOMETRIC: Standard trimetric/isometric perspective (\(1.2, 1.8, 1.2\))ViewType.SECTION: Planar cross-section cut with engineering hatchingViewType.FLAT_PATTERN: Unfolded 2D sheet metal blank with bend & punch metadata
Adding Views Manually
# Add Front view centered at (150 mm, 120 mm)
view_front = sheet.add_view(
shape=part,
view_type=ViewType.FRONT,
center=(150.0, 120.0),
scale=1.0,
show_hidden=True, # Dotted lines for hidden contours
view_label="FRONT",
)
GPU Shading Styles & Visibility-Buffer HLR
Every view factory (sheet.add_view, FrontView, IsometricView, etc.) also accepts optional WebGPU shading and HLR parameters when build123d-techdraw[gpu] is installed:
from build123d_techdraw.gpu import ViewStyle
iso_view = sheet.add_view(
shape=assembly,
view_type=ViewType.ISOMETRIC,
center=(320.0, 110.0),
scale=0.5,
style=ViewStyle.GOOCH, # WIREFRAME | SHADED | SHADED_WITH_EDGES | GOOCH | TOON | BLUEPRINT_SHADED | XRAY
ssao=True,
hlr="auto", # "exact" (OCCT default) | "gpu" (visibility buffer) | "auto"
)
See GPU & Shaders for all ViewStyle modes, hlr_resolution, and hlr_gpu_face_threshold.
Adding Section Views with 45° Cross-Hatching
import build123d as bd
# Slice through part along XZ plane at Y=0
section_view = sheet.add_section_view(
shape=part,
cutting_plane=bd.Plane.XZ,
center=(280.0, 120.0),
scale=1.0,
view_label="SECTION A-A",
)
Half-Section Views & Turned / Shaft Component Mode (ISO 128-3 / ISO 129-1 / DIN 509)
For symmetrical lathe-turned components (shafts, spindles, bushings, sleeves), HalfSectionView
renders one half as a hatched longitudinal section and the opposite half as an external elevation
without hidden lines, separated cleanly along the axis of symmetry:
from build123d_techdraw import BuildDrawing, SheetSize, TurnedPartLayout
with BuildDrawing(SheetSize.A3_LANDSCAPE) as sheet:
# Automatically detects the revolution axis (X, Y, or Z), lays the shaft out
# horizontally, creates an ISO 128-3 half-section + optional end view, and places
# centerline half-dimensions, axial lengths, chamfer callouts, and DIN 509 undercuts.
TurnedPartLayout(
shaft,
section_mode="auto", # "half_section" if bored, else "external"
include_end_view="auto", # True / False / "auto"
auto_dimensions=True,
half_diameters=True,
)
In Algebraic mode, use add_turned_part_views(sheet, shaft, ...) or sheet.add_half_section_view(...)
followed by view.auto_dimension_turned().
Broken Views (ISO 128-3)
view.add_break(interval=(lo, hi), axis="X", style="zigzag", gap=10.0) cuts a span out of a long
part. interval is in absolute model coordinates, the same frame as to_sheet_x / to_sheet_y:
a 400 mm rod centred on the origin runs from -200 to 200, so interval=(-130.0, 130.0) keeps
70 mm at each end. Dimensions across the break still show the true length, with the
dimension-line jog at the gap and the text moved clear of it.
rod_view = sheet.add_view(tie_rod, ViewType.FRONT, center=(430.0, 180.0), scale=0.8)
rod_view.add_break(interval=(-130.0, 130.0), axis="X", style="zigzag", gap=10.0)
A view can have several breaks on one axis ("X" or "Y"). add_break raises ValueError if
the interval is not strictly inside the part, is no longer on paper than gap, overlaps another
break, or uses a different axis from the view's existing breaks.
Updating the Model (update_shape)
When the part changes, sheet.update_shape(new_part) re-projects every view and re-binds
anchored annotations to the new geometry:
- Each view is rebuilt from the parameters it was created with: section cut plane or path,
hatch, auxiliary direction, an explicit
model_originand the label position. The view's current position and scale are kept, including anylocate,align_toorscale_to. - Detail views follow their parent view. They are re-cut from the parent after it updates.
- Space that dimensions reserved below a view is kept and moves with the view's new bottom edge.
- A section, detail or auxiliary
SheetViewbuilt by hand has no recorded parameters. In that caseupdate_shaperaisesValueErrorand changes no views. Check withview.can_regenerate().
Sheet Metal Flat Patterns (FlatPatternView & FlatPatternLayout)
Unfold a 3D build123d sheet metal part directly into a 2D flat pattern view with UP/DOWN bend
centerlines, DIN 6935 bend allowances, punch tooling markers, and manufacturing schedules:
from build123d_techdraw import BuildDrawing, FlatPatternLayout, SheetSize, TitleBlock
with BuildDrawing(SheetSize.A3_LANDSCAPE) as sheet:
TitleBlock(title="MOUNTING BRACKET", drawing_no="SM-402", material="AL 5052-H32")
layout = FlatPatternLayout(
bracket_part,
k_factor="din6935",
include_formed_iso=True,
include_bend_table=True,
include_punch_table=True,
auto_dimensions=True,
)
# Export 1:1 CNC laser/punch DXF (CUT_OUTER, CUT_INNER, BEND_UP, BEND_DOWN, PUNCH, ETCH)
sheet.export_dxf("bracket_flat.dxf", flat_pattern=True)
For manual view placement, use FlatPatternView(bracket_part, center=(150, 140), scale=1.0) or
sheet.add_flat_pattern(...). Both FlatPatternView and FlatPatternLayout support Builder
and Algebraic (+=) modes as well as update_shape().
🏗️ Builder Mode vs Algebraic Mode
build123d-techdraw supports both build123d programming paradigms:
Builder Mode (BuildDrawing)
with BuildDrawing(SheetSize.A3_LANDSCAPE) as sheet:
TitleBlock(title="BRACKET", drawing_no="DWG-001")
GeneralNotes(["1. ALL DIMENSIONS IN MM."])
with FrontView(part, center=(130, 150), scale=1.0) as front:
CenterMark(hole_face)
LinearDimension(part.edges().filter_by(bd.Axis.Z)[0], offset=-15.0)
with TopView(part, center=(130, 230), scale=1.0):
LinearDimension(v_min, v_max, offset=15.0, direction="horizontal")
with IsometricView(part, center=(320, 190), scale=0.8):
pass
BuildDrawing is a DrawingSheet subclass: inside or after the with block, use it directly
(sheet.to_svg(), sheet.lint(), booklet.add_sheet(sheet)).
Algebraic Mode
sheet = DrawingSheet(SheetSize.A3_LANDSCAPE)
sheet += TitleBlock(title="BRACKET", drawing_no="DWG-001")
front = FrontView(part, scale=1.0).locate((130, 150))
top = TopView(part, scale=1.0).align_to(front, direction="below", spacing=25.0)
iso = IsometricView(part, scale=0.8).align_to(front, direction="right", spacing=50.0)
front += [
CenterMark(hole_face),
LinearDimension(part.edges().filter_by(bd.Axis.Z)[0], offset=-15.0),
]
top += LinearDimension(v_min, v_max, offset=15.0, direction="horizontal")
sheet += [front, top, iso]
What += Accepts
view += ... takes an Annotation (every dimension, callout, symbol and table derives from
build123d_techdraw.Annotation) or an iterable of them. sheet += ... additionally takes a
SheetView, a TitleBlockInfo, or a SheetDirective (TitleBlock, GeneralNotes, Revision,
AssemblyBOM, MultiviewLayout). Anything else is a type error, and raises TypeError at
runtime.
Custom Annotations
Subclass Annotation and implement to_svg() (paper-space mm, theme CSS variables). Override
bounding_box_2d() so the sheet linter and auto-dimension collision checks can see it, and
_attach_to_view() if it needs to resolve anchors against the view before registering:
from build123d_techdraw import Annotation
class RevisionCloud(Annotation):
def __init__(self, x: float, y: float, r: float) -> None:
self.x, self.y, self.r = x, y, r
def to_svg(self) -> str:
return f'<circle cx="{self.x}" cy="{self.y}" r="{self.r}" class="dim-line" fill="none"/>'
def bounding_box_2d(self) -> tuple[float, float, float, float]:
return (self.x - self.r, self.y - self.r, self.x + self.r, self.y + self.r)
front += RevisionCloud(120.0, 80.0, 6.0)
🏢 Custom Corporate Title Blocks & Sheet Templates
SheetTemplate imports existing corporate SVG or DXF templates and binds dynamic metadata placeholders (${TITLE}, ${DWG_NO}, ${REV}, ${MATERIAL}, ${SHEET}, custom fields) across SVG, PDF, DXF, and interactive HTML exports.
Template Modes (TemplateMode)
TemplateMode.SHEET(auto-inferred whenwidth_mm >= 200andheight_mm >= 180): Replaces the built-in ISO 5457 border/grid and ISO 7200 title block with the full imported corporate sheet.TemplateMode.TITLE_BLOCK(auto-inferred for smaller title-block-only templates): Keeps the sheet's standard ISO 5457 border/grid and replaces only the title block, anchored atbottom_right(default),bottom_left,top_right,top_left, or an explicitposition=(x, y).
Loading SVG, DXF, FreeCAD & AutoCAD Templates
from build123d_techdraw import BuildDrawing, SheetTemplate, StandardMultiview, TitleBlock
# Auto-dispatches .svg or .dxf by file extension
tpl = SheetTemplate.from_file(
"corporate_a3.dxf", # or .svg / SheetTemplate.from_svg(xml_string)
margins=(15.0, 8.0, 8.0, 8.0),
defaults={"COMPANY": "APEX MOTION", "CHECKED_BY": "M. KOWALSKI"},
)
# Builder Mode
with BuildDrawing(template=tpl) as sheet:
TitleBlock(
title="SERVO ACTUATOR FLANGE",
drawing_no="AMX-402-01",
rev="C",
material="AL 7075-T651",
fields={"ERP_CODE": "104-8821-03"},
)
StandardMultiview(part, scale="auto", auto_dimensions=True)
In Algebraic Mode, pass template=tpl to DrawingSheet(template=tpl), call DrawingSheet.from_template(tpl), or attach it with sheet += tpl. Templates are reusable across multiple sheets and DrawingBooklet packages, automatically updating ${SHEET}, ${SHEET_NO}, and ${TOTAL_SHEETS} per page.
Dynamic Placeholders, FreeCAD freecad:editable, & DXF ATTDEF / ATTRIB
- Placeholders:
${KEY}and inline fallbacks${KEY:-default}resolve case- and punctuation-insensitively (${DWG_NO},${DRAWING NO.},${Drawn-By},${PROJECTION},${SHEET_SIZE}, plus any custom keys inTitleBlockInfo.fieldsortemplate.defaults). - FreeCAD TechDraw SVG templates: Elements carrying
freecad:editable="KEY"are recognized and bound automatically. - AutoCAD DXF templates:
ATTDEF/ATTRIBblock attributes insideINSERTtitle blocks (withbind_dxf_attributes=True), multi-lineMTEXT,$INSUNITSscaling, andSOLID/HATCH/LWPOLYLINE/ARC/ELLIPSE/SPLINEentities are translated directly to paper-space vectors. - Dynamic projection cone slot: Add
data-techdraw="projection_symbol"to a<rect>/<g>(or${PROJECTION_SYMBOL}text) to render the ISO 5456-2 first-angle or third-angle projection symbol matchingTitleBlockInfo.third_angle. - Theme adaptation: With
theme_adapt=True(default), neutral monochrome strokes/fills adapt to bothTheme.DARK_BLUEPRINTandTheme.ISO_WHITE, while chromatic corporate logo and accent colors remain untouched.