@typecad/typecad
Version:
🤖programmatically 💥create 🛰️hardware
128 lines (127 loc) • 5.1 kB
TypeScript
import { Component } from "./component";
import { Schematic } from "./schematic";
import { TrackBuilder } from './pcb_track_builder';
import { IPcbOptions, IVia, IGrLine } from './pcb_interfaces';
export { TrackBuilder } from './pcb_track_builder';
export { IPcbOptions, INetResolution, IVia, IGraphicPrimitive, IGrLine, IGrArc, OutlineElement, IOutline, IGeneratedElement } from './pcb_interfaces';
/**
* Represents a printed circuit board (PCB).
*/
export declare class PCB {
#private;
Boardname: string;
Schematic: Schematic;
thickness: number;
copper_thickness: number;
/**
* Initializes a new PCB.
* @param Boardname - Name and filename of generated files.
* @param schematic - Optional schematic associated with the PCB.
*/
constructor(Boardname: string, options?: IPcbOptions);
/**
* Getter for PCB options.
*/
get option(): IPcbOptions;
/**
* Places components on the board.
* @param components - List of components to place.
*/
place(...components: Component[]): void;
/**
* Groups components and/or elements from a TrackBuilder together on the board.
* @param group_name - Name of the group.
* @param items - A list of Component instances or TrackBuilder instances.
*/
group(group_name: string, ...items: Array<Component | TrackBuilder>): void;
/**
* Creates and saves the board to a file.
* @param items - Components and TrackBuilder instances to add to the board before creating.
*/
create(...items: Array<Component | TrackBuilder>): Promise<void>;
private getCallSite;
/**
* Calculate the current capacity of a via based on its size and drill
* @param size - Via size in mm
* @param drill - Via drill size in mm
* @param thickness - Copper plating thickness in microns (defaults to PCB copper thickness)
* @param boardThickness - Board thickness in mm (defaults to PCB thickness)
* @param maxTempRise - Maximum temperature rise in °C (defaults to 10)
* @returns Maximum current capacity in amperes
*/
private calculateViaCurrentCapacity;
/**
* Handles via-related operations.
* @param via - The via details.
* @returns The component representing the via.
*/
via({ at, size, drill, powerInfo }?: Omit<IVia, 'uuid' | 'netCode' | 'layers' | 'net'>): Component;
/**
* Creates a rectangular outline on the Edge.Cuts layer.
* @param x - The x-coordinate of the rectangle's start point.
* @param y - The y-coordinate of the rectangle's start point.
* @param width - The width of the rectangle.
* @param height - The height of the rectangle.
* @param filletRadius - The radius for filleted corners (0 for sharp).
* @param conceptualUuidFromUser - Optional UUID for the conceptual outline.
*/
outline(x: number, y: number, width: number, height: number, filletRadius?: number, conceptualUuidFromUser?: string): void;
_track(start: {
x: number;
y: number;
}, end: {
x: number;
y: number;
}, width?: number, layer?: string, locked?: boolean, uuid?: string): string;
/**
* Begins a fluent interface for creating connected tracks and vias.
* @returns A TrackBuilder instance.
*
* Example:
* ```
* let power_track_elements = pcb.connect()
* .from({x: 100, y: 100}, "F.Cu", 0.2)
* .to({x: 110, y: 100})
* .via({size: 0.8, drill: 0.4}) // Transitions to B.Cu (or other side of via)
* .to({x: 110, y: 120, layer: "B.Cu"}) // Continues on B.Cu
* ```
*/
track(): TrackBuilder;
/**
* Connects a group of pins together in the associated schematic.
* This is a pass-through to the Schematic.net() method.
* @param pins - Pins to connect in the net.
*/
net(...pins: import("./pin").Pin[]): void;
/**
* Sets a name for a net in the associated schematic.
* This is a pass-through to the Schematic.named() method.
* @param name - The name to set for the net.
* @returns The PCB instance for chaining.
*/
named(name: string): this;
/**
* Generates a Bill of Materials (BOM) for the associated schematic.
* This is a pass-through to the Schematic.bom() method.
* @param output_folder - The folder to output the BOM to.
*/
bom(output_folder?: string): void;
/**
* Performs electrical rule checks on the associated schematic.
* This is a pass-through to the Schematic.erc() method.
*/
erc(): void;
/**
* Adds components to the associated schematic.
* This is a pass-through to the Schematic.add() method.
* @param components - Components to add to the schematic.
*/
add(...components: Component[]): void;
/**
* Gets the actual track data for a given UUID, including any preserved manual edits.
* @param uuid - The UUID of the track to retrieve
* @returns The track data if found, null otherwise
* @private
*/
_getTrackData(uuid: string): IGrLine | null;
}