Schematic API Functions

Old Content - visit altium.com/documentation

Parent page: Technical Reference - Schematic API

Schematic API: Functions Reference

The Schematic API Functions reference includes the following content:

SchServer Interface
General functions
Measurement Conversion functions
Conversion functions

SchServer Interface

Function SchServer : ISch_ServerInterface;

Description
The SchServer function returns the interface of the loaded Schematic Editor module in Altium Designer. To work with Schematic objects, you need to have access to the ISch_ServerInterface interface first. To obtain the current schematic document, invoke the SchServer.GetCurrentSchDocument for instance.

Refer to the ISch_ServerInterface’s methods and properties for more information.

Example 1

    // Grab current schematic document.
    SchDoc := SchServer.GetCurrentSchDocument;
    If SchDoc = Nil Then Exit;
 
    // Component is a container that has child objects
    // Create component, and its rectangle, pin and parameter objects.
    Component := SchServer.SchObjectFactory (eSchComponent, eCreate_Default);

Example 2

   Try
       SchServer.ProcessControl.PreProcess(SchDoc, '');
 
       // Add the parameter to the pin with undo stack also enabled
       Param.Name := 'Added Parameter';
       Param.Text := 'Param added to the pin. Press Undo and this will disappear.  Press undo twice to remove the component';
       Param.Location := Point(InchesToCoord(3), InchesToCoord(2.4));
 
       Pin.AddSchObject(Param);
       SchServer.RobotManager.SendMessage(Component.I_ObjectAddress, c_BroadCast, SCHM_PrimitiveRegistration, Param.I_ObjectAddress);
   Finally
       SchServer.ProcessControl.PostProcess(SchDoc, '');
   End;

See also
ISch_ServerInterface interface

General functions

AlignToGridClosest

Function AlignToGridClosest  (AValue    : TCoord; AGridSize : TCoord) : TCoord;

AlignToGridDecrease

Function AlignToGridDecrease (AValue    : TCoord; AGridSize : TCoord) : TCoord;

AlignToGridIncrease

Function AlignToGridIncrease (AValue    : TCoord;
                              AGridSize : TCoord) : TCoord;

GetState_AllImplementations

Function GetState_AllImplementations (Const ASchComponent  : ISch_Component)       : TList;

GetState_PinsForCurrentMode

Function GetState_PinsForCurrentMode (Const ASchComponent  : ISch_Component)       : TList;

GetState_AllPins

Function GetState_AllPins            (Const ASchComponent  : ISch_Component)       : TList;

GetState_AllParameters

Function GetState_AllParameters      (Const ASchObject     : ISch_BasicContainer)  : TList;

HitTestResultToCursor

Function  HitTestResultToCursor(T : THitTestResult): TCursor;

GetDefaultSchSheetStyle

Function  GetDefaultSchSheetStyle : TSheetStyle;

GetWholeAndFractionalPart_DXP2004SP2_To_DXP2004SP1

Procedure GetWholeAndFractionalPart_DXP2004SP2_To_DXP2004SP1(ACoord : TCoord; Var AWholePart, AFractionalPart : Integer);

GetCoord_DXP2004SP1_To_DXP2004SP2

Function  GetCoord_DXP2004SP1_To_DXP2004SP2(AWholePart, AFractionalPart : Integer) : TCoord;

ConvertFileName_99SEToDXP2004

Function ConvertFileName_99SEToDXP2004(Const AOriginalName, ADocKind : TDynamicString) : TDynamicString;

GetResolvedSheetFileName

Function GetResolvedSheetFileName(Const AOriginalSFN : TDynamicString; Const AProject : IProject) : TDynamicString;

Sch_GetOwnerProject

Function Sch_GetOwnerProject(Const AContainer : ISch_BasicContainer) : IProject;

Measurement Conversion functions

//Imperial functions
Function  CoordToMils        (    C : TCoord) : TReal;
Function  CoordToDxps        (    C : TCoord) : TReal;
Function  CoordToInches      (    C : TCoord) : TReal;
Function  MilsToCoord        (    M : TReal)  : TCoord;
Function  DxpsToCoord        (    M : TReal)  : TCoord;
Function  InchesToCoord      (    M : TReal)  : TCoord;
 
//Metric functions
Function  CoordToMMs         (    C : TCoord) : TReal;
Function  CoordToCMs         (    C : TCoord) : TReal;
Function  CoordToMs          (    C : TCoord) : TReal;
Function  MMsToCoord         (    M : TReal)  : TCoord;
Function  CMsToCoord         (    M : TReal)  : TCoord;
Function   MsToCoord         (    M : TReal)  : TCoord;
 
