技术参考 - PCB API
Parent page: Altium Designer API Reference
The PCB Application Programming Interface (API) reference details the object interfaces for PCB objects such as PCB documents and PCB design objects.
The PCB API consists of the PCB Object model and the API functions. The PCB Object Model part of the PCB API is made accessible by the PCB Editor.
The PCB design objects and methods are available in all script languages supported by Altium Designer. The PCB design objects are wrapped by their corresponding PCB interfaces which makes it possible to manipulate those objects by scripts and server code.
Object Interfaces
An interface is basically a list of methods that a class declares it implements — that is, each method in the interface is implemented in the corresponding class. Interfaces are declared like classes, but cannot be directly instantiated and do not have their own method definitions.
PCBServer function
To work with PCB design objects, the starting point is to invoke the PCBServer function which returns the IPCB_ServerInterface interface, which represents the PCB Editor. With this interface, all other PCB interfaces can be extracted.
For example to get access to the current PCB document open in Altium Designer, you would invoke the GetCurrentPCBBoard method from the IPCB_ServerInterface interface object.
Example: Obtaining the currently open PCB document.
Board := PCBServer.GetCurrentPCBBoard;
If Board = Nil then Exit;
TheFilename := Board.FileName;
Main PCB Interfaces
- The IPCB_Primitive interface is a generic ancestor interface for all PCB design object interfaces.
- The IPCB_Board interface represents an existing PCB document.
- The IPCB_ServerInterface interface represents the PCB server object.
Script Examples
There are PCB script examples in the \Examples\Scripts\DelphiScripts\PCB
folder which demonstrate the use of PCB interfaces.
References for the PCB API
- PCB API System Interfaces
- PCB API Layer Stack Interfaces - new updated content
- PCB API Layer Interfaces - new updated content
- PCB API Design Objects Interfaces
- PCB API Types
- PCB API Constants and Functions
Separate references for other Altium Designer APIs
- System API Object Model - refer to the System API Reference
- Schematic Object Model - refer to the Schematic API Reference
- Workspace Manager Object Model - refer to the Workspace Manager API Reference
- Integrated Library Object Model - refer to the Integrated Library API Reference
PCB Object Model
The PCB Object Model compromises of PCB Object Interfaces and standalone utility functions that allow you to deal with PCB objects from a PCB document in Altium Designer via object interfaces.
An interface is just a means of access to an object in memory. To have access to the PCB server and massage certain PCB design objects, you need to invoke the PCBServer function, which extracts the IPCB_ServerInterface interface.
The IPCB_ServerInterface interface is the main interface and contains many interfaces within. With this interface for example, you can proceed further by iterating for PCB objects on a PCB document.
A simplified PCB Interfaces hierarchy example:
IPCB_Primitive
IPCB_Group
IPCB_Net
The IPCB_ServerInterface and IPCB_Board interfaces are two of the main interfaces to deal with when accessing and manipulating a PCB document.
See also
IPCB_ServerInterface
IPCB_BoardOutline
IPCB_Board
IPCB_LayerStack
IPCB_LayerObject
IPCB_InternalPlane
IPCB_DrillLayerPair
IPCB_MechanicalLayerPairs
IPCB_SystemOptions
IPCB_InteractiveRoutingOptions
IPCB_Arc
IPCB_Pad
IPCB_Via
IPCB_Track
IPCB_Connection
IPCB_Embedded
IPCB_Violation
IPCB_Text
IPCB_Fill
IPCB_Coordinate
IPCB_Dimension
IPCB_Component
IPCB_Polygon
IPCB_Net
IPCB_LibComponent