Using the Altium Designer API

Old Content - visit altium.com/documentation

Parent page: Altium Designer API

The Altium Designer Application Programming Interface (API) is composed of several sub APIs offering specialized classes and system routines. Each API has an Object Model and in turn, the object model is a hierarchical system of object interfaces. These object interfaces represent actual objects in the Altium Designer.

In the scripting system, we refer to the Object Models because we are only dealing with object interfaces that represent objects in the Altium Designer. An object model is a subset of the relevant API. For example, the PCB Object model is part of the PCB API.

The major APIs from the Altium Designer API are: Client/Server API, Workspace Manager API, PCB API, Schematic API and Integrated Library API.

For information on using the interfaces from specific Altium Designer APIs in scripts see:

DXP Software Technology platform

Altium Designer's open architecture is the DXP platform which allows scripters and third party developers to write and integrate their modules into the environment, with API access to the Schematic editor, PCB editor and other server extensions.

Several major software technologies are used in Altium Designer: the client/server architecture technology, APIs, DXP Object Models, and object oriented technologies.

Altium Designer provides a hybrid interface model, which exposes the functionality of a dynamic linked library (DLL) module to both a user and the client executable system. The servers themselves are built using the Altium Designer API.


Client - Executable /Server - DLL paradigm

The Client executable is a standalone executable system that collaborates with loaded DLL servers within Altium Designer. The Client module controls the user interface and delegates tasks (sends commands) to appropriate servers, while servers (as dynamic linked library files) concentrate solely on providing specific functionality based on the Altium Designer commands invoked by the user.

Editor Server services

An editor server provides its services within Altium Designer. The DXP platform interprets the tasks in terms of commands and then delegates these commands to the appropriate server.

The server responds by activating its required functionality on the currently focused design document.


The server responds to the process by the Client module and acts on the current document.

For example, when a user clicks on the Schematic menu to place a wire, the system interprets this action as a Sch:PlaceWire command and delegates the command to the Schematic Editor.

The Schematic server responds by executing the command. The functionality of a server that is installed in Altium Designer is exposed by that server's processes and its exposed functions.

Main Altium Designer Servers

The Workspace Manager module is a system extensions server coupled tightly with the client module within Altium Designer. The Workspace Manager server deals with projects and their associated documents, and provides compiling, multi sheet design support, connectivity navigation tools, multi-channel support, multiple implementation documents and so on. It also manages output generators such as netlisters.


A project and its design documents in Altium Designer. A document can be represented by two ways - as seen by the Workspace Manager and as seen by the Editor (Server).

The Schematic server and PCB server are two main document editors which have their own document types (design and library documents).

Managing the locations of footprints or symbols from the library documents is performed by the Integrated Library server.

There are two representations of a design document in Altium Designer: projects and documents dealt with by the Workspace Manager, and the server documents dealt with by the associated servers (as shown in the above image).

Using the Altium Designer API in scripts

The scripting engine in Altium Designer supports PCB, Schematic and Workspace Manager APIs which enables you to write scripts that act on PCB or Schematic documents, or invoke one of the file management routines to massage the documents in a project.

Altium Designer API is automatically exposed to be used in scripts, so you can code API statements in the scripts with appropriate parameter values using one of the supported scripting languages. Altium Designer supports scripting languages such as EnableBasic, Visual Basic, Javascript and as well as commonly used DelphiScript (which is very much like Delphi). DelphiScript scripts are the most common scripts used in Altium Designer.

A DelphiScript Script which counts Pad Objects on a PCB document

Procedure PadCount;
Var
    Board     : IPCB_Board;
    Pad       : IPCB_Primitive;
    Iterator  : IPCB_BoardIterator;
    PadNumber : Integer;
Begin
    PadNumber       := 0;
    // Retrieve the current board
    Board := PCBServer.GetCurrentPCBBoard;
    If Board = Nil Then Exit;
    // retrieve the iterator
    Iterator        := Board.BoardIterator_Create;
    Iterator.AddFilter_ObjectSet(MkSet(ePadObject));
    Iterator.AddFilter_LayerSet(AllLayers);
    Iterator.AddFilter_Method(eProcessAll);
 
    // Search and count pads
    Pad := Iterator.FirstPCBObject;
    While (Pad <> Nil) Do
    Begin
        Inc(PadNumber);
        Pad := Iterator.NextPCBObject;
    End;
    Board.BoardIterator_Destroy(Iterator);
 
    // Display the count result on a dialog.
    ShowMessage('Pad Count = ' + IntToStr(PadNumber));
End;

VBScript Script which creates a new via object on a PCB document

Sub ViaCreation
    Dim  Board
    Dim  Via 
 
    Set Board = PCBServer.GetCurrentPCBBoard
    If Board is Nothing Then Exit Sub
 
    ' Create a Via object
    Via           = PCBServer.PCBObjectFactory(eViaObject, eNoDimension, eCreate_Default)
    Via.X         = MilsToCoord(7500)
    Via.Y         = MilsToCoord(7500)
    Via.Size      = MilsToCoord(50)
    Via.HoleSize  = MilsToCoord(20)
    Via.LowLayer  = eTopLayer
    Via.HighLayer = eBottomLayer
 
    ' Put this via in the Board object
    Board.AddPCBObject(Via)
