Delphi Compiler Defines

Posted on by  admin
  1. Delphi Compiler Directives
  2. Delphi Define Directive
  3. Delphi Compiler Defines Download

1) You could add these defines in a separate (include) file. Create a new text file, add the global defines in it and save it as for instance MyOptions.inc (it is more or less a standard to give this file an.inc extension).

Sometime we need some special directories path from Microsoft Windows system to store User data or to copy some files etc. So we can get those folder paths in Delphi in several ways. In this blog I have tried to cover all the ways. If I have left something please feel free to add comments. By using Windows API function SHGetFolderPath Delphi provides SHGetFolderPath API function which helps us to get windows system folder paths. We need to use ShlObj unit in uses clause. For more details about SHGetFolderPath please visit following link Here at following I have created a string function GetSpecialFolderPath using SHGetFOlderPath API function which will return all special Windows folder path as per CSIDLFolder value. Function GetSpecialFolderPath(CSIDLFolder: Integer): string; var FilePath: array 0.MAXPATH of char; begin SHGetFolderPath(0, CSIDLFolder, 0, 0, FilePath); Result:= FilePath; end; // to get DESKTOP folder location // procedure TForm1.Button2Click(Sender: TOb.

In this blog I will describe how to read and write data from and to an Excel file. Sometime in our application we use Excel for reporting purpose, for data import / export purpose and for other works. So here I will explain how to access an Excel file and use for data read / write. For this Excel 2003 or later should have installed in our system.

First use Excel2000 unit to uses clause. This unit comes with Delphi installation it self. You can get the unit in installed path C: Program Files (x86) Embarcadero RAD Studio 10.0 OCX Servers Uses Excel2000; Before proceed I would mention an important word LCID which is required at most places. So what it LCID? LCID = In Microsoft Excel, the LCID indicates the currency symbol to be used when this is an xlListDataTypeCurrency type. Returns 0 (which is the Language Neutral LCID) when no locale is set for the data type of the column.

We can get LCID in Delphi by using GetUserDefaultLCID function. Private LCID: Cardinal. //assigned on. Today in most of software program it is required to send mail to others with attached data.

As some time we need to update clients about their account details, status or any other information through mail. So Delphi provides so many easiest ways to send mail from our Delphi application. I have collected some of ways which are very useful for Delphi developers. In Delphi we don't required any third party components to send mails. We can send mail to single or group of peoples with CC, BCC and attachments.

Even we can send HTML mails from Delphi. So here are the ways. ShellExecute Sends Email using default mail client software installed on user's system.

But it will not work with attachment for every mail client. And you have to use ShellAPI unit in uses list.

