Using the Altium Design Software API

This documentation page references Altium NEXUS/NEXUS Client (part of the deployed NEXUS solution), which has been discontinued. All your PCB design, data management and collaboration needs can now be delivered by Altium Designer and a connected Altium 365 Workspace. Check out the FAQs page for more information.

 

Parent page: Altium NEXUS API

Please note that this documentation was last updated for an older version of Altium NEXUS. While many of the principles and approaches will remain the same, be aware that interfaces, objects, methods, properties, and the like will have changed since then, and will not reflect the entirety of those found in later versions of the software.

The Altium NEXUS 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 NEXUS.

In the scripting system, we refer to the Object Models because we are only dealing with object interfaces that represent objects in the Altium NEXUS. 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 NEXUS 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 NEXUS APIs in scripts see:

DXP Software Technology platform

Altium NEXUS'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 NEXUS: the client/server architecture technology, APIs, DXP Object Models, and object oriented technologies.

Altium NEXUS 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 NEXUS API.

Client - Executable /Server - DLL paradigm
Client - Executable /Server - DLL paradigm

The Client executable is a standalone executable system that collaborates with loaded DLL servers within Altium NEXUS. 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 NEXUS commands invoked by the user.

Editor Server services

An editor server provides its services within Altium NEXUS. 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 NEXUS is exposed by that server's processes and its exposed functions.

Main Altium NEXUS Servers

The Workspace Manager module is a system extensions server coupled tightly with the client module within Altium NEXUS. 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 NEXUS. A document can be represented by two ways - as seen by the Workspace Manager and as seen by the Editor (Server).
A project and its design documents in Altium NEXUS. 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 NEXUS: 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 NEXUS API in scripts

The scripting engine in Altium NEXUS 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 NEXUS 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 NEXUS 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 NEXUS.

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 Overview & Setup 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 NEXUS framework.

Server development with the Altium NEXUS API

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

Using the Altium NEXUS Object Models

In Altium NEXUS, 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 NEXUS (such as the board, document, PCB objects etc).

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

The projects and the corresponding documents are managed by the Workspace Manager. As indicated in the above image, a project open in Altium NEXUS 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 NEXUS 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 NEXUS 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 NEXUS 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 interface.
If you find an issue, select the text/image and pressCtrl + Enterto send us your feedback.
Content