API Reference
The LinkCAD Python API is organized into the following modules, all accessible through the stable linkcad.v1 namespace. The current Python plugin and database additions are part of v1, so scripts should continue to import from linkcad.v1.*.
| 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
# 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, WriterControllerfrom linkcad.v1.plugin import DialogSpec, ChoiceItem, EventLog, Phase, LayerFlags, SortOrderfrom linkcad.v1.plugin import HolesMode, PolygonType, EndCap, FillRule
# 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 Color, Property, ReadLock, WriteLock, Transaction, Unitfrom linkcad.v1.db import EndCap, FillRule, BooleanOperation, MergeLayerPolarityResult
# Geometryfrom linkcad.v1.geom import Point, Vector, Bounds, Transformation, Angle, Resolution
# Edit tasksfrom linkcad.v1.edit import MergeTask, FlattenTask, FillRule, HolesMode
# Options & loggingfrom linkcad.v1.env import get_option_boolean, set_option_boolean, EventLog, Severity
# File conversionfrom linkcad.v1.conv import Conversion, Conversions, FormatRegistry, Format, FormatAttributes
# Boolean geometryfrom linkcad.v1.libgraph import boolean_and, boolean_or, ShapeProcessor
# Conversion controllerfrom linkcad.v1.controller import ConversionController