技术参考 - 原理图API
Parent page: Altium NEXUS API Reference
The Schematic Application Programming Interface (API) reference details the object interfaces for Schematic objects such as schematic documents and schematic design objects.
The Schematic Object Model and Functions
The Schematic API consists of the Schematic Object model and Schematic API functions. The Schematic API is made accessible by the Schematic Editor in Altium NEXUS. The Schematic design object interfaces and methods are available in all script languages supported by Altium NEXUS.
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. While interfaces are declared like classes, they cannot be directly instantiated and do not have their own method definitions. The Schematic design objects are wrapped by their corresponding Schematic interfaces, which makes it possible to manipulate those objects by scripts and server code.
Main Schematic Object Interfaces
- The
ISch_ServerInterface
interface is the main interface in the Schematic API and represents the main Schematic Editor object.The ISch_ServerInterface
interface is the gateway to fetching other Schematic objects. - The
ISch_GraphicalObject
interface is a generic interface used for all Schematic design object interfaces (inherited from theISch_BasicContainer
interface). - The
ISch_Document
,ISch_Sheet
andISch_Lib
interfaces represent an existing Schematic or library documents.
SchServer function
To obtain the Schematic interface that represents the Schematic editor object, invoke the SchServer
function in a script to return the ISch_ServerInterface
interface. This object interface obtains the Schematic editor server object so you can then extract data from existing Schematic objects and invoke the Schematic object's methods.
For example, the SchServer
function is highlighted in the code snippet below:
Var
Sheet : ISch_Sheet;
Begin
Sheet := SchServer.GetCurrentSchDocument
If Sheet = Nil then Exit;
// do something here
End;
Script Examples
Schematic script examples that demonstrate the use of Schematic interfaces can be found in the \Examples\Scripts\DelphiScript\SCH
folder.
References for the Schematic API
- Schematic API System Interfaces
- Schematic API Component Mapping
- Schematic API Design Objects Interfaces
- Schematic API Constants
- Schematic API Types
- Schematic API Functions
Separate references for other Altium NEXUS APIs
- System API Object Model - refer to the System API Reference
- PCB Object Model - refer to the PCB API Reference
- Workspace Manager Object Model - refer to the Workspace Manager API Reference
- Integrated Library Object Model - refer to the Integrated Library API Reference
Schematic Object Model Hierarchy
The Schematic Object Model compromises of Schematic Object Interfaces and standalone utility functions that allow you to deal with Schematic objects from a Schematic document that's open in Altium NEXUS. An object interface is just a means of access to an object in memory.
To have access to the Schematic Editor server and manipulate common schematic design objects, you need to invoke the SchServer
function. This extracts the ISch_ServerInterface
interface, which represents the loaded schematic server in Altium NEXUS. The ISch_ServerInterface
interface is the main server object interface and contains sub object interfaces within, as shown in the diagram below.
The ISch_ServerInterface
and ISch_Document
object interfaces, amongst others, are the main object interfaces used when working with a opened schematic document in Altium NEXUS. See the Schematic API System Interfaces reference for more information.
Schematic Object Interfaces Hierarchy Map
The following diagrams represent examples of the hierarchy map for schematic design objects. In all cases, the ISch_BasicContainer
interface (which represents a schematic object's parent or child objects) is the ancestor object interface. For more information see the Schematic API System Interfaces reference.
All the descendant interfaces inherit methods and properties from their immediate parent interfaces. For example the ISch_Pie
interface has its own methods and properties as well as inherited methods and properties from the ISch_Arc
, ISch_GraphicalObject,
and finally the ancestor ISch_BasicContainer
interfaces. In the diagram below, the descended ISch_Pie
interface is shown at the right.
The below hierarchy example diagram shows the inherited sequence from the ISch_BasicConatiner
ancestor interface down to the ISch_Designator
and IOpenBus_Component
interfaces.
A further, more complex, interface hierarchy diagram (below) showing the descendants of the ISch_Label and ISch_ParametizedGroup interfaces. Methods and properties are inherited down the hierarchical chain from the ISch_BasicContainer interface to the ISch_GraphicalObject interface, and so on.