linkcad.conv
File format conversion — loading and saving drawings programmatically.
from linkcad.conv import Conversion, Conversions, FormatRegistry, FormatClasses
Conversion
A single import → export operation. Use this for straightforward one-file conversions.
from linkcad.conv import Conversion
conv = Conversion("GDSII", "DXF")conv.set_import_path("/data/design.gds")conv.set_export_path("/data/design.dxf")
conv.read_file()if not conv.succeeded(): raise RuntimeError("Import failed")
dwg = conv.drawing()# optionally inspect/modify dwg under WriteLock here
conv.write_file()if not conv.succeeded(): raise RuntimeError("Export failed")| Method | Description |
|---|---|
Conversion(import_format, export_format) | Construct with format names (e.g. "GDSII", "DXF") |
conv.set_import_path(path) | Set single input file path |
conv.set_export_path(path) | Set output file path |
conv.read_file() | Execute the import step |
conv.write_file() | Execute the export step |
conv.succeeded() | Returns True if the last operation succeeded |
conv.drawing() | Returns the Drawing produced by read_file() |
Conversions
A batch container for running multiple Conversion jobs. Each job is independent.
from linkcad.conv import Conversions
batch = Conversions()conv = batch.append_new("CIF", "CIF")conv.set_import_paths(["/data/a.cif", "/data/b.cif"])conv.set_export_path("/data/out.cif")
conv.read_file()conv.write_file()| Method | Description |
|---|---|
Conversions() | Create an empty batch |
batch.append_new(import_fmt, export_fmt) | Add a new Conversion to the batch and return it |
conv.set_import_paths(paths) | Set a list of input file paths (for multi-file formats) |
FormatRegistry
Provides access to the list of formats that LinkCAD can read and write.
from linkcad.conv import FormatRegistry
registry = FormatRegistry.instance()for fmt in registry.formats(): print(fmt.name, fmt.extensions)| Method | Description |
|---|---|
FormatRegistry.instance() | Class method — get the singleton registry |
registry.formats() | Iterate all registered Format objects |
registry.find(name) | Find a format by name; returns None if not found |
Format
Describes a single file format supported by LinkCAD.
| Property | Description |
|---|---|
fmt.name | Format display name (e.g. "GDSII") |
fmt.extensions | List of file patterns (e.g. ["*.gds", "*.gdsii"]) |
fmt.can_read | True if the format supports import |
fmt.can_write | True if the format supports export |