Using the WorkSpace Manager API

Old Content - visit altium.com/documentation

Parent page: Using the Altium Designer API

Using the Workspace Manager Interfaces

The Workspace Manager is a system extensions server which is always running when Altium Designer is loaded in memory. The Workspace Manager provides project functionality of grouping of files and provides a bridge between source documents (such as Schematic documents) and its corresponding primary implementation documents (such as PCB documents).

This Workspace Manager provides information on how a project is structured, information on nets and its associated net aware objects of source and implementation documents.

This Workspace Manager also provides you with the ability to manipulate the contents of a design project in Altium Designer.

The document interfaces in the Workspace Manager can refer to documents which may not be open in Altium Designer, whereas the IServerDocument interfaces only references loaded documents in Altium Designer. To have access to data within the Workspace Manager, you need to have access to the IWorkSpace interface object which references the workspace manager.

Simplified Workspace Manager Object hierarchy

IWorkspace
  IProject
    IDocument
        ISheetSymbol
        IComponent
        IBus

Main Workspace Manager Interfaces

  • The IDMObject interface is the ancestor interface used for many Workspace interfaces.
  • The IWorkSpace interface is the top level interface and contains many interfaces within. For example the IWorkSpace interface has a DM_OpenProject function which returns a currently open or currently focussed IProject interface.
  • The IProject interface represents the current project in Altium Designer.
  • The IPart interface represents a part of a multi-part component. This component is represented by this IComponent interface.
  • The IDocument interface represents a document in Altium Designer.
  • The IComponentMappings interface is used for the Signal Integrity models mapping to Schematic components.
  • The IECO interface represents the Engineering Change Order system in PCB and Schematic editors.
  • The INet interface is a container storing Net aware objects (which are INetItem interfaces) that have the same net property. So there are INet interfaces representing nets on a document.
  • The INetItem interface is the parent interface for the Cross interface. Pin, Port, Netlabel, Sheet entry and Power Object Interfaces are direct representations of the INetItem interface so these objects can be part of a net.

GetWorkspace function

The Function GetWorkspace : IWorkspace; returns the Workspace Manager interface object within your server project. With this interface, you can extract extra information about a project and its associated documents and their design objects on them.

Using the GetWorkSpace function in a DelphiScript

Var
    i        : Integer;
    Document : IDocument;
    Project  : IProject;
Begin
    Project := GetWorkspace.DM_FocusedProject;
    If Project = Nil Then Exit;
    For i := 0 To Project.DM_LogicalDocumentCount - 1 Do
    Begin
        Document := Project.DM_LogicalDocuments(i);
        ShowMessage(Document.DM_DocumentKind);
    End;
End;

Compiling a Project

A project needs to be compiled first so you can have access to the most current data which provides a snapshot of the latest status of a design project. There are two ways you can compile the project which are shown below.

Compile with Project.DM_Compile example

Procedure CompileProject;
Begin
    Project := GetWorkspace.DM_FocusedProject;
    If Project = Nil Then Exit;
    Project.DM_Compile;
    FileName := Project.DM_ProjectFullPath;
End;

Compile example using the MessageRouter_SendCommandToModule call

GetMem(P, 4048);
SetState_Parameter(P,'Action','Compile');
SetState_Parameter(P,'ObjectKind', 'Project');
MessageRouter_SendCommandToModule('WorkspaceManager:Compile',P,4048,Nil);
FreeMem(P);

For detailed information on Workspace Manager API, refer to the Technical Reference - Workspace Manager API document.
See the script examples in the Scripts\DelphiScript Scripts\DXP\ folder.

Nets of design documents

Schematic Design documents that have components and wires contain connectivity information which is captured in nets. A net is composed of connections and each connection is linked by a node as a pin. Nets are connected pins and a valid net has more than 1 pin.

To obtain connectivity information, we use the WorkSpace Manager API to fetch net information. Open a project with valid schematics and then going through each schematic, the net count is obtained and for each net, the pin count is obtained and we have pins at our disposal. With pin interfaces, we can fetch pin designator, pin number and so on.

