### Direct Option Example Source: https://docs.linkcad.com/rust/api/options An example demonstrating how to register and read options directly. ```APIDOC ## Direct Option Example ```rust use lc_plugin::options; fn register_options() { options::register_bool("ExampleInMerge", true); options::register_int("ExampleInFacets", 32); options::register_string("ExampleInUnits", "um"); } fn read_options() -> (bool, i32, String) { ( options::get_bool("ExampleInMerge"), options::get_int("ExampleInFacets"), options::get_string("ExampleInUnits"), ) } ``` ``` -------------------------------- ### Rust Log2 Export Example Source: https://docs.linkcad.com/rust/api/log Shows how to obtain a log from a WriterController and use the `log2` method with `Severity::Info` to record the start of an export operation, including the file path. ```rust fn write_file(&mut self, path: &str, ctrl: &mut WriterController) -> bool { let mut log = ctrl.log(); log.log2( Severity::Info, "Export started", &format!("Writing {path}"), ); true } ``` -------------------------------- ### Practical Descriptor Example Source: https://docs.linkcad.com/rust/api/format An example demonstrating how to implement `FormatDescriptor` for a custom format, setting multiple attributes, ranges, lengths, and file extensions. ```APIDOC ## Practical Descriptor Example (`ExampleFormat`) ### Description An example implementation of `FormatDescriptor` for `ExampleFormat`, showcasing the configuration of various format capabilities. ### Code ```rust impl FormatDescriptor for ExampleFormat { fn describe_format(&self, fmt: &mut Format) { fmt.set_attributes( FormatAttributes::LAYER_NUMBERS | FormatAttributes::LAYER_NAMES | FormatAttributes::CELL_NAMES | FormatAttributes::MULTIPLE_FILES, ); fmt.set_layer_number_range(0, 255); fmt.set_layer_name_length(32); fmt.set_valid_layer_chars( "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_", "ABCDEFGHIJKLMNOPQRSTUVWXYZ_", "L", ); fmt.set_cell_name_length(64); fmt.set_file_name_extension("exa"); } } ``` ``` -------------------------------- ### Rust Layer Enumeration Example Source: https://docs.linkcad.com/rust/api/writer_ctrl Demonstrates how to iterate through layers using WriterController, starting with regular sort order and logging the name of each layer. ```rust ctrl.start_enum_layers(SortOrder::Regular); while let Some(layer) = ctrl.next_layer() { ctrl.log().info(&format!("Exporting layer {}", layer.name())); } ``` -------------------------------- ### Import Example for Event Logging Source: https://docs.linkcad.com/rust/api/log Example demonstrating how to import and use the EventLog for logging messages during an import process. This snippet shows basic usage with different severity levels. ```rust use lc_plugin::log::{EventLog, Severity}; fn import_data(...) -> Result<(), ()> { let mut log = EventLog::from_raw(...); log.log("Starting import process.", Severity::Info); // ... import logic ... if import_failed { log.log("Import failed due to invalid data.", Severity::Error); return Err(()); } log.log("Import completed successfully.", Severity::Info); Ok(()) } ``` -------------------------------- ### Example Usage Source: https://docs.linkcad.com/python/api/plugin Example demonstrating how to use DrawingBuilder methods to create a drawing with a cell, layer, arc, and text. ```APIDOC ## Example Usage ### Description Example demonstrating how to use DrawingBuilder methods to create a drawing with a cell, layer, arc, and text. ### Code ```python from linkcad.v1.db import EndCap, TextStyle, TextStyleMask from linkcad.v1.geom import Point # Assuming 'builder' is an instance of DrawingBuilder provided by the LinkCAD runtime # builder.open_cell("TOP", is_main_cell=True) # builder.select_layer("metal1") # builder.create_arc(Point(0, 0), radius=10_000, width=500, end_cap=EndCap.Round) # builder.create_text() # builder.set_text_position(Point(0, 12_000)) # builder.set_text_height(1_000) # builder.set_text_style(TextStyle.AlignHCenter, TextStyleMask.AlignH) # builder.set_unformatted_text("TOP") # builder.close_cell() ``` ``` -------------------------------- ### Rust DrawingBuilder Example: Create Polygon Source: https://docs.linkcad.com/rust/api/builder Example demonstrating how to open a cell, select a layer, create a polygon, and close the cell using the DrawingBuilder. ```rust builder.open_cell_by_name("TOP", true, false); builder.select_layer_by_name("metal1"); builder.create_polygon( &[ Point::new(0, 0), Point::new(10_000, 0), Point::new(10_000, 5_000), Point::new(0, 5_000), ], true, ); builder.close_cell(); ``` -------------------------------- ### Simple Conversion Example Source: https://docs.linkcad.com/automation/cli Performs a basic conversion from an input file to an output file using the CLI. ```bash linkcad "input.dwg" "output.dxf" ``` -------------------------------- ### Direct Option Example Source: https://docs.linkcad.com/rust/api/options Demonstrates registering and reading boolean, integer, and string options directly. ```rust use lc_plugin::options; fn register_options() { options::register_bool("ExampleInMerge", true); options::register_int("ExampleInFacets", 32); options::register_string("ExampleInUnits", "um"); } fn read_options() -> (bool, i32, String) { ( options::get_bool("ExampleInMerge"), options::get_int("ExampleInFacets"), options::get_string("ExampleInUnits"), ) } ``` -------------------------------- ### Install LinkCAD on RPM-based Linux Source: https://docs.linkcad.com/getting-started/installation Install LinkCAD using rpm or dnf on RPM-based distributions like Fedora, RHEL, or openSUSE. ```bash sudo rpm -i linkcad-*.rpm ``` ```bash sudo dnf install linkcad-*.rpm ``` -------------------------------- ### Export Example for Event Logging Source: https://docs.linkcad.com/rust/api/log Example demonstrating how to export data using the EventLog for logging messages during an export process. This snippet illustrates logging warnings and errors. ```rust use lc_plugin::log::{EventLog, Severity}; fn export_data(...) -> Result<(), ()> { let mut log = EventLog::from_raw(...); log.log("Preparing to export data.", Severity::Info); // ... export logic ... if some_data_is_missing { log.log("Warning: Some optional data was missing, export will continue.", Severity::Warning); } if critical_export_error { log.log("Critical error during export: Cannot write to file.", Severity::Error); return Err(()); } log.log("Data exported successfully.", Severity::Info); Ok(()) } ``` -------------------------------- ### Writer Callback Example Source: https://docs.linkcad.com/rust/api/entity An example implementation of the `Writer` trait, demonstrating how to iterate through layers and render cells. ```rust impl Writer for ExampleWriter { fn write_file(&mut self, _path: &str, ctrl: &mut WriterController) -> bool { let Some(cell) = ctrl.main_cell() else { ctrl.log().error("No main cell to export"); return false; }; ctrl.start_enum_layers(SortOrder::Regular); while let Some(layer) = ctrl.next_layer() { let xform = ctrl.transformation(false); ctrl.render_cell(&cell, &layer, &xform); } true } fn write_polygon(&mut self, polygon: &Polygon, fill_rule: FillRule) -> bool { let vertices = polygon.vertices(); let layer_name = polygon.layer().name(); // Write vertices and layer_name to the output format. let _ = (vertices, layer_name, fill_rule); true }} ``` -------------------------------- ### CSV Layer Map Example Source: https://docs.linkcad.com/automation/layer-maps This example demonstrates the CSV format for layer maps, showing multiple layer mappings with various properties. ```csv METAL1,M1,Metal 1 layer,#FF0000,true,1000,3,true,false,500 VIA1,V1,,Blue,true,,,,false,200 POLY,P1,,#FFFF00,,,,,,, ``` -------------------------------- ### DialogSpec Builder Example Source: https://docs.linkcad.com/rust/api/dialog Demonstrates chaining builder methods to construct a DialogSpec for plugin import options. ```rust use lc_plugin::dialog::{ChoiceItem, DialogSpec}; fn import_dialog_spec() -> DialogSpec { DialogSpec::new("Import Options") .group("Geometry") .bool_field("ExampleInMerge", "Merge polygons", true) .int_field("ExampleInFacets", "Minimum facets", 4, 256, 32) .combo_field("ExampleInUnits", "Units", &["nm", "um", "mm"], "um") .group("Layers") .single_select_list( "ExampleInLayer", "Layer", &[ChoiceItem::with_display("metal1", "Metal 1")], Some("layers"), ) } ``` -------------------------------- ### FormatDescriptor Trait and Example Implementation Source: https://docs.linkcad.com/rust/api/format Demonstrates the FormatDescriptor trait and provides an example implementation for a custom format, setting attributes like layer and cell names, and their lengths. ```APIDOC ## `FormatDescriptor` Trait ### Description Defines a trait for describing the capabilities of a file format. Implement this trait on types that also implement `Reader`, `Writer`, or both. ### Methods - `describe_format(&self, fmt: &mut Format)`: A method that takes a mutable reference to a `Format` object and sets its descriptor values. ### Example Implementation (`ExampleReader`) ```rust impl FormatDescriptor for ExampleReader { fn describe_format(&self, fmt: &mut Format) { fmt.set_attributes(FormatAttributes::LAYER_NAMES | FormatAttributes::CELL_NAMES); fmt.set_layer_name_length(64); fmt.set_cell_name_length(64); fmt.set_file_name_extension("exa"); } } ``` ``` -------------------------------- ### Format Registration Example Source: https://docs.linkcad.com/python/reference/format-decorators Shows how to use the @format_reader decorator with specific name and extensions to register a custom format. ```python @format_reader(name="My Format", extensions=["*.myf", "*.myfx"]) ``` -------------------------------- ### Path Option Example Source: https://docs.linkcad.com/python/tutorial-tool-plugin Creates a file picker dialog for selecting a file path. Can specify a file filter for the dialog. ```python Option.path("Output", file_filter="*.csv") ``` -------------------------------- ### CSV Layer Map Example Source: https://docs.linkcad.com/user-guide/layer-maps This example demonstrates mapping GDSII layers 1 through 6 to custom colors, visibility settings, and stacking behavior with specified thicknesses. Trailing commas are used to omit unspecified columns. ```csv 1,,,Blue,true,,,false,true,100000000002,,,Yellow,true,,,false,true,50000000003,,,Magenta,true,,,false,true,50000000004,,,Cyan,true,,,false,true,50000000005,,,"#ffc000",true,,,false,true,100000000006,,,"#ff00cc",true,,,false,true,10000000000 ``` -------------------------------- ### Launch LinkCAD from Terminal Source: https://docs.linkcad.com/getting-started/installation Execute the LinkCAD application from the terminal after installation. ```bash linkcad ``` -------------------------------- ### Dialog-Backed Options Source: https://docs.linkcad.com/rust/api/options Example of how to define options that are backed by a user interface dialog. ```APIDOC ## Dialog-Backed Options ```rust fn import_dialog_spec() -> DialogSpec { DialogSpec::new("Import Options") .group("Geometry") .bool_field("ExampleInMerge", "Merge polygons", true) .int_field("ExampleInFacets", "Minimum facets", 4, 256, 32) .string_field("ExampleInUnits", "Units", "um") } ``` When this dialog is passed to `register_format!`, the macro registers its options before it registers the dialog with the host. ``` -------------------------------- ### Choice Option Example Source: https://docs.linkcad.com/python/tutorial-tool-plugin Creates a dropdown list for selecting one option from a predefined list of choices. ```python Option.choice("Mode", choices=["Fast", "Precise"]) ``` -------------------------------- ### Example Reader Format Descriptor Source: https://docs.linkcad.com/rust/api/format Implements FormatDescriptor for an ExampleReader to set layer and cell name lengths, and file extension. ```rust impl FormatDescriptor for ExampleReader { fn describe_format(&self, fmt: &mut Format) { fmt.set_attributes(FormatAttributes::LAYER_NAMES | FormatAttributes::CELL_NAMES); fmt.set_layer_name_length(64); fmt.set_cell_name_length(64); fmt.set_file_name_extension("exa"); } } ``` -------------------------------- ### Practical Format Descriptor Example Source: https://docs.linkcad.com/rust/api/format Demonstrates implementing FormatDescriptor for ExampleFormat, setting multiple attributes, ranges, lengths, valid characters, and file extensions. ```rust impl FormatDescriptor for ExampleFormat { fn describe_format(&self, fmt: &mut Format) { fmt.set_attributes( FormatAttributes::LAYER_NUMBERS | FormatAttributes::LAYER_NAMES | FormatAttributes::CELL_NAMES | FormatAttributes::MULTIPLE_FILES, ); fmt.set_layer_number_range(0, 255); fmt.set_layer_name_length(32); fmt.set_valid_layer_chars( "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_", "ABCDEFGHIJKLMNOPQRSTUVWXYZ_", "L", ); fmt.set_cell_name_length(64); fmt.set_file_name_extension("exa"); } } ``` -------------------------------- ### Arc Source: https://docs.linkcad.com/python/api/db Represents a circular arc, extending the `Shape` class. It allows for the creation of arcs with specified center, radius, width, start, and end angles, and provides methods to get or set these properties. ```APIDOC ## Arc A circular arc. Extends `Shape`. ### Methods - **`Arc.create(cell, layer, center, radius, width=None, start_angle=None, end_angle=None)`**: Create an arc in a cell and layer. - **`arc.center()` / `arc.set_center(point)`**: Get or set the center point. - **`arc.radius()` / `arc.set_radius(radius)`**: Get or set radius in database units. - **`arc.width()` / `arc.set_width(width)`**: Get or set stroke width. - **`arc.start_angle()`**: Start angle as an `Angle`. - **`arc.end_angle()`**: End angle as an `Angle`. ### Example Usage ```python from linkcad.v1.db import Arc from linkcad.v1.geom import Angle, Point arc = Arc.create( cell, layer, center=Point(0, 0), radius=10_000, width=500, start_angle=Angle.from_degrees(0), end_angle=Angle.from_degrees(90), ) ``` ``` -------------------------------- ### Basic Conversion Workflow with ConversionController Source: https://docs.linkcad.com/python/api/controller Instantiate ConversionController, set import/export formats and paths, run the conversion, and check the final state. ```python from linkcad.v1.controller import ConversionController ctrl = ConversionController() ctrl.set_import_format("GDSII") ctrl.set_export_format("DXF") ctrl.set_import_path("/data/design.gds") ctrl.set_export_path("/data/design.dxf") ctrl.run() if ctrl.state == ConversionState.Done: print("Conversion succeeded") else: print(f"Failed at state: {ctrl.state}") ``` -------------------------------- ### Silent Installation on Windows Source: https://docs.linkcad.com/getting-started/installation Perform a silent installation of LinkCAD on Windows for enterprise deployment. Specify the installation directory using the /D flag. ```bash LinkCAD-Setup.exe /S /D="C:\ Program Files\LinkCAD" ``` -------------------------------- ### Implement Reader for ExampleReader Source: https://docs.linkcad.com/rust/getting-started Parses an example file, setting drawing name, opening cells, selecting layers, and creating geometric shapes. ```rust impl Reader for ExampleReader { fn parse_file( &mut self, _path: &str, builder: &mut DrawingBuilder, _file_size: i64, _current_file: i32, _file_count: i32, ) -> bool { builder.set_drawing_name("Example import"); builder.open_cell_by_name("TOP", true, false); builder.select_layer_by_name("L1"); builder.create_rectangle(Point::new(0, 0), Point::new(1000, 1000)); builder.create_polyline( 25, &[Point::new(0, 0), Point::new(1000, 1000)], false, EndCap::Round, ); builder.close_cell(); true } } ``` -------------------------------- ### ctrl.run() Source: https://docs.linkcad.com/python/api/controller Initiates and executes the complete conversion pipeline based on the configured settings. ```APIDOC ## ctrl.run() ### Description Execute the full conversion pipeline. ### Method run ### Parameters None ### Response None ``` -------------------------------- ### Create and Configure Text Source: https://docs.linkcad.com/rust/api/builder Demonstrates creating text, setting its position, height, and content. ```rust builder.create_text();builder.set_text_position(Point::new(0, 12_000));builder.set_text_height(1_000.0);builder.set_unformatted_text("TOP"); ``` -------------------------------- ### JSON Layer Map Schema Example Source: https://docs.linkcad.com/automation/layer-maps An example of a JSON layer map configuration. This format is schema-validated and recommended for new LinkCAD projects. ```json { "$schema": "https://schema.linkcad.com/layer-map-v1-schema.json", "version": 1, "units": "um", "layer_map": [ { "input_layer": "METAL1", "output_layer": "M1", "order": 1, "comment": "Metal 1 layer", "color": "#FF0000", "visibility": true, "elevation": 1000, "thickness": 500, "material": 3, "extrude": true }, { "input_layer": "VIA1", "output_layer": "V1", "order": 2, "color": "Blue", "stack": true, "thickness": 200 } ] } ``` -------------------------------- ### Install LinkCAD on Debian/Ubuntu Source: https://docs.linkcad.com/getting-started/installation Use dpkg to install the LinkCAD .deb package on Debian or Ubuntu systems. If dependencies are missing, use apt-get to resolve them. ```bash sudo dpkg -i linkcad-*.deb ``` ```bash sudo apt-get install -f ``` -------------------------------- ### Rust Log Info Example Source: https://docs.linkcad.com/rust/api/log Demonstrates how to obtain a log from a DrawingBuilder and use the `info` method to record a message during file parsing. It also shows error handling with `error` and `set_fatal`. ```rust fn parse_file( &mut self, path: &str, builder: &mut DrawingBuilder, _file_size: i64, _current_file: i32, _file_count: i32, ) -> bool { let mut log = builder.log(); log.info(&format!("Reading {path}")); if path.is_empty() { log.error("No input file was provided"); log.set_fatal(); return false; } true } ``` -------------------------------- ### Gerber Import with Tools Example Source: https://docs.linkcad.com/automation/config-files Configuration snippet for importing Gerber files and applying specific tools for merging and deembedding. ```config [LinkCAD]LcLoadDefaults=true LcImportFormat=Gerber RS-274X LcExportFormat=GDSII GbrInUnits=4 ToolApply=Merge ToolApply=Deembed ``` -------------------------------- ### MetaItem Construction Methods Source: https://docs.linkcad.com/rust/api/inspect Demonstrates the different ways to create MetaItem instances, each with varying levels of detail for value, display text, and descriptions. ```rust MetaItem::simple(value: &str) -> MetaItem ``` ```rust MetaItem::with_display(value: &str, display: &str) -> MetaItem ``` ```rust MetaItem::full(value: &str, display: &str, description: &str) -> MetaItem ``` -------------------------------- ### Installing Additional Python Packages with Pip Source: https://docs.linkcad.com/python/setup Install additional Python packages using pip within the LinkCAD Python environment. Note that only pure-Python packages are guaranteed to work. ```python import subprocess subprocess.check_call(["pip", "install", "numpy"]) ``` -------------------------------- ### Import and Create an Arc with Text Source: https://docs.linkcad.com/python/api/plugin This example demonstrates opening a cell, selecting a layer, creating an arc, and adding text to it. It requires importing necessary modules and assumes the builder object is available. ```python from linkcad.v1.db import EndCap, TextStyle, TextStyleMask from linkcad.v1.geom import Point builder.open_cell("TOP", is_main_cell=True) builder.select_layer("metal1") builder.create_arc(Point(0, 0), radius=10_000, width=500, end_cap=EndCap.Round) builder.create_text() builder.set_text_position(Point(0, 12_000)) builder.set_text_height(1_000) builder.set_text_style(TextStyle.AlignHCenter, TextStyleMask.AlignH) builder.set_unformatted_text("TOP") builder.close_cell() ``` -------------------------------- ### Rust Export File Function Example Source: https://docs.linkcad.com/rust/api/writer_ctrl An example function that exports a file using WriterController. It retrieves the main cell, enumerates layers, and renders each cell within its layer. ```rust fn write_file(&mut self, _path: &str, ctrl: &mut WriterController) -> bool { let Some(cell) = ctrl.main_cell() else { ctrl.log().error("No main cell to export"); return false; }; ctrl.start_enum_layers(SortOrder::Regular); while let Some(layer) = ctrl.next_layer() { let xform = ctrl.transformation(false); ctrl.render_cell(&cell, &layer, &xform); } true } ``` -------------------------------- ### GDS to DXF Conversion Example Source: https://docs.linkcad.com/automation/config-files Configuration snippet for converting a GDSII file to DXF format, including scaling and version settings. ```config [LinkCAD]LcLoadDefaults=true LcImportFormat=GDSII LcExportFormat=DXF LcImportFile=C:\\designs\\chip.gds LcExportFile=C:\\output\\chip.dxf DxfOutScaling=1000 DxfOutFormatVersion=2000 ToolApply=SanitizePolygons ``` -------------------------------- ### Python Format Writer Plugin Example Source: https://docs.linkcad.com/python/tutorial-format-plugin Example of a simple format writer plugin that exports data to a text file. It uses the `@format_writer` decorator and iterates through shapes to write their properties. ```python from linkcad.plugin import format_writer from linkcad.plugin.context import WriterContext @format_writer("SimpleText", extensions=[".txt"]) def write_simple_text(ctx: WriterContext): for shape in ctx.shapes(): ctx.write(f"{shape.id}: {shape.type} {shape.layer} {shape.color}\n") if shape.type == "point": ctx.write(f" Coords: {shape.x}, {shape.y}\n") elif shape.type == "line": ctx.write(f" Start: {shape.x1}, {shape.y1}\n") ctx.write(f" End: {shape.x2}, {shape.y2}\n") ``` -------------------------------- ### Python Format Reader Plugin Example Source: https://docs.linkcad.com/python/tutorial-format-plugin Example of a simple format reader plugin that imports coordinate data. It uses the `@format_reader` decorator and interacts with `DrawingContext` to process input lines. ```python from linkcad.plugin import format_reader from linkcad.plugin.context import DrawingContext @format_reader("SimpleCoord", extensions=[".coord"]) def read_simple_coord(ctx: DrawingContext, lines: list[str]): for line in lines: try: x, y = map(float, line.split()) ctx.add_point(x, y) except ValueError: ctx.error(f"Invalid line: {line}") ``` -------------------------------- ### LinkCAD Session File Format Example Source: https://docs.linkcad.com/user-guide/sessions This is an example of a LinkCAD session file, which uses the .lsn extension and is a plain-text INI file. It demonstrates how to specify import and export formats, scaling, version, and tool application. ```ini [LinkCAD] LcLoadDefaults=true LcImportFormat=GDSII LcExportFormat=DXF DxfOutScaling=1000 DxfOutFormatVersion=2000 GdsInIgnoreText=false ToolApply=SanitizePolygons ``` -------------------------------- ### Create a Scale Transformation Source: https://docs.linkcad.com/python/api/geom Shows how to create a uniform scaling transformation. ```python from linkcad.v1.geom import Transformation t = Transformation.scale(2.0) ``` -------------------------------- ### Make AppImage Executable and Run Source: https://docs.linkcad.com/getting-started/installation Prepare the LinkCAD AppImage for execution by making it executable and then running it directly. This method works on any modern 64-bit Linux distribution. ```bash chmod +x LinkCAD-*.AppImage ``` ```bash ./LinkCAD-*.AppImage ``` -------------------------------- ### Rust Reader Implementation Example Source: https://docs.linkcad.com/rust/api/drawing Example of implementing the `Reader` trait for custom file parsing and post-processing. This snippet demonstrates opening a cell, selecting a layer, creating a rectangle, and merging polarity groups during post-processing. ```rust impl Reader for ExampleReader { fn parse_file( &mut self, _path: &str, builder: &mut DrawingBuilder, _file_size: i64, _current_file: i32, _file_count: i32, ) -> bool { builder.open_cell_by_name("TOP", true, false); builder.select_layer_by_name("metal"); builder.create_rectangle(Point::new(0, 0), Point::new(10_000, 10_000)); builder.close_cell(); true } fn post_process( &mut self, phase: Phase, drawing: &mut Drawing, progress: Option<&mut DrawingBuilder>, log: &mut EventLog, resolution: &Resolution, ) -> bool { if phase != Phase::ParsedAll { return true; } match drawing.merge_all_polarity_groups(resolution, progress, 0, 100) { MergeLayerPolarityResult::Success => true, MergeLayerPolarityResult::Cancelled => false, MergeLayerPolarityResult::Failure => { log.error("Could not merge layer polarity groups"); false } } }} ``` -------------------------------- ### Running LinkCAD from Command Line with Config File Source: https://docs.linkcad.com/automation/config-files Execute LinkCAD using a command file for settings and specify the output file. ```bash linkcad.exe --config my_settings.lsn --console --quit ``` -------------------------------- ### Sanitize Polygons Example Source: https://docs.linkcad.com/tools/shape-operations/sanitize-polygons This example demonstrates how to use the sanitize polygons functionality. It takes an input polygon and applies cleaning operations to produce a valid output polygon. Ensure the input polygon data is correctly formatted. ```javascript const inputPolygon = { "points": [{"x": 0, "y": 0}, {"x": 10, "y": 0}, {"x": 10, "y": 10}, {"x": 0, "y": 10}, {"x": 0, "y": 0}] }; const sanitizedPolygon = await linkcad.tools.shapeOperations.sanitizePolygons(inputPolygon); console.log(sanitizedPolygon); ``` -------------------------------- ### LinkCAD Command File Example Source: https://docs.linkcad.com/automation/config-files A basic INI-format command file specifying import and export formats and file paths for LinkCAD. ```ini [LinkCAD] LcImportFormat=GDSIILcExportFormat=DXFLcImportFile=C:\designs\chip.gdsLcExportFile=C:\output\chip.dxf ``` -------------------------------- ### Layer Enumeration Source: https://docs.linkcad.com/rust/api/writer_ctrl Methods for starting and iterating through layers during export. ```APIDOC ## start_enum_layers ### Description Reset layer enumeration in the requested order. ### Method `start_enum_layers(order: SortOrder)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Response None ## next_layer ### Description Return the next layer, or `None` at the end. ### Method `next_layer() -> Option` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Response `Option`: The next layer, or `None` if enumeration is complete. ``` -------------------------------- ### Example Inspector Implementation Source: https://docs.linkcad.com/rust/api/inspect A concrete implementation of the SourceInspector trait, demonstrating how to create and populate SourceMeta with sample data for 'steps' and 'layers'. ```rust use lc_plugin::inspect::{MetaItem, SourceInspector, SourceMeta}; use std::path::Path; struct ExampleInspector; impl SourceInspector for ExampleInspector { fn inspect(&self, _path: &Path) -> Result { let mut meta = SourceMeta::new(); meta.add_items("steps", &["pcb", "panel"]); meta.add_meta_items( "layers", vec![ MetaItem::with_display("top", "Top Copper"), MetaItem::with_display("bottom", "Bottom Copper"), ], ); Ok(meta) } } ``` -------------------------------- ### ClosePolylinesTask Source: https://docs.linkcad.com/python/api/edit Closes open polylines by connecting the start and end points. ```APIDOC ## ClosePolylinesTask ### Description Closes open polylines by connecting the start and end points. ### Class ClosePolylinesTask ### Parameters None explicitly documented for direct instantiation or method calls. ``` -------------------------------- ### Getting Options Source: https://docs.linkcad.com/rust/api/options Functions to retrieve the current values of registered options. ```APIDOC ## Getting Options ### `get_int(name: &str) -> i32` Read an integer option. ### `get_bool(name: &str) -> bool` Read a boolean option. ### `get_real(name: &str) -> f64` Read a floating-point option. ### `get_string(name: &str) -> String` Read a string option. Returns an empty string when the host returns no value. ``` -------------------------------- ### Create a Mirror X Transformation Source: https://docs.linkcad.com/python/api/geom Illustrates creating a transformation that mirrors about the X axis. ```python from linkcad.v1.geom import Transformation t = Transformation.mirror_x() ``` -------------------------------- ### Using a Command File for Shared Settings Source: https://docs.linkcad.com/automation/batch Utilize a command file to specify common settings for batch conversions, simplifying command-line execution. This example uses a file named 'batch_settings.txt'. ```bash linkcad.exe -batch @batch_settings.txt ``` -------------------------------- ### Get Real Option Source: https://docs.linkcad.com/rust/api/options Use to read a floating-point option by its name. ```rust get_real(name: &str) -> f64 ``` -------------------------------- ### SourceMeta Methods Source: https://docs.linkcad.com/rust/api/inspect Illustrates the core methods for creating and manipulating SourceMeta, including initialization, adding items, and serialization. ```rust pub struct SourceMeta { pub lists: Vec<(String, Vec)>, } ``` ```rust SourceMeta::new() -> SourceMeta ``` ```rust add_items(key: &str, items: &[&str]) ``` ```rust add_meta_items(key: &str, items: Vec) ``` ```rust get(key: &str) -> Option<&[MetaItem]> ``` ```rust to_json() -> String ```