技术参考 - 原理图API

Parent page: Altium Designer API Reference

Please note that this documentation was last updated for an older version of Altium Designer. 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 Schematic Application Programming Interface (API) reference details the object interfaces for Schematic objects such as schematic documents and schematic design objects.

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.

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 Designer. The Schematic design object interfaces and methods are available in all script languages supported by Altium Designer.

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 the ISch_BasicContainer interface).
  • The ISch_Document, ISch_Sheet and ISch_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

Separate references for other Altium Designer APIs

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 Designer. 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 Designer. 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 Designer. 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.


 

If you find an issue, select the text/image and pressCtrl + Enterto send us your feedback.

软件的功能取决于您购买的Altium产品级别。您可以比较Altium Designer软件订阅的各个级别中包含的功能,以及通过Altium 365平台提供的应用程序所能实现的功能。

如果您在软件中找不到某个讨论过的功能,请联系Altium销售团队以获取更多信息。