The design project needs to be compiled first, the documents (IDocument interfaces) are obtained and then the Nets (INet interfaces) are obtained. For each net, IPin interfaces are again obtained.

Fetch Nets example using the INet interface

//net information is stored in the NetList TStringList container
For i := 0 To Document.DM_NetCount - 1 Do
        WriteNet(Document.DM_Nets(i));
 
Procedure WriteNet(Net : INet);
Var
    I       : Integer;
    Pin     : IPin;
    PinDsgn : String;
    PinNo   : String;
Begin
    If Net.DM_PinCount >= 2 Then
    Begin
        NetList.Add('(');
        NetList.Add(Net.DM_CalculatedNetName);
        For i := 0 To Net.DM_PinCount - 1 Do
        Begin
            Pin := Net.DM_Pins(i);
            PinDsgn := Pin.DM_PhysicalPartDesignator;
            PinNo   := Pin.DM_PinNumber;
            NetList.Add(PinDsgn + '-' + PinNo);
        End;
        NetList.Add(')');
    End;
End;

PCB Design documents also have net information, but these nets are captured in IPCB_Net interfaces. Refer to the Technical Reference - PCB API document for more information.
See the script examples in the Scripts\DelphiScript Scripts\WSM\ folder.

You are reporting an issue with the following selected text and/or image within the active document:
ALTIUM DESIGNER FREE TRIAL
Altium Designer Free Trial
Let’s get started. First off, are you or your organization already using Altium Designer?

If would like to speak with a representative, please contact your local Altium office.
Copyright © 2019 Altium Limited

In that case, why do you need an evaluation license?

If would like to speak with a representative, please contact your local Altium office.
Copyright © 2019 Altium Limited

Got it. You actually don’t need an evaluation license for that.

Click the button below to download the latest Altium Designer installer.

Download Altium Designer Installer

If would like to speak with a representative, please contact your local Altium office.
Copyright © 2019 Altium Limited

Please fill out the form below to get a quote for a new seat of Altium Designer.

By clicking “Get Your Free Trial”, you are agreeing to our Privacy Policy.
You may receive communications from Altium and can change your notification preferences at any time.

If you are on Altium Subscription, you don’t need an evaluation license.

If you are not an active Altium Subscription member, please fill out the form below to get your free trial.

By clicking “Get Your Free Trial”, you are agreeing to our Privacy Policy.
You may receive communications from Altium and can change your notification preferences at any time.

Why are you looking to evaluate Altium Designer?

If would like to speak with a representative, please contact your local Altium office.
Copyright © 2019 Altium Limited

You came to the right place! Please fill out the form below to get your free trial started.

By clicking “Get Your Free Trial”, you are agreeing to our Privacy Policy.
You may receive communications from Altium and can change your notification preferences at any time.

Sounds exciting! Did you know we offer special discounted student licenses? For more information, click here.

In the meantime, feel free to request a free trial by filling out the form below.

By clicking “Get Your Free Trial”, you are agreeing to our Privacy Policy.
You may receive communications from Altium and can change your notification preferences at any time.

Got it. You can download a free Altium Designer Viewer license which is valid for a 6 months.

Please fill out the form below to request one.

By clicking “Get Your Free Trial”, you are agreeing to our Privacy Policy.
You may receive communications from Altium and can change your notification preferences at any time.

That’s great! Making things is awesome. We have the perfect program for you.

Upverter is a free community-driven platform designed specifically to meet the needs of makers like you.

Click here to give it a try!

If would like to speak with a representative, please contact your local Altium office.
Copyright © 2019 Altium Limited

Got it. You can download a free Altium Designer Viewer license which is valid for a 6 months.

Please fill out the form below to request one.

By clicking “Get Your Free Trial”, you are agreeing to our Privacy Policy.
You may receive communications from Altium and can change your notification preferences at any time.