Skip to main content
View as Markdown

API conventions

Namespaces​

NamespaceArea
SCHSchematic and schematic library documents, design objects, the schematic server.
PCBPCB and PCB library documents, design objects, the PCB server.
EDPProjects, documents and the workspace (the project manager).
DXPThe client application, servers, commands, views and notifications.

Entry points​

Each editor is reached through a static property of GlobalVars in Altium.SDK.dll (SCH.GlobalVars, PCB.GlobalVars, DXP.GlobalVars):

Entry pointTypeUse
SCH.GlobalVars.SchServerISch_ServerInterfaceSchematic documents, object creation, schematic preferences.
PCB.GlobalVars.PCBServerIPCB_ServerInterfacePCB documents and objects.
DXP.GlobalVars.ClientIClientThe application: documents, views, commands.

An entry point is null when its server is not loaded, so check before use.

Interfaces and properties​

The API is a set of interfaces; objects are never created with new but obtained from the servers, documents and iterators. Interfaces form hierarchies: ISch_Component is an ISch_ParametrizedGroup, which is an ISch_GraphicalObject, and so on. Each reference page lists the members an interface inherits.

An object's state is read and written through accessor methods: GetState_<Name>() reads and SetState_<Name>(value) writes. The reference shows each pair as one property page:

TRotationBy90 orientation = component.GetState_Orientation();
component.SetState_Orientation(TRotationBy90.eRotate90);

A property with only a GetState_ accessor is read-only. Some interfaces use other prefixes (Get_/Set_, GetProperty_/SetProperty_, or plain Get/Set pairs such as GetModified/SetModified); they are grouped the same way. Indexed properties take the index as the first argument (GetState_AliasAt(index)).

Typed helper methods​

Many methods are provided as extension methods of a static helper class next to the interface, such as ISch_ComponentHelper for ISch_Component. The helpers return and accept the specific interface and enumeration types, for example ISch_Designator from GetState_SchDesignator() and TRotationBy90 for SetState_Orientation. With using SCH; they are called like interface methods:

using SCH;

ISch_Designator designator = component.GetState_SchDesignator();

They can also be called as static methods: ISch_ComponentHelper.GetState_SchDesignator(component). The reference documents the typed form and notes on each page when a method comes from a helper class.

Enumerations and object sets​

Enumeration values carry their type's prefix convention, such as eWire and eSchComponent in TObjectId. Filters that take a set of values use the *Set classes, such as SCH.TObjectSet:

var objectSet = new SCH.TObjectSet();
objectSet.Add(SCH.TObjectId.eWire);

Coordinates​

Coordinates are integers in internal units. EDP.Utils converts between internal units and mils or millimetres (MilsToCoord, CoordToMils, MMsToCoord, CoordToMMs); see EDP.Utils.