API Reference
The LinkCAD Python API is organized into the following modules, all accessible through the stable linkcad.v1 namespace. Each linkcad.v1.* module mirrors the whole public namespace of the matching top-level module, so the objects are the same ones; importing from v1 pins your script to the stable surface.
linkcad and linkcad.v1 publish these modules and nothing else — there are no names at the top level, because the modules’ contents collide. See Package Structure.
Four conventions run through the whole API, in every module:
- A noun is a property, a verb is a method.
shape.area,cell.shapes,drawing.layers,bounds.width,task.progress,log.entry_count,conversion.succeeded— no parentheses.destroy(),clone(),rotate(),mark_fatal()keep theirs. - A getter/setter pair is one read-write property, never two names.
layer.enabled = False, notlayer.enable(False). - Geometry is created by the object that will own it.
drawing.add_cell(name),drawing.add_layer(name),cell.add_polygon(layer, vertices),cell.add_ref(cell). There are no static factories. - Where an accessor takes parameters, the property covers the common case and a
filtered_*method exposes the rest:cell.shapes/cell.filtered_shapes(selected_only=True),controller.layers/controller.filtered_layers(sort_order=…).
Enum members are always reached through their type — EndCap.Round, HolesMode.Link — never as bare module attributes.
| Module | Purpose | Documentation |
|---|---|---|
linkcad.v1.plugin | Plugin framework — decorators, options, reader/writer base classes, DrawingBuilder, WriterController, dialog specs | Plugin development |
linkcad.v1.db | Drawing database — cells, layers, shapes, curves, text, locks, transactions, drawing helpers | Data access |
linkcad.v1.geom | Geometry primitives — points, vectors, transforms, bounds, angles | Coordinate math |
linkcad.v1.edit | Geometry tasks — merge, flatten, snap, join, explode | Batch operations |
linkcad.v1.env | Options and logging — read/write persistent options, event log | Settings & diagnostics |
linkcad.v1.conv | File format conversion — load and save drawings programmatically | Format I/O |
linkcad.v1.libgraph | Boolean geometry engine — union, intersection, difference on polygons | Shape math |
linkcad.v1.controller | Conversion workflow controller — full wizard pipeline | High-level conversion |
Import Patterns
Import the module and reach through it:
from linkcad.v1 import db, geom, edit, env, conv, libgraph, controller, plugin
with db.Drawing("scratch") as dwg: cell = dwg.add_cell("TOP") cell.add_polygon(dwg.add_layer("METAL1"), [(0, 0), (100, 0), (100, 100)])Or import the names you use:
# Plugin frameworkfrom linkcad.v1.plugin import tool, Tool, Option, TableColumnfrom linkcad.v1.plugin import format_reader, FormatReader, DrawingContext, DrawingBuilderfrom linkcad.v1.plugin import format_writer, FormatWriter, WriterContext, ShapeInfo, WriterControllerfrom linkcad.v1.plugin import DialogSpec, ChoiceItem, EventLog, Phase, LayerFlags, SortOrderfrom linkcad.v1.plugin import HolesMode, PolygonType, EndCap, FillRule, UNIT_IN_METERS
# Databasefrom linkcad.v1.db import Drawing, Cell, Layer, Shape, Polygon, Polylinefrom linkcad.v1.db import Arc, Ellipse, Donut, Nurbs, Text, Reffrom linkcad.v1.db import Object, DrawingObject, CellObject, Color, Propertyfrom linkcad.v1.db import ReadLock, WriteLock, Transactionfrom linkcad.v1.db import Unit, ObjectType, CellContext, EndCap, FillRulefrom linkcad.v1.db import BooleanOperation, MergeLayerPolarityResult
# Geometryfrom linkcad.v1.geom import Point, Vector, Bounds, Transformation, Angle, Resolution
# Edit tasksfrom linkcad.v1.edit import MergeTask, FlattenTask, FillRule, HolesMode, ShapesToConvertfrom linkcad.v1.edit import CellFilter, LayerFilter, ShapeFilter
# Options & loggingfrom linkcad.v1.env import get_option_boolean, set_option_boolean, EventLog, Severity
# File conversionfrom linkcad.v1.conv import Conversion, Conversions, FormatRegistry, FormatInfofrom linkcad.v1.conv import Format, FormatAttributes
# Boolean geometryfrom linkcad.v1.libgraph import boolean_and, boolean_or, ShapeProcessor, succeeded
# Conversion controllerfrom linkcad.v1.controller import ConversionController, ConversionState, ProgressInfo