End Sub

See the A Tour of the Scripting System document for a scripting overview.
The downloadable Script Examples collection has a large number of examples that demonstrate how scripts with different API functions work within the Altium Designer framework.

Server development with the Altium Designer API

The Altium Designer scripting system implements a subset of the complete Altium Designer API and its Object Interfaces. The Altium DXP Developer, used for developing Altium Designer server Extensions, has access to the full Altium Designer API via a set of API SDK source units.

Using the Altium Designer Object Models

In Altium Designer, each API (such as the PCB API) has an Object Model and in turn, the object model is a hierarchical system of object interfaces. These object interfaces represent actual objects in the Altium Designer (such as the board, document, PCB objects etc).


An illustration of the relationship between objects in Altium Designer and the Object Interfaces supported by the Altium Designer API.

The projects and the corresponding documents are managed by the Workspace Manager. As indicated in the above image, a project open in Altium Designer is represented by the IProject object interface, and the documents from this project are represented by the IDocument interfaces. Also:

  • The PCB documents and PCB design objects are managed by the PCB Editor and its PCB API.
  • The PCB document open in Altium Designer is represented by its IPCB_Board interface.
  • The pad objects and the track objects are represented by IPCB_Pad and IPCB_Track interfaces, respectively.

Object Interfaces

Object Interfaces are implementation independent declarations of functionality. From a developer’s perspective, there are high level object interfaces which encapsulate certain system objects in Altium Designer system such as IProject, IWorkSpace, IClient and IServerModule interfaces, which can be used to extract data for further processing by other servers.

Types of Altium Designer Object Interfaces

  • Client and Server Interfaces – needed for dealing with Server Documents and Client objects.
  • Workspace Manager Interfaces – needed for dealing with projects and documents.
  • Schematic Interfaces – needed for dealing with schematic objects
  • PCB Interfaces – needed for dealing with PCB objects
  • Integrated Library Interfaces – needed for dealing with library links and building model editors.
  • Other interfaces – such as the Output Generator and Nexar interfaces.
You are reporting an issue with the following selected text and/or image within the active document:
Altium Designer 免费试用
Altium Designer Free Trial
我们开始吧!首先,您或者您的公司已经在使用Altium Designer了吗?

如果您有任何需求,请点击这里联系获取当地办公室销售代表联系方式。.
Copyright © 2019 Altium Limited

既然您在使用Altium Designer,为何仍需要试用?

如果您有任何需求,请点击这里联系获取当地办公室销售代表联系方式。.
Copyright © 2019 Altium Limited

好的,实际上您无需下载一个试用版本。

点击下方按钮下载最新版本的Altium Designer安装包

下载Altium Designer 安装包

如果您有任何需求,请点击这里联系获取当地办公室销售代表联系方式。.
Copyright © 2019 Altium Limited

填写下方表格,获取Altium Designer最新报价。

点击[获取免费试用],并同意我们的隐私政策。您会接收到来自Altium的资讯,并允许其改变您的通知首选项。

如果您是Altium维保期内客户,您不需要下载试用版本。

如果您不是Altium维保客户,请填写下方表格免费试用。

点击[获取免费试用],并同意我们的隐私政策。您会接收到来自Altium的资讯,并允许其改变您的通知首选项。

您为何想要试用Altium Designer?

如果您有任何需求,请点击这里联系获取当地办公室销售代表联系方式。.
Copyright © 2019 Altium Limited

那您来对地方了!请填写下方表格申请试用吧。

点击[获取免费试用],并同意我们的隐私政策。您会接收到来自Altium的资讯,并允许其改变您的通知首选项。

听上去很棒!您知道我们为学生提供了特殊折扣么?欲知详情,请点击这里。.

同时,请填写下方表格申请免费试用吧。

点击[获取免费试用],并同意我们的隐私政策。您会接收到来自Altium的资讯,并允许其改变您的通知首选项。

好的,您可以下载免费的Altium Designer Viewer查看文档,有效期6个月。

请填写下方表格申请。

点击[获取免费试用],并同意我们的隐私政策。您会接收到来自Altium的资讯,并允许其改变您的通知首选项。

好棒!创作是一件超酷的事情,我们可以为您提供完美的设计软件。

Upverter是一个社区导向的交流平台,专为您这样的创客量身定做。

点击这里看看吧!

如果您有任何需求,请点击这里联系获取当地办公室销售代表联系方式。.
Copyright © 2019 Altium Limited

好的,您可以下载免费的Altium Designer Viewer查看文档,有效期6个月。

请填写下方表格申请。

点击[获取免费试用],并同意我们的隐私政策。您会接收到来自Altium的资讯,并允许其改变您的通知首选项。