ShellExecute(Self.Handle, nil, 'mailto:' + 'jiten.g.s001@gmail.com' + '?Subject=Test Message Subject' + '&Body=Test Message Body&.

Contents. Note: This document subject to updates to support Altium's latest technology. This document guides you in the process of developing an Extension server for the PCB Editor, and how to update the Altium Designer's PCB Editor's menus automatically. See document for an introduction to the SDK.

The Altium Designer software integration platform (also called the DXP software technology platform, or DXP platform for short) is based on the client-server architecture. The DXP platform allows software extensions to work together and behave as a single design application, and provides you with an integrated and customizable user interface. This integrated platform provides developers a ready-built environment to develop modules that extend or enhance the existing functionality of Altium Designer.

The Altium Designer SDK provides a set of source units and source code examples that allow you to develop software extension modules. Altium Designer has a range of built in software products that provide specialized functionality such as the PCB editor and the Integrated Library server. Other software extensions can be developed as add-ons to enhance the functionality of an Altium Designer server that has an Application Programming Interface (API) such as PCB API.

You can also port your existing Altium Designer scripts to a server extension, mainly to lock the code and to speed up the functionality. A software module developed with the SDK is generally referred to as an Extension or Server in this document, however a software extension can be implemented in a number of forms, depending on its functionality and how it integrates with Altium Designer. Software extensions can act as design editor add-ons, design file editors, output generators, workspace extensions and more. All act as servers in the Altium Designer client-server architecture, and 'extend' its functionality – hence the moniker 'extension'.

The software extension developed in the example project below acts as an add-on for the PCB Editor. Client / Server Architecture Altium Designer consists of the DXP platform as the client module which hosts extension server applications. A server here is basically a Dynamic Link Library (DLL) module installed in Altium Designer that has the algorithms and data structures needed to provide specific services or functionality. It can also be called a server module (or just server) within Altium Designer's client-server architecture. The PCB and Schematic editors are examples of servers. These servers harness Altium Designer's interface elements for communication between the user and the computer.

The figure above shows the conceptual bridge within the Altium Designer application, where the client side consists of the DXP platform module. On the other side of the bridge, the server side consists of the Workspace Manager system module, the Schematic Editor module, PCB editor, additional software extensions, and so on. The WorkSpace Manager module is a system server, while the Hole Size Editor for the PCB Editor, for example, is an add-on extension that uses the PCB Editor's Application Programming Interface so that it can deal with the PCB objects on a PCB document.

Providing services in Altium Designer In Altium Designer, a extension module (as a server) provides its specialized services in the Altium Designer environment, and interfaces to the system's Graphical User Interface (GUI) through commands. A command can be thought of as the software executing a sequence of tasks. This task can be as simple as redrawing the screen on the monitor, or it may be more complex like generating a Bill of Materials (BOM) report.

Delphi

Commands are the basic units of Altium Designer's GUI. A command is a packaged process launcher which is linked to a resource item in Altium Designer, for example the PCB's View » Area menu item is a PCB command which has a PCB:Zoom process launcher. A process launcher is linked to a resource item in Altium Designer and can be assigned to a key, toolbar button or a menu item. When you launch a command, a process launcher is invoked. Basically, each server has its own list of processes.

These processes with their parameters are packed as process launchers that are linked to commands in the Altium Designer's GUI. Whenever a command is invoked through the GUI, the process launcher is routed to the appropriate server. This server then interprets the process launcher as a process string with parameters. To have a server function in Altium Designer, this server needs to have the APIs linked in and several configuration files such as the server installation file (with an INS extension).

The APIs provide the necessary protocols for the server to interact within the Altium Designer environment, and the server installation file provides a list of available server processes of the server. Altium Designer SDK The Altium Designer SDK contains API source files, which when compiled and bundled, allow your server to work in Altium Designer. The files can be found in the installation's SDK Source Code folder.

When you want to use a particular function, you need to add the corresponding unit in the Uses clause of your server code project. For example, using the MessageRouterSendCommandToModule procedure, you need to add the SDK's EPDUtil source unit in the Uses clause. Otherwise the Embarcadero Delphi compiler will report an Undeclared identifier error message in the Message window. You can check out the files in the SDK Source Code folder to see the variable and object declarations/interfaces.

Delphi Compiler Directives

Altium Designer Object Interfaces An Object Interface that represents a design object in Altium Designer will have methods and properties listed (note that some interfaces will only have methods listed);. A method is a procedure or function that is invoked from its interface. Methods of Object Interfaces are the actions an Object Interface can perform. A property of an object interface is like a variable; you get or set a value in a property, but some properties are read only properties, so they can only return values and cannot be set.

Properties of object interfaces represent the data contained in the object that is represented by the interface. Kumki movie. For example the IDispPCBComponent interface from the PCB API has a Height property and two associated methods.

Note that the IDispPCBComponent declaration comes from the PCB API in the Altium Designer SDK. IDispPCBComponent interface declaration. IDispPCBComponent = DispInterface. Function GetStateHeight: Integer; Procedure SetStateHeight (Value: Integer); Property Height: IntegerRead GetStateHeight Write SetStateHeight. End; Object Model Hierarchy A parent object interface can have child object interfaces and in turn, child object interfaces can act as parent object interfaces and have child object interfaces and so on. This forms an Object Model Hierarchy.

For example, in the EDP SDK, the IWorkspace Object Interface is the top level interface representing the Workspace manager in Altium Designer. Projects are part of the Workspace Manager, therefore an IProject interface is a child interface from the parent IWorkspace interface.

Design objects such as sheet symbols, components and buses are child objects of the document object (represented by the IDocument interface). This is illustrated in a simple hierarchy example below: IWorkspace IProject IDocument ISheetSymbol IComponent IBus A relationship exists between objects in Altium Designer and the object Interfaces supported by the various APIs from the Altium Designer SDK. Projects and the corresponding documents are managed by the Workspace Manager. A project open in Altium Designer is represented by the IProject object interface.

The documents from this project are represented by the IDocumentinterfaces. The PCB documents and PCB design objects are managed by the PCB Editor and its PCB Object Model.

The PCB document open is represented by its IPCBBoard interface and the design objects (for example, a pad object and a track object) are represented by IPCBPad and IPCBTrack interfaces. Altium Designer APIs The Altium Designer SDK has a DXP Platform API and several software product APIs:. Client API. Integrated Library API.

WorkSpace Manager API. Schematic API. PCB API Figure 2 below is an illustration of the relationship between objects in the Altium Designer application and the object interfaces supported by the Altium Designer SDK. This shows the PCB and Workspace Object Interfaces in Altium Designer, where the projects and the corresponding documents are managed by the Workspace Manager. An open project in Altium Designer is represented by the IProject object interface, and the documents from this project are represented by the IDocument interfaces. Figure 2: The PCB and Workspace Object Interfaces in Altium Designer.

Furthermore, the PCB documents have PCB objects which are accessed by the PCB API. The open PCB document open is also represented by its IPCBBoard interface and design objects, for example the pad object and the track object are represented by IPCBPad and IPCBTrack interfaces respectively. The PCB API provides PCB interfaces to use in scripts and server module projects. The PCB API allows a programmer to modify PCB objects and their attributes from a PCB document. PCBServer Function When you need to work with PCB design objects in Altium Designer the starting point is to invoke the PCBServer function. With the IPCBServerInterface interface returned (see the EDPInterfacesPCB source unit), you can extract all other derived PCB interfaces that are exposed in the IPCBServerInterface interface.

For example to get an access to the current PCB document, you would invoke the GetCurrentPCBBoard method from the I PCBServerInterface interface object from your server code. To use PCB interfaces, you need to obtain the IPCBServerInterface object by invoking the PCBServer function. The IPCBServerInterface interface is the gateway to other PCB object interfaces. The IPCBBoard interface points to an existing PCB document in Altium Designer.

GetCurrentPCBBoard Example Var TheServer: IPCBServerInterface; TheBoard: IPCBBoard; TheFileName: String; Begin TheServer:= PCBServer; If TheServer = Nil Then Exit; TheBoard:= PCBBoard.GetCurrentPCBBoard; If TheBoard = Nil The Exit; TheFileName:= TheBoard.FileName; End; For detailed information on PCB API, refer to the. Building and running an SDK example project in Altium Designer A good place to start in developing your own software extensions for Altium Designer with the SDK is to examine and build one of the example projects provided with the SDK. This section shows you how to build an example add-on extension server that uses the PCB API to interact with an opened PCB design document in Altium Designer, where it counts the number of pad objects on the document.

This extension displays the number of pads in a dialog or in a text document in Altium Designer. When installed in Altium Designer and fully configured, the add-on extension will add three new menu items to the PCB menu, along with two new buttons on a new floating toolbar. To build and run the example, you will need a copy of Embarcadero Delphi development tool ( XE2 or better).

The Embarcadero Delphi Starter edition is a low cost alternative to Embarcadero's more elaborate development suites. Setting up your Server Project To start the process, open the Embarcadero Delphi tool and navigate to the SDK Examples AddOn Complete folder (depending on where your copy of the SDK is installed on your computer). The folder should contain, amongst others, the files listed in the table further below. Note that the Delphi project files will be located in the SDK AddOn Complete D2010 folder.

Your Windows installation may not have the necessary folder write permissions to allow Delphi to create files in the SDK Examples AddOn Complete folder, resulting in a Delphi complier error. Typically, this would be when the SDK is installed in the. Program Files folder on a Windows 7 machine. In this case just copy the Add-on project into a folder that's in a more suitable location. For example C: SDK Projects. My Documents SDK Projects. This approach also avoids corrupting the source example files provided in the SDK installation itself.

To build a server DLL that will interact with Altium Designer, Delphi must be able to find the Altium Designer SDK API files build the project. These are located in the SDK installation's Source Code folder.

The search and file output paths need to be defined in Delphi's compiler options. With the AddOn project loaded in Delphi ( File » Open Project), click Project » Options from the Delphi menu to open the Project Options dialog. Select the Debug option from the Build Configuration pull down menu, then populate or edit the following fields: Output directory: This is where the compiler will generate the Add-on project DLL. So the DLL will be generated in the project root folder. Unit output directory: This is where the compiler generates the compiled unit files (.dcu), which are linked to create a single executable.

Dcu so they collect in a single folder within the project. Search path: The location of the source unit files, which should include the SDK source files. To add the SDK API units, click in the Search Path field then use the navigator button (at the right) to open the Search Path dialog. Use the path browse button to select the SDK source code folder for your installation. Click Add to include the path, then OK to close the dialog. Note that Delphi's inherent $(BDS) lib source path (and possibly others) is inherited from the Base Configuration compiler settings.

Figure 3: Setting the path to the API in the Project Options dialog in the Embarcadero Delphi application. Figure 4: Adding the SDK source file units to Delphi's search path. The project Source Code A extension server as a dynamic library linking (DLL) module is constructed from Altium Designer API files (units).

The files used for this Add-on project, as described in the tables below, are stored in the project folder. The units that make up the project are stored in a Delphi project folder (for the SDK examples, the AddOn Complete D2010 folder): Add-on files Description AddOn.dproj The Delphi project file for the Add-on server. AddOn.res The Delphi -generated resources file (binary) for this server project. AddOn.dpr The Delphi Library project file Addon source and configuration files are stored in the Server Project folder ( AddOn Complete): Add-on files Description AddOn.Ins The Add-on's server installation file.

AddOn.rcs The Embarcadero Delphi resources file for this server project. Commands.pas The commands unit for the server. You also define the commands (processes) in this unit – which is the interface between the DXP platform and the extension server Main.pas This unit is responsible for creating and destroying the Add-on server. The project's command table that stores the commands is managed here. When the server is loaded, its TServerModule object and its associated IServerModule interface handles all the low level protocol for communicating in Altium Designer. Other files: The project folder includes additional files for expanding the project - along with extra source units, these include display form and icon files.

Since a server DLL is a library module, there is an Exports directive which exposes the some of the functionality from the server into the Altium Designer (see listing for the Add-on example project below). In this case, a PlugInFactory routine from the server project, when instantiated, is exposed in the DXP platform. This routine is defined in the main.pas unit. It takes in the IClient object interface which represents the DXP platform, and this same routine creates a single unique server module which stays in memory until Altium Designer is closed down. Code Listing 1: AddOn.dpr.

Uses SysUtils, Classes, Windows, Dialogs, EDPParam, // Contains all the functions for server parametric process processing. EDPUtil, // Contains EDP utility functions.

EDPTypes, // Contains types used for the Client, Server and Workspace. EDPClasses, // Contains base classes for Client, Server and Workspace interfaces. EDPInterfaces, // Contains Client, Server and Workspace interfaces.

EDPTypesPCB, // Contains types used for PCB. EDPClassesPCB, // Contains base classes for PCB interfaces. EDPInterfacesPCB; // Contains PCB interfaces. Searching PCB objects on a PCB document Note the CountPadObjects procedure that's defined in the commands.pas unit (Code Snippet 2, below).

This routine counts the pad objects on the current PCB document using an object search mechanism called an iterator. The CountPadObjects procedure counts the pad objects on a currently focused document using the PCB API. The database system of the PCB editor stores objects such as pads, vias, tracks etc.

So to have access to the objects in the PCB database that represents the current PCB document from an extension server, we use an iterator derived from the PCB Board object (IPCBBoard interface). Code Snippet 2: The CountPadObjects procedure in commands.pas. Procedure CountPadObjects(DisplayOnText: Boolean); Var Board: IPCBBoard; Pad: IPCBPrimitive; Iterator: IPCBBoardIterator; PadNumber: Integer; PadNumberString: String; PCBFileName: String; PCBServer: IPCBServerInterface; Begin PadNumber:= 0; PCBServer:= PCBServer; If PCBServer = Nil Then Exit; // retrieve the interface representing the PCB document Board:= PCBServer.GetCurrentPCBBoard; If Board = Nil Then Exit; // Obtain PCB document filename and path, then change the file extension. PCBFileName:= Board.FileName; // retrieve the board iterator Iterator:= Board.BoardIteratorCreate; Iterator.AddFilterObjectSet(ePadObject); Iterator.AddFilterLayerSet2(cAllLayers); Iterator.AddFilterMethod(eProcessAll); // search and count pads Pad:= Iterator.FirstPCBObject; While (Pad Nil) Do Begin PadNumber:= PadNumber + 1; Pad:= Iterator.NextPCBObject; End; Board.BoardIteratorDestroy(Iterator); // Convert the integer type to a string type. PadNumberString:= IntToStr(PadNumber); If DisplayOnText Then Begin // Display the results onto a text document ExportResultsToTextEditor(PCBFilename,PadNumberString); End Else Begin // Display the results on a dialog DisplayResultsOnDialog(PadNumberString); End; End; An iterator is a compact method of accessing PCB objects without creating a mirror database across the PCB API. So the iterator is issued once to set up the search mechanism, and the interface representing the pad object found is always issued with a unique value every time a pad object is found. If this pad interface is zero, it implies that there are no more pads to find in the database.

This is shown in Code Snippet 3 below. Code Snippet 3: Iterator (within above Procedure) in commands.pas. // retrieve the board iterator Iterator:= Board.BoardIteratorCreate; Iterator.AddFilterObjectSet(ePadObject); Iterator.AddFilterLayerSet2(cAllLayers); Iterator.AddFilterMethod(eProcessAll); // search and count pads Pad:= Iterator.FirstPCBObject; While (Pad Nil) Do Begin PadNumber:= PadNumber + 1; Pad:= Iterator.NextPCBObject; End; Board.BoardIteratorDestroy(Iterator);); Once the last pad object is found, the Board Iterator object is no longer needed and is therefore destroyed.

Server Processes and Parameters A parametric server process allows the information that a server process needs to be passed when the server process is called. The ability to pass server process parameters allows direct control over the operation of a server process. A parametric server process is a process with multiple parameters (a multiple name and value block) which could be used to dictate the course of this process. This method can be used instead of having multiple processes to do similar tasks in Altium Designer. The parameters format for the Parameters variable, as part of the server process procedure that normally has the CommandNameOfProcess format, is composed of two identifiers as a block; the parameter name and the parameter value.

Each block is separated by the Pipe symbol. A typical Parameters block will look like this. DocumentName1=4Port.PCB DocumentName2=MyDesign.PCB DocumentName3=Report.TXT From this example, the GetStateParameter function processes the Parameters parameter to match the parameter value (which has the following format, DocumentName1, DocumentName2 etc) and returns the result (Value only which contains the actual document name), if any, into the value. It continues until there are no more DocumentName parameters. This function is not destructive; that is, the original Parameters parameter is not altered. The routines that massage server parametric processes are defined in the EDPParam unit as part of the Altium Designer SDK. A process procedure is defined in the commands unit, and you can add your logic in this unit to interpret and extract required values of names from the Parameters variable.

In Code Snippet 4 (in the Commands.pas unit of a server project) the CommandCountPadObjects is the entry point where Altium Designer registers a server-specific process in its command launcher table. The pad count is displayed in a text document or on a dialog depending on the value of the Display parameter for the CountPads server process.

Code Snippet 4: Altium Designer to Add-on server entry point in commands.pas. Procedure CommandCountPads(View: IServerDocumentView; Parameters: WideString); Var S: TDynamicString; Begin // Check the parameters passed in by Altium Designer GetStateParameter(Parameters,'DISPLAY',S); // If Display = True then post results on a text document otherwise post on a dialog. If UpperCase(S) = 'TRUE' Then CountPadObjects(True) Else CountPadObjects(False); End; If the server process has the Display = True parameter, then the procedure call is made to bring up the text editor so the pad count results will be displayed in a new text document.

It will be saved as a text file with the same name as the PCB document, but with a.TXT extension, in the folder that holds the current PCB document. See Code Snippet 5 below.

Alternatively, if the Display=False condition is met, a dialog box is called to display the number of pads found - see Code Snippet 6. The parameter comes from the CommandCountPads procedure in the main.pas unit. Code Snippet 5: Export to text procedure in commands.pas. Procedure DisplayResultsOnDialog(PadCount: TDynamicString); Var DisplayForm: TDialog; Begin DisplayForm:= TDialog.Create(Application); DisplayForm.Label1.Caption:= PadCount; DisplayForm.ShowModal; DisplayForm.Free; End; Here, the DisplayForm variable is declared and defined in the DisplayForm unit.

The result is a simple dialog with a close button. The Altium Designer application handle needs be passed to this dialog, so this dialog appears as part of Altium Designer.

Code snippet 7: Server module creation function in main.pas. // The new server module sets up the command launcher table which stores commands (processes). Function PluginFactory (AClient: IClient): IServerModule; Safecall; Begin // name of addon server passed in // the installation file with INS extension needs to have the same name Result:= TAddOn.Create(AClient, 'AddOn'); End; To see the final code for the Commands unit, refer to the complete Commands.pas file in the SDK Addon Complete folder.

You can use the example files, or copy and paste the above command code snippets into the commands.pas unit of your server project and update the InitializeCommands procedure (Code snippet 7, above) in the main.pas unit. You will also need the DisplayForm (pas/dfm) unit before you can compile the project. These files (and others) can be found in the SDK Addon Complete folder. Compile the server project by selecting Build from Delphi's Project menu ( Project » Build). Server Installation File The next step is to create or edit the server installation file, Addon.ins, which should reflect the server processes declared and defined in the commands.pas and main.pas units of the Add-on server project. The Command Name clauses need to include the commands defined in the other units (for example, CountPads).

Installation file: AddOn.ins. Installable Server File: Addon.ins ClientInsFile 1.0 Server EditorName = 'AddOn' EditorExePath = 'AddOn.DLL' EditorDescription = 'Demonstratory AddOn module' Version = 'Version 6.3.0.6689' Date = '29-Dec-2012' HelpAboutInfo = 'This software is protected by copyright law and international treaties.' Copyright = 'Copyright © Altium Limited 2013' Updates = 'ADVPCB' End Command Name = 'CountPads' LongSummary = 'Find how many pads on a PCB document' End Executing the CountPads Command Copy all the relevant files to Altium Designer's System folder, then run Altium Designer and load a PCB document that has a number pad objects. In the DXP System menu, click the Run Process button Running a process from the DXP System menu in Altium Designer In the Run Process dialog, click Browse and select the Add-on extension. Select the AddOn:CountPads process, click OK, then click the button again to run the Add-on's process.

Delphi Define Directive

The Add-on extension checks for the presence of a PCB document, then it counts the number of pads on this document. The number of pad objects found is displayed or written out to a text document. An easier way to debug your server project To revise the code, the Add-on server needs to be stopped first by closing Altium Designer. The project source can then be revised in Delphi and the project re-compiled.

Make sure the updated DLL file is copied into Altium Designer's system folder if it was generated in a folder other than the default System folder. There is, however, an easier method; you can execute Altium Designer from Delphi using the Run menu within Delphi. For this approach, you need to set the compiler so that the DLL is generated in Altium Designer's System folder, and set the compiler break points. Note that depending on your computers operating system and setup, you may need to redefine the folder write permissions for the Altium Designer System folder - see the Note alert box in the section above. To set the DLL output path for the compiler debugging setup, open the Project Options dialog from Delphi's Run » Parameters menu. Use the Browse button to specify the Host application path to the Altium Designer application (the executable) for debugging your server. Setting up the path to Altium Designer in the Host Application field Then set the Output directory field on the Directories/Conditionals page of the Project Options dialog to the default System path, or where your Altium Designer system is installed (see below).

Setting the DLL output directory for debugging the server With the paths defined, breakpoints can then be set in your server code and run in Altium Designer from Delphi IDE, allowing you to step into the server code whenever the breakpoint is encountered. Recommended Debug compiler settings are shown in the figure below. These are found in the Compiling page under Delphi Compiler section in the Project Options dialog. Setting the debugging compiler options in Delphi for extension server projects Extending the server project A extension server, in this case the add-for the PCB editor, has a set of processes.

These process identifiers are stored in an installation file (with an.ins extension) and the functionality implemented in server source files. The commands linked to Altium Designer's GUI are the packaged process launchers which wrap around server processes and their parameters, if any. As a reminder, a command in Altium Designer is a specific server process launcher linked to a menu item, a toolbar button or a hot key (one of the three resources). These process launchers are defined in the server resources file (with a.rcs extension). Each process launcher is composed of a server process string, parameters and bitmap filenames. This section explores three methods that extend the Add-on extension project:.

Executing a PCB command from within the Add-on project. Adding the project's process launchers in the PCB editor. Adding a new floating toolbar with the project's process launchers Once the three methods are completed to enhance the Add-on project, the following physical files will be included to plug into Altium Designer: Addon files Description Addon.dll The Add-on server object. Addon.ins The server installation file which defines the processes, types of documents and toolbars/menus/hotkeys used by this extension server.

Addon.rcs The server's resources file which defines the process launchers for the graphical user interface in Altium Designer. Addon.tlt The server's tool layout file which defines the locations of toolbars and panels (optional). Server project files The complete Add-on extension project is composed of at least four files – the server file (DLL) representing the functionality of the server itself, the resources file (RCS) which contains the process launchers and the structure of the server's user interface, the installation file (INS) with server settings and command names, and optionally, the toolbar locations file (TLT) representing the locations of panels for this server. Extending the functionality requires that the two new files, the resources and toolbar files, be included. Files for the resources and toolbar locations will be defined so that commands (as process launchers) can appear in the PCB editor's menu, and a floating toolbar containing two buttons will also appear in the PCB Editor's work space.

The full code is not provided here, but the completed files (with the exception of the Addon.tlt file, for some SDK installations) can be found in the SDK Examples Addon Complete folder. Executing a PCB process from the extension The Add-on server itself can invoke and execute different server processes when running in Altium Designer. Here, another command procedure is included in the Add-on project; the first command procedure is CountPads which counts pads from the current PCB document, and the second process, RunAPCBProcess runs the PCB Server's BoardInformation process. In order to invoke the PCB editor's BoardInformation process from the extension server, the source units of the project ( Main.pas, Commands.pas and AddOn.ins) are expanded as follows.

Refer to the snippets below in which you can copy and paste into your own server project, or use the files from the SDK Examples AddOn Complete folder. Main Unit In the main.pas unit, the InitializeCommands procedure include the new CommandRunAPCBProcess procedure for the RunAPCBProcess process.

Command initialization in the main.pas unit. ClientInsFile 1.0 Server EditorName = 'AddOn' EditorExePath = 'AddOn.DLL' EditorDescription = 'Demonstratory AddOn module' Version = 'Version 6.3.0.6689' Date = '29-Dec-2012' HelpAboutInfo = 'This software is protected by copyright law and international treaties.'

Copyright = 'Copyright © Altium Limited 2012' Updates = 'ADVPCB' End Command Name = 'CountPads' LongSummary = 'Find how many pads on a PCB document' End Command Name = 'RunAPCBProcess' LongSummary = 'Invoke a PCB process' End Note that later, a toolbar definition will be added. Save all the files and recompile the Add-on project. Don't forget to copy the latest server installation and server module files into the System folder within the Altium Designer installation. Setting up the project's Processes in the PCB Editor You can execute a server process from Altium Designer's Run Process dialog to launch the Add-on extension, but there is a better way. The commands can be invoked in the PCB Editor from a toolbar button, a menu item or a hot key. These extension server processes are linked to the new resource items in the PCB editor.

In practice, the Add-on server will add its process launchers in the PCB editor when the extension server is loaded in Altium Designer. What follows shows how to add new menu items in the PCB menu and their respective menu key shortcuts, and a new toolbar with two buttons. The Add-on server's menu items in the GUI. Also note the new toolbar buttons positioned to the right of Help, in the main Menu.

Modifying the server configuration files that update the PCB Editor GUI To add new resource items that link to the Add-on extension's processes in the PCB Editor, these server files need to be updated: Addon.ins installation file, Addon.rcs resources file, the new Addon.tlt tools locations file (see below), and the main server (the PCB editor) AdvPCB.ins installation file. For reference, you can find the final project files in the SDK Examples folder. These files are essential to the process that inserts three new menu items in the PCB editor's View menu interface and two toolbar buttons on a new floating toolbar. The toolbar will need new buttons, and their bitmaps (18x18 pixels in size) are added to the System Buttons folder in the Altium Designer installation. The same bitmaps are used for the images beside the menu items. Each time the Altium Designer is started it loads and processes all the servers and their installation, toolbar locations and resources files.

When a PCB editor is loaded for example, the default PCB resources are also loaded and set up in Altium Designer, and then the resources for any other PCB extensions (AutoPlace, MakeLib, etc) are processed and set up, changing the PCB menus and other PCB resource items as dictated by the extension servers. To register the Add-on project's resources, the AdvPCB installation file needs to be updated to include the user interface details from the extension server, so that its user interface elements can be inserted in the PCB Editor user interface (see later). The following section looks at a server resources file which defines GUI elements in Altium Designer. Resources File and its Sections A resources file (with a RCS extension) is made up of two sections: Process Launcher definitions and Process Launcher Trees definitions. Process Launchers resource section A process launcher is a command linked to a user interface element such as a menu item, hotkey and toolbar in Altium Designer. The process launchers section in the resources file has a list of process launcher blocks.

Each process launcher block denoted by a PL–End clause that needs to have a unique name. A PL–End block has the following identifiers:. PL. The unique name (prefixed with a PL string) of the Process launcher linked to the server command string.

Command. Caption. Image. ShortCut1.

ShortCut2. Params. Description. End These process launchers are then used in the process launcher trees section of the resources file. These process launcher trees map to menu items, toolbar buttons or a hot keys in Altium Designer. Example of a process launcher (PL–End block) - this maps the CountPads process to menus and buttons. PL PLAddon:CountPadsAndShowDialog Command='Addon:CountPads' Caption='&Pad Count on Dialog.'

Image='Pad1.bmp' Shortcut1='d' Shortcut2=' Params='Display=False' Description='Display pad count in a dialog.' End This process launcher (above) defines a process launcher called Addon:CountPads, has a Caption called Pad Count on Dialog, has a image for the menu item and a short cut key, 'd'. Note: To set up hot keys for the menu items, you need to define the key character in the Shortcut1 clause and an alternative key character in the Shortcut2 clause in Process Launcher (PL) block. Process Launcher Trees section The process launcher trees section of the resources file provides a list of trees that represent each top-level user interface element (a hot key, a toolbar, or a menu) such as the File menu. Within each process launcher tree, you define the links for specific process launchers to sub user interface elements (say, sub menus) under that top level user interface element (say, a main menu), such as the Save As menu item.

In this case for example, the three Add-on extension commands appear under the View » AddOn menu. A Process Launcher Tree–End clause has the following identifiers:. Tree. The unique name of the process launcher tree. TargetId. RefIDn where n is a numerical value, 0.N.

Popup. Link. Separator. End Within a tree block, there are links and separators.

In Altium Designer a separator inserts a line between a menu item/toolbar button and the next menu item/toolbar button. For the links, they must have unique link identifiers to process launchers within each process launcher tree block. Example process launcher tree block - this defines the three menu items. Tree MNAddonMenuTree Caption='&Addon Menu' Popup='1' Link AddonMenu1 PLID='PLAddon:CountPadsAndShowDialog' End Link AddonMenu2 PLID='PLAddon:CountPadsAndShowDocument' End Separator AddonSeparator1 End Link AddonMenu3 PLID='PLAddon:RunAPCBProcess' End End This process launcher tree block defines three menu items that will appear on a PCB menu. Note: To enable pop up menus, you need to insert a Popup identifier with a key value at the end of the Tree clause (here, Popup='1'). Therefore, to add a new menu item in the PCB editor you need to insert an Insertion–End block, and within this block a Tree–End block with defined Links to specific Add-on server process launchers. You also need to specify the TargetId and RefID0 values so the PCB editor knows where to attach the commands to.

TargetID The TargetID clause identifies which top level user interface element to link from the main server resources file. An example is the PCB's View menu. See the Insertion–End block code below.

RefID0 The RefID0 clause refers to which existing user interface element (for example the menu item within the menu) for the new resource item to be inserted after or before. See the Insertion–End block code below. This process is similar for toolbar buttons and hot keys, except that you only need links to process launchers rather than trees within an insertion body. Inserting new Menu Items in an existing menu To place new menu items in a target's menu (such as the PCB Editor) that has the server's process launchers, you need to;. Update the resources file with Insertion–End blocks ( AddOn.rcs). Insert the Updates clause with the name of the target PCB editor in the installation file ( AddOn.ins). Insert the name of the extension in the ResourceDependencies block in the target PCB editor's installation file ( AdvPCB.ins).

Example Insertion–End block - this inserts the three process menu items. // Inserts two new addon processes in the PCB's View menu Insertion MNAddOnMenu TargetID='MNPCBView10' RefID0='MNPCBView80' Tree MNAddonMenuTree Caption='&Addon Menu' Popup='1' Link AddonMenu1 PLID='PLAddon:CountPadsAndShowDialog' End Link AddonMenu2 PLID='PLAddon:CountPadsAndShowDocument' End Separator AddonSeparator1 End Link AddonMenu3 PLID='PLAddon:RunAPCBProcess' End End End To do this, you need to know the Target ID and the Resource reference ID values that describe where the new menu items should appear in the PCB menu. You will need to look for the appropriate values in the AdvPCB.rcs file in Altium Designer's System folder for the TargetId and RefID0 identifiers to refer to. The full resources file for the Add-on extension is as follows. Later, an Insertion–End block for a toolbar will be added.

Complete Addon.rcs resources file. PL PLAddon:CountPadsAndShowDialog Command='Addon:CountPads' Caption='&Pad Count on Dialog.' Image='Pad1.bmp' Shortcut1='d' Shortcut2=' Params='Display=False' Description='Display pad count in a dialog.' End PL PLAddon:CountPadsAndShowDocument Command='Addon:CountPads' Caption='&Pad Count on Document.' Image='Pad2.bmp' Shortcut1='t' Shortcut2=' Params='Display=True' Description='Display pad count in a text document.' End PL PLAddon:RunAPCBProcess Command='Addon:RunAPCBProcess' Caption='&Run a PCB Process.'

Image=' Shortcut1='r' Shortcut2=' Params=' Description='Runs a PCB Process!' ClientInsFile 1.0 Server EditorName = 'AddOn' EditorExePath = 'AddOn.DLL' EditorDescription = 'Demonstratory AddOn module' Version = 'Version 6.8.0.14549' Date = '07-Aug-2008' HelpAboutInfo = 'This software is protected by copyright law and international treaties.' Copyright = 'Copyright © Altium Limited 2013' Updates = 'ADVPCB' End Command Name = 'CountPads' LongSummary = 'Find how many pads on a PCB document' End Command Name = 'RunAPCBProcess' LongSummary = 'Invoke a PCB process' End Save all the files and re-compile the Add-on extension project. Don't forget to update the resources file, installation file and the server module (DLL) in Altium Designer's System folder. Once you have copied the files to this folder and have Altium Designer up and running with a PCB document open, you can then invoke a command from the Add-on extension via one of the three new menu items in the PCB's View menu. Adding new Toolbars to the PCB Editor's Workspace To place a new toolbar in a PCB Editor's workspace that has the Add-on server's process launchers, the step are as follows;.

Define a new BarLayout block for the Add-on server's toolbar and panel locations file. Update the resources file with a Tree End block that point to the server processes. Insert Name and EditorBar clauses within an EditorWindowKind block in the installation file. Insert the name of the extension server in the ResourceDependencies block in the PCB Editor's installation file. The Add-on extension's toolbar The figure above is a screen shot depicting the Add-on' projects toolbar floating on the PCB work-space. The first step is to define the resources file for the Add-on server that define the process launchers for the new floating toolbar on the PCB workspace (specifically, only when PCB type documents are open).

For this exercise floating toolbar will be called TLAddon. Next, the new addon's tool layout file is defined with a TLT extension and the project's installation file is updated. Note that the toolbar name in the server resources file will also be used in the tool locations file and in the installation file. It is imperative to delete the DXP.RCS, DXP.RAF and UserTools.TLT files to remove the User Interface customizations when you are experimenting with the Altium Designer's graphical user interface. Altium Designer will recreate these files, but it may be prudent to back up the existing files first. ClientInsFile 1.0 Server EditorName = 'PCB' ResourceDependencies 'AutoPlacer' 'PinSwapper' 'AddOn' End End Updating the project Installation file Here the EditorWindowKind block needs to be inserted within the supporting server INS file with the following format; EditorBar Name = NameOfAddon BarType = ResourceType (Toolbar, Menu, HotKeyTable) End Then a new Tree block is defined with links to toolbar buttons in the addon resources file.

Finally a BarLayout block for the toolbar in the project TLT file (don't forget to specify the BarName and BarDocumentKind clauses). Add-on example installation file (addon.ins): Toolbar included. ClientInsFile 1.0 Server EditorName = 'AddOn' EditorExePath = 'AddOn.DLL' EditorDescription = 'Demonstratory AddOn module' Version = 'Version 6.3.0.6689' Date = '29-Dec-2012' HelpAboutInfo = 'This software is protected by copyright and international treaties.'

Copyright = 'Copyright © Altium Limited 2012' Updates = 'ADVPCB' End EditorWindowKind Name = 'Pcb' EditorBar Name = 'TLAddon' BarType = Toolbar End End Command Name = 'CountPads' LongSummary = 'Find how many pads on a PCB document' End Command Name = 'RunAPCBProcess' LongSummary = 'Invoke a PCB process' End The Updates clause tells the Altium Designer to update the PCB Server (AdvPCB) to update its resources. The format of the Updates clause is: Updates 'NameOfTargetServer'. In this case, we wish to update the PCB Editor, thus the ADVPCB string is used.

Delphi Compiler Defines Download

Updating the Server Resources File An extension server resources file (with a RCS extension) is a text file with a list of process launchers. Each process launcher is enclosed in a PL-End block consisting of a command string, a bitmap and parameters etc. The name of the toolbar in the tool locations file correspond to the name in the Editor. Add-on project resources file (addon.rcs): Add toolbar Tree block. PL PLAddon:CountPadsAndShowDialog Command='Addon:CountPads' Caption='&Pad Count on Dialog.' Image='Pad1.bmp' Shortcut1='t' Shortcut2=' Params='Display=False' Description='Display pad count in a dialog.'

End PL PLAddon:CountPadsAndShowDocument Command='Addon:CountPads' Caption='&Pad Count on Document.' Image='Pad2.bmp' Shortcut1='d' Shortcut2=' Params='Display=True' Description='Display pad count in a text document.' End PL PLAddon:RunAPCBProcess Command='Addon:RunAPCBProcess' Caption='&Run a PCB Process.'

Image=' Shortcut1='r' Shortcut2=' Params=' Description='Runs a PCB Process!' ToolsLayout BarLayout BarName='TLAddon' BarState=BarStateFloating BarDockSite=DockSiteNone BarDockOffset=563 BarFloatLeft=307 BarFloatTop=137 BarFloatWidth=51 BarActive=True BarDocumentKind=PCB End End The tools layout file is defined for the Add-on server so that the new toolbar is set to floating, and the location and size of the toolbar is set in the PCB workspace. Make sure that the BarName is set to TLAddon and it corresponds to the TLAddon entry in the project's resources file. The BarState identifier is set to BarStateFloating and the BarDocumentKind identifier is set to PCB. To sum up To add menu items to the PCB Editor from an extension server for example, you need to have Insertion clauses in the project's resources file with TargetID and RefID0 referencing user interface element IDs in the PCB Editor's server resources file. To add an extension server's toolbar to a PCB Editor for example, there are four files to update;.

The supporting server's INS,TLT and RCS files. The target server's INS file - that is, the appropriate.ins file in Altium Designer's System folder) Refer to the Add-on extension example in the Examples Addon Complete folder. Further information Refer to the and documents for more information on developing and deploying extension servers using the Altium Designer SDK. To explore the supplied SDK examples, take a look at various software extension projects in the SDK Examples folder of Altium Designer SDK installation.

Comments are closed.