Skip to content

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, not layer.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.

ModulePurposeDocumentation
linkcad.v1.pluginPlugin framework — decorators, options, reader/writer base classes, DrawingBuilder, WriterController, dialog specsPlugin development
linkcad.v1.dbDrawing database — cells, layers, shapes, curves, text, locks, transactions, drawing helpersData access
linkcad.v1.geomGeometry primitives — points, vectors, transforms, bounds, anglesCoordinate math
linkcad.v1.editGeometry tasks — merge, flatten, snap, join, explodeBatch operations
linkcad.v1.envOptions and logging — read/write persistent options, event logSettings & diagnostics
linkcad.v1.convFile format conversion — load and save drawings programmaticallyFormat I/O
linkcad.v1.libgraphBoolean geometry engine — union, intersection, difference on polygonsShape math
linkcad.v1.controllerConversion workflow controller — full wizard pipelineHigh-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 framework
from linkcad.v1.plugin import tool, Tool, Option, TableColumn
from linkcad.v1.plugin import format_reader, FormatReader, DrawingContext, DrawingBuilder
from linkcad.v1.plugin import format_writer, FormatWriter, WriterContext, ShapeInfo, WriterController
from linkcad.v1.plugin import DialogSpec, ChoiceItem, EventLog, Phase, LayerFlags, SortOrder
from linkcad.v1.plugin import HolesMode, PolygonType, EndCap, FillRule, UNIT_IN_METERS
# Database
from linkcad.v1.db import Drawing, Cell, Layer, Shape, Polygon, Polyline
from linkcad.v1.db import Arc, Ellipse, Donut, Nurbs, Text, Ref
from linkcad.v1.db import Object, DrawingObject, CellObject, Color, Property
from linkcad.v1.db import ReadLock, WriteLock, Transaction
from linkcad.v1.db import Unit, ObjectType, CellContext, EndCap, FillRule
from linkcad.v1.db import BooleanOperation, MergeLayerPolarityResult
# Geometry
from linkcad.v1.geom import Point, Vector, Bounds, Transformation, Angle, Resolution
# Edit tasks
from linkcad.v1.edit import MergeTask, FlattenTask, FillRule, HolesMode, ShapesToConvert
from linkcad.v1.edit import CellFilter, LayerFilter, ShapeFilter
# Options & logging
from linkcad.v1.env import get_option_boolean, set_option_boolean, EventLog, Severity
# File conversion
from linkcad.v1.conv import Conversion, Conversions, FormatRegistry, FormatInfo
from linkcad.v1.conv import Format, FormatAttributes
# Boolean geometry
from linkcad.v1.libgraph import boolean_and, boolean_or, ShapeProcessor, succeeded
# Conversion controller
from linkcad.v1.controller import ConversionController, ConversionState, ProgressInfo