Function  MetricString(Var S : TDynamicString; DefaultUnits : TUnit) : Boolean;
Function  ImperialString(Var S : TDynamicString; DefaultUnits : TUnit) : Boolean;
 
Function  CoordUnitToString       (C : TCoord; U : TUnit) : TDynamicString;
 
Function  CoordUnitToStringWithAccuracy  (ACoord         : TCoord;
                                          AUnit          : TUnit;
                                          ARounding      : Integer;
                                          AFixedDecimals : Integer) : TDynamicString;
 
Function  ExtractValueAndUnitFromString(AInString : TDynamicString;
                                        ADefaultUnit : TUnit;
                                    Var AValue       : TDynamicString;
                                    Var AUnit        : TUnit) : Boolean;
 
Function  StringToCoordUnit       (S : TDynamicString; Var C : TCoord; ADefaultUnit : TUnit) : Boolean;
 
Function  CoordUnitToString       (C : TCoord; U : TUnit) : TDynamicString;
 
Function  CoordUnitToStringFixedDecimals (C : TCoord; U : TUnit; AFixedDecimals : Integer) : TDynamicString;
 
Function  CoordUnitToStringNoUnit (C : TCoord; U : TUnit) : TDynamicString;
Function  CoordUnitToStringWithAccuracy  (ACoord         : TCoord;
                                          AUnit          : TUnit;
                                          ARounding      : Integer;
                                          AFixedDecimals : Integer) : TDynamicString;
 
Function  GetDisplayStringFromLocation(ALocation : TLocation; AUnit : TUnit) : TDynamicString;
 
Function GetCurrentDocumentUnit : TUnit;
Function GetCurrentDocumentUnitSystem : TUnitSystem;
Function GetSchObjectOwnerDocumentUnit(Const AObject : ISch_BasicContainer) : TUnit;

Conversion functions

Function  GetStateString_ObjectId                 (N : TObjectId                 ) : TString;
Function  GetStateString_HorizontalAlign          (N : THorizontalAlign          ) : TString;
Function  GetStateString_IeeeSymbol               (N : TIeeeSymbol               ) : TString;
Function  GetStateString_LeftRightSide            (N : TLeftRightSide            ) : TString;
Function  GetStateString_LineStyle                (N : TLineStyle                ) : TString;
Function  GetStateString_PinElectrical            (N : TPinElectrical            ) : TString;
Function  GetStateString_PortArrowStyle           (N : TPortArrowStyle           ) : TString;
Function  GetStateString_PortIO                   (N : TPortIO                   ) : TString;
Function  GetStateString_PowerObjectStyle         (N : TPowerObjectStyle         ) : TString;
Function  GetStateString_CrossSheetConnectorStyle (N : TCrossSheetConnectorStyle ) : TString;
Function  GetStateString_RotationBy90             (N : TRotationBy90             ) : TString;
Function  GetStateString_Justification            (N : TTextJustification        ) : TString;
Function  GetStateString_HorizontalJustification  (N : TTextJustification        ) : TString;
Function  GetStateString_VerticalJustification    (N : TTextJustification        ) : TString;
Function  GetStateString_SheetStyle               (N : TSheetStyle               ) : TString;
Function  GetStateString_Size                     (N : TSize                     ) : TString;
Function  GetStateString_Location                 (N : TLocation                 ) : TString;
Function  GetStateString_DisplayMode              (N : TDisplayMode              ) : TString;
 
Function  GetStateString_LineShape    (N : TLineShape) : TString;
Function  GetStateString_ObjectIdPlural(N : TObjectId) : TString;

Justification functions

Function  IsJustified_Left    (N : TTextJustification) : Boolean;
Function  IsJustified_HCenter (N : TTextJustification) : Boolean;
Function  IsJustified_Right   (N : TTextJustification) : Boolean;
Function  IsJustified_Bottom  (N : TTextJustification) : Boolean;
Function  IsJustified_VCenter (N : TTextJustification) : Boolean;
Function  IsJustified_Top     (N : TTextJustification) : Boolean;
Procedure GetOrdinalValueFromHorizontalJustification(J : TTextJustification;Var I : Integer);
Procedure GetOrdinalValueFromVerticalJustification  (J : TTextJustification;Var I : Integer);
Procedure GetHorizontalJustificationFromOrdinalValue(I : Integer; Var J : TTextJustification);
Procedure GetVerticalJustificationFromOrdinalValue  (I : Integer; Var J : TTextJustification);
 

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.