### Report Installation Usage Example Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/system-utilities.md Example implementation of calling the installation report procedure. ```pascal procedure ReportInstall; begin ReportInstallationInfo; ShowMessage('Installation report generated'); end; ``` -------------------------------- ### Installation Report File Generation Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/system-utilities.md Example code for defining the destination path and filename for the installation report. ```pascal var ReportFile: string; begin ReportFile := GetTempPath + 'AltiumInstall_' + FormatDateTime('YYYY-MM-DD_HH-MM-SS', Now) + '.txt'; // Write report end; ``` -------------------------------- ### Report Installation Info Procedure Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/system-utilities.md Procedure declaration for generating an Altium installation report. ```pascal procedure ReportInstallationInfo; ``` -------------------------------- ### Retrieve Altium Configuration and Installation Paths Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/system-utilities.md Functions to resolve the APPDATA configuration path and read the installation directory from the Windows Registry. ```pascal function GetAltiumConfigPath: string; begin Result := GetEnvironmentVariable('APPDATA') + '\Altium\' + GetAltiumVersionString; end; function GetAltiumInstallPath: string; var Reg: TRegistry; begin Reg := TRegistry.Create; try Reg.RootKey := HKEY_CURRENT_USER; Reg.OpenKey('Software\Altium\AD21\CurrentVersion', false); Result := Reg.ReadString('InstallPath'); finally Reg.Free; end; end; ``` -------------------------------- ### DrawPolyRegOutline Usage Example Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/pcb-core-operations.md Demonstrates how to invoke the outline drawing function and handle the returned collection of primitives. ```pascal var OutlineList: TObjectList; Region: IPCB_Region; Layer: TLayer; begin Layer := LayerUtils.SignalLayer(eTopLayer); OutlineList := DrawPolyRegOutline(Region, Layer, MilsToCoord(2), 'Region 1', 0); // OutlineList contains IPCB_Line and IPCB_Arc objects for the outline end; ``` -------------------------------- ### procedure ReportInstallationInfo Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/system-utilities.md Generates a comprehensive report of the current Altium installation, including version, build, and module information. ```APIDOC ## procedure ReportInstallationInfo ### Description Generates a comprehensive Altium installation report containing version, build number, installation path, and license information. ### Signature `procedure ReportInstallationInfo;` ### Output The report is generated as a text file saved to the system temporary directory with the naming convention: AltiumInstall_YYYY-MM-DD_HH-MM-SS.txt ``` -------------------------------- ### Extract Project Files Pattern Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/system-utilities.md Example of extracting all files from a ZIP archive using TZipFile. ```pascal var Zipper: TZipFile; ExtractPath: string; begin Zipper := TZipFile.Create; try Zipper.Open('project_backup.zip', zmRead); Zipper.ExtractAll(ExtractPath); Zipper.Close; finally Zipper.Free; end; end; ``` -------------------------------- ### Define INI File Structure Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/configuration.md Example structure for project parameters and variant-specific settings in an INI file. ```ini [PRJParameters] ProjectParam1=Value1 ProjectParam2=Value2 [PRJParameters-Variant1] VariantParam1=Value1 [PRJParameters-Variant2] VariantParam1=Value1 ``` -------------------------------- ### Usage of TLayer Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/types.md Example of assigning layers using LayerUtils helper functions. ```pascal var TopLayer, BottomLayer, Mech1: TLayer; begin TopLayer := LayerUtils.SignalLayer(0); BottomLayer := LayerUtils.SignalLayer(31); Mech1 := LayerUtils.MechanicalLayer(1); end; ``` -------------------------------- ### Conditional Version Checking Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/system-utilities.md Example logic for executing code based on the major version of the Altium client. ```pascal VerMajor := GetBuildNumberPart(Client.GetProductVersion, 0); if VerMajor >= 19 then // Use AD19+ features else // Use legacy approach for AD17/18 ``` -------------------------------- ### Access Layer Stack Material Properties Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/layer-and-mechanical.md Example showing the format for layer stack material properties when exported. ```pascal var LSM_Property: string; begin // Layer stack material properties in stack export format // LAYER_V8_2$LSM$Material=Nickel, Gold // LAYER_V8_2$LSM$Process=ENIG // LAYER_V8_2$LSM$Thickness=1.5748mil end; ``` -------------------------------- ### Retrieve Project Paths Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/project-and-parameters.md Gets the focused project and extracts its full path and directory. ```pascal var Prj: IBoardProject; PrjPath: string; PrjFile: string; begin Prj := WS.DM_FocusedProject; if Prj <> nil then begin PrjFile := Prj.DM_ProjectFullPath; // Full path to .prjpcb PrjPath := ExtractFilePath(PrjFile); // Directory containing project end; end; ``` -------------------------------- ### Layer Stack Export Format Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/configuration.md Example structure for the layer stackup export file format. ```text [LayerStack] Layer1=eOutlineLayerKind Layer2Top=eCompPlacementTopLayerKind Layer2Bottom=eCompPlacementBottomLayerKind ``` -------------------------------- ### Define System File Paths Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/configuration.md Sets standard file system paths for application data, installation directories, and user documents. ```pascal const // Application data ConfigPath = '%APPDATA%\Altium\AD{VERSION}'; // Installation InstallPath = 'C:\Program Files\Altium\AD{VERSION}'; // User documents DocumentPath = 'Documents\Altium\{VERSION}'; LibraryPath = 'Documents\Altium\Libraries'; TemplatePath = 'Documents\Altium\Templates'; ``` -------------------------------- ### Archive Project Files Usage Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/system-utilities.md Example of creating a timestamped ZIP archive containing project files using TZipFile. ```pascal var ArchivePath: string; Zipper: TZipFile; begin ArchivePath := GetProjectPath + 'Backups\' + ExtractFileName(ProjectPath) + '_' + FormatDateTime('YYYY-MM-DD_HH-MM-SS', Now) + '.zip'; Zipper := TZipFile.Create; try Zipper.Open(ArchivePath, zmWrite); AddDirectoryToZip(Zipper, ProjectPath, ''); Zipper.Close; finally Zipper.Free; end; end; ``` -------------------------------- ### AddRegionToBoard2 Usage Example Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/pcb-core-operations.md Shows how to copy a region to a specific mechanical layer and add it to the board object. ```pascal var NewRegion: IPCB_Region; SourceRegion: IPCB_Region; begin // Copy region from top copper to mechanical layer 20 NewRegion := AddRegionToBoard2( SourceRegion, LayerUtils.MechanicalLayer(20), true ); Board.AddObjectToBoard(NewRegion); end; ``` -------------------------------- ### Layer Order Export Format Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/system-utilities.md Example of the INI-based configuration format used for storing layer order settings. ```ini [LayerOrder] TopLayer=1 Inner1=2 Inner2=3 BottomLayer=4 SolderMask=5 SilkScreen=6 ``` -------------------------------- ### ChangePlaneDrawMode Usage Example Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/pcb-core-operations.md Demonstrates triggering the plane drawing mode cycle. ```pascal begin // Cycle through plane draw modes ChangePlaneDrawMode; // Board view refreshes to show planes in new color scheme end; ``` -------------------------------- ### Read Altium Registry Keys Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/system-utilities.md Standard pattern for accessing Altium installation paths and version information from the Windows Registry. ```pascal var Reg: TRegistry; Version: string; InstallPath: string; begin Reg := TRegistry.Create; try Reg.RootKey := HKEY_CURRENT_USER; if Reg.OpenKey('Software\Altium\AD21\CurrentVersion', false) then begin Version := Reg.ReadString('Version'); InstallPath := Reg.ReadString('InstallPath'); Reg.CloseKey; end; finally Reg.Free; end; end; ``` -------------------------------- ### Apply Plane and Polygon Configuration Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/configuration.md Example usage of plane constants to set coordinate values and arc resolution in the PCB server. ```pascal var LineWidth: TCoord; TextHeight: TCoord; begin LineWidth := MilsToCoord(cLineWidth); TextHeight := MilsToCoord(cTextHeight); PCBServer.PCBContourMaker.SetState_ArcResolution(MilsToCoord(cArcResolution)); end; ``` -------------------------------- ### ParameterExistsUpdateValue Usage Example Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/project-and-parameters.md Demonstrates how to retrieve the focused project and use the ParameterExistsUpdateValue function to check and update a parameter. ```pascal var Prj: IProject; Variant: TProjectVariant; Existing: WideString; Found: boolean; begin WS := GetWorkspace; Prj := WS.DM_FocusedProject; Variant := Prj.DM_ProjectVariants(0); Found := ParameterExistsUpdateValue( Prj, Variant, 'BoardName', 'NewValue', Existing ); if Found then ShowMessage('Parameter was: ' + Existing) else ShowMessage('Parameter not found'); end; ``` -------------------------------- ### Use TUnit for coordinate conversion Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/types.md Example of checking the board display unit to determine the correct conversion function. ```pascal var Unit: TUnit; Size: TCoord; DisplaySize: double; begin Unit := Board.DisplayUnit; if Unit = eImperial then DisplaySize := CoordToMils(Size) else DisplaySize := CoordToMMs(Size); end; ``` -------------------------------- ### Parse data with TStringList Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/types.md Example of using TStringList to parse delimited string data. ```pascal var List: TStringList; Line: string; begin List := TStringList.Create; try List.Delimiter := '='; List.DelimitedText := 'Name=Value | Key=Data'; // Parse delimited data finally List.Free; end; end; ``` -------------------------------- ### Get Active Workspace with Error Handling Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/errors-and-patterns.md Checks for an active workspace and alerts the user if none is available. ```pascal function GetActiveWorkspace: IWorkspace; begin Result := GetWorkspace; if Result = nil then ShowMessage('No active workspace available') else Result := WS.DM_FocusedProject; end; ``` -------------------------------- ### Implement Verbose Logging Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/errors-and-patterns.md Logs messages to a temporary file with timestamps. Includes a main procedure example demonstrating error handling and lifecycle logging. ```pascal procedure LogDebugInfo(Message: string); var LogFile: string; LogList: TStringList; begin LogFile := GetTempPath + 'AltiumScript.log'; LogList := TStringList.Create; try if FileExists(LogFile) then LogList.LoadFromFile(LogFile); LogList.Add('[' + FormatDateTime('HH:MM:SS', Now) + '] ' + Message); LogList.SaveToFile(LogFile); finally LogList.Free; end; end; procedure Main; begin try LogDebugInfo('Script started'); Board := PCBServer.GetCurrentPCBBoard; if Board = nil then begin LogDebugInfo('ERROR: No board found'); Exit; end; LogDebugInfo('Board loaded: ' + Board.GetState_BoardFileName); // Do work... LogDebugInfo('Script completed successfully'); except on E: Exception do LogDebugInfo('EXCEPTION: ' + E.Message); end; end; ``` -------------------------------- ### Retrieve Current PCB Library Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/pcblib-schlib-operations.md Attempts to get the active library window, falling back to the library associated with the current board if necessary. ```pascal var CurrentLib: IPCB_Library; Board: IPCB_Board; begin CurrentLib := PCBServer.GetCurrentPCBLibrary; if CurrentLib = nil then begin Board := PCBServer.GetCurrentPCBBoard; if Board <> nil then CurrentLib := Board.Library; // Fallback to board library end; if CurrentLib = nil then begin ShowMessage('No library available'); exit; end; end; ``` -------------------------------- ### Define Design Rule Scopes Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/pcb-core-operations.md Example scope definitions for applying clearance rules to specific layers and nets. ```text Scope1 = OnLayer('Internal Plane 1') and IsRegion and InNet('GND') Scope2 = Net = 'TargetNet' ``` -------------------------------- ### Mechanical Layer INI Configuration Format Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/pcblib-schlib-operations.md Example structure for defining footprint mechanical layers and pairs in an INI file. ```ini [Footprint1] MechLayer1=Mechanical1 MechLayer2=Mechanical2 [MechPairs] Pair1Top=Mechanical1 Pair1Bottom=Mechanical2 ``` -------------------------------- ### Iterate Board Primitives Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/overview.md Uses an iterator to traverse PCB objects on all layers. Ensure the iterator is properly initialized and filtered before starting the loop. ```pascal var Iterator: IPCB_BoardIterator; Primitive: IPCB_Primitive; begin Iterator := Board.BoardIterator_Create; Iterator.AddFilter_LayerSet(AllLayers); Iterator.SetState_FilterAll; Primitive := Iterator.FirstPCBObject; while Primitive <> nil do begin // Process primitive Primitive := Iterator.NextPCBObject; end; end; ``` -------------------------------- ### Component Placement Usage Pattern Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/schematic-operations.md Demonstrates the standard workflow for retrieving the current document and executing the component placement procedure. ```pascal var SchDoc: ISCH_Document; CompList: TStringList; begin SchDoc := SchServer.GetCurrentSchDocument; CompList := GetComponentsList; // User-defined PlaceComponentsFromLib(SchDoc, CompList); end; ``` -------------------------------- ### Configure Internal Options Registry Pattern Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/system-utilities.md Demonstrates the pattern for writing configuration values to the Altium registry path using TRegistry. ```pascal var Reg: TRegistry; begin Reg := TRegistry.Create; try Reg.RootKey := HKEY_CURRENT_USER; Reg.OpenKey('Software\Altium\AD21\CurrentVersion', true); Reg.WriteString('LayerStackFile', 'default.stackup'); Reg.CloseKey; finally Reg.Free; end; end; ``` -------------------------------- ### Initialize TCoordPoint Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/types.md Shows how to assign values to a TCoordPoint record. ```pascal var Point: TCoordPoint; begin Point.X := MilsToCoord(100); Point.Y := MilsToCoord(200); end; ``` -------------------------------- ### Perform Standard File Handling Operations Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/system-utilities.md Demonstrates extracting path components, checking file existence, retrieving file size, and performing file system modifications like copying and deleting. ```pascal var FilePath: string; FileName: string; FileDir: string; begin FilePath := 'C:\Projects\Design\Board.PcbDoc'; // Extract components FileDir := ExtractFilePath(FilePath); // C:\Projects\Design\ FileName := ExtractFileName(FilePath); // Board.PcbDoc // Check existence if FileExists(FilePath) then ShowMessage('File found'); // Get size if FileExists(FilePath) then FileSize := GetFileSize(FilePath); // Copy file CopyFile(PChar(SourcePath), PChar(DestPath), true); // Delete file DeleteFile(FilePath); end; ``` -------------------------------- ### Get Component Bounding Rectangle Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/pcb-core-operations.md Calculates the bounding rectangle for a component, excluding name and comment text. ```pascal function GetComponentBR(Comp: IPCB_Component): TCoordRect; ``` ```pascal var BR: TCoordRect; Comp: IPCB_Component; begin BR := GetComponentBR(Comp); ShowMessage('Component width: ' + CoordUnitToString(BR.Right - BR.Left, BUnit)); end; ``` -------------------------------- ### Apply Layer Color to System Options Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/configuration.md Demonstrates applying a defined color constant to a PCB layer background. ```pascal var SysOpts: IPCB_SystemOptions; Layer: TLayer; begin SysOpts := PCBServer.SystemOptions; Layer := LayerUtils.SignalLayer(0); // Top layer SysOpts.SetState_LayerColor_Background(Layer, cRed); end; ``` -------------------------------- ### Configure Live Portal Settings Procedure Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/system-utilities.md Defines the procedure signature for managing Altium Live Portal connection and authentication settings. ```pascal procedure ConfigureLivePortalSettings; ``` -------------------------------- ### Execute Directory Operations Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/system-utilities.md Covers directory creation and listing files within a specified path using standard system functions. ```pascal var DirPath: string; begin DirPath := 'C:\Projects\Design\'; // Create directory if not DirectoryExists(DirPath) then CreateDir(DirPath); // List files if DirectoryExists(DirPath) then FindFirst(DirPath + '*.*', faAnyFile, SearchRec); end; ``` -------------------------------- ### Define System Constants and Defaults Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/system-utilities.md Lists standard constants for file names, folder paths, and system limits used across utility scripts. ```pascal const cDefaultReportFileName = 'Report.txt'; cDefaultReportFolder = 'Reports'; cDefaultConfigFileName = 'config.ini'; cDefaultBackupFolder = 'Backups'; cMaxFileSize = 2147483647; // 2 GB limit for some operations cGridSize = 100; // Default grid (mils) ``` -------------------------------- ### Set PCB Layer Order Procedure Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/system-utilities.md Initializes the procedure for configuring and exporting PCB layer ordering preferences. ```pascal procedure SetPCBLayerOrder; ``` -------------------------------- ### Configure Release Settings Procedure Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/system-utilities.md Procedure declaration for managing Altium Releaser settings. ```pascal procedure ConfigureReleaseSettings; ``` -------------------------------- ### Define and use TPoint Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/types.md Defines the TPoint record structure and shows basic initialization. ```pascal type TPoint = record X: integer; Y: integer; end; ``` ```pascal var Pt: TPoint; BOrigin: TCoordPoint; begin Pt := Point(100, 200); // Convert to coordinate point BOrigin := Point(0, 0); end; ``` -------------------------------- ### Define Altium Registry Paths Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/configuration.md Configures base registry keys for accessing Altium configuration settings. ```pascal const // Base registry path pattern: RegistryBase = 'Software\Altium\AD{VERSION}\CurrentVersion'; // Subkeys: ViewColors = RegistryBase + '\ViewColors'; LayerColors = RegistryBase + '\LayerColors'; Preferences = RegistryBase + '\Preferences'; OutputOptions = RegistryBase + '\OutputOptions'; LibraryPaths = RegistryBase + '\LibraryPaths'; ``` -------------------------------- ### Define INI File Format for LayerStack Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/layer-and-mechanical.md Example structure for the INI file used to store mechanical layer and pair information. ```ini [LayerStack] Layer1Name=Top Solder Mask Layer1Kind=eSoldermaskLayerKind Layer1Color=16711680 [MechPairs] Pair1Top=Mechanical5 Pair1Bottom=Mechanical6 Pair1Kind=eTopBottomDrillDrawingLayerPairKind ``` -------------------------------- ### Release Settings Data Structure Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/system-utilities.md Record structure defining the configuration parameters for design releases. ```pascal type TReleaseSettings = record VersionNumber: WideString; OutputPath: WideString; DocumentPath: WideString; ArchivePath: WideString; GenerateGerber: boolean; GenerateDrill: boolean; GenerateBOM: boolean; GenerateNetlist: boolean; IncludeSchematic: boolean; end; ``` -------------------------------- ### Usage of Version Function Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/project-and-parameters.md Demonstrates how to call the Version function and access individual version components from the returned TStringList. ```pascal var VersionList: TStringList; MajorVersion: string; begin VersionList := Version(true); MajorVersion := VersionList[0]; // First component // Use VersionList[1], VersionList[2], etc for minor, patch, build VersionList.Free; end; ``` -------------------------------- ### Accessing Document Metadata Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/project-and-parameters.md Demonstrates how to retrieve file names, full paths, and document types from an IDocument instance. ```pascal var Doc: IDocument; FileName: string; DocType: string; begin FileName := Doc.DM_FileName; FileName := Doc.DM_FullPath; DocType := Doc.DM_DocumentKind; end; ``` -------------------------------- ### Define Altium Document File Extensions Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/configuration.md Standard constants for common Altium file format extensions. ```pascal const PcbDocExt = '.PcbDoc'; // PCB design document SchDocExt = '.SchDoc'; // Schematic design document PcbLibExt = '.PcbLib'; // PCB library SchLibExt = '.SchLib'; // Schematic library IntLibExt = '.IntLib'; // Integrated library PrjExt = '.PrjPcb'; // PCB project IniExt = '.ini'; // Configuration file TxtExt = '.txt'; // Text/report file ``` -------------------------------- ### Access Product Version via Client Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/project-and-parameters.md Retrieves the major version number directly from the product version string. ```pascal VerMajor := GetBuildNumberPart(Client.GetProductVersion, 0); ``` -------------------------------- ### Configure OutJob Script Constants Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/configuration.md Sets default file names and source parameters for OutJob script execution. ```pascal const cDefaultReportFileName = 'OJScript-Report.txt'; cSourceFileNameParameter = 'SourceFileName'; cSourceFileName = 'dummy.PcbDoc'; ``` -------------------------------- ### PlaceComponentFromLibrary Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/schematic-operations.md Automatically places components in a schematic sheet from a library, maintaining electrical properties and applying grid alignment. ```APIDOC ## Procedure: PlaceComponentFromLibrary ### Description Automatically places components in a schematic sheet from a library. It handles automatic positioning, rotation, and grid alignment. ### Signature `procedure PlaceComponentFromLibrary;` ### Configuration - **cXSpacing** (const) - X spacing between components (mils) - **cYSpacing** (const) - Y spacing between rows (mils) - **cGridSize** (const) - Snap to grid (mils) ### Usage Example ```pascal var SchDoc: ISCH_Document; CompList: TStringList; begin SchDoc := SchServer.GetCurrentSchDocument; CompList := GetComponentsList; PlaceComponentsFromLib(SchDoc, CompList); end; ``` ``` -------------------------------- ### Find Components with Primitives Procedure Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/pcblib-schlib-operations.md Defines the entry point for identifying footprints that contain specific types of primitives. ```pascal procedure FindComponentsWithPrimitives; ``` -------------------------------- ### procedure ListProjectLibraries Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/system-utilities.md Generates a report listing all PCB, Schematic, and Symbol libraries associated with the current project, including file paths, sizes, and component counts. ```APIDOC ## procedure ListProjectLibraries ### Description Generates a list of all libraries in the current project, including library type, file path, size, component count, last modified date, and read-only status. ### Signature `procedure ListProjectLibraries;` ``` -------------------------------- ### Iterate Project Variants and Parameters Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/project-and-parameters.md Shows the nested loop structure required to traverse all project variants and their specific parameters. ```pascal var I, J: integer; Prj: IProject; Variant: TProjectVariant; TempPara: TParameters; begin for I := 0 to (Prj.DM_ProjectVariantCount - 1) do begin Variant := Prj.DM_ProjectVariants(I); for J := 0 to (Variant.DM_ParameterCount - 1) do begin TempPara := Variant.DM_Parameters(J); // Process parameter end; end; end; ``` -------------------------------- ### Access Project Files Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/overview.md Iterates through logical documents within the currently focused project in the workspace. ```pascal var WS: IWorkspace; Prj: IBoardProject; Doc: IDocument; begin WS := GetWorkspace; Prj := WS.DM_FocusedProject; // Iterate documents for I := 0 to (Prj.DM_LogicalDocumentCount - 1) do begin Doc := Prj.DM_LogicalDocuments(I); // Process document end; end; ``` -------------------------------- ### Access Library Properties Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/system-utilities.md Iterates through project documents to identify PCB and Schematic libraries and retrieve their file paths and sizes. ```pascal var Prj: IBoardProject; Doc: IDocument; LibPath: string; LibSize: int64; begin for I := 0 to (Prj.DM_LogicalDocumentCount - 1) do begin Doc := Prj.DM_LogicalDocuments(I); if (Doc.DM_DocumentKind = 'PCBLIB') or (Doc.DM_DocumentKind = 'SCHLIB') then begin LibPath := Doc.DM_FullPath; // Get file size LibSize := GetFileSize(LibPath); end; end; end; ``` -------------------------------- ### Access TParameters Instance Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/project-and-parameters.md Demonstrates reading parameter properties and updating a value. ```pascal var Para: TParameters; PName: WideString; PValue: WideString; begin PName := Para.DM_Name; PValue := Para.DM_Value; Para.DM_SetValue('NewValue'); end; ``` -------------------------------- ### Place Component from Library Procedure Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/schematic-operations.md Defines the procedure signature for placing components from a library onto a schematic sheet. ```pascal procedure PlaceComponentFromLibrary; ``` -------------------------------- ### List Project Libraries Procedure Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/system-utilities.md Defines the procedure signature for generating a list of libraries within the current project. ```pascal procedure ListProjectLibraries; ``` -------------------------------- ### Automate Output Job Generation Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/project-and-parameters.md Procedure to access the workspace and project to configure and run Output Job documents. ```pascal procedure RunOutJobDocs(dummy: boolean); var WS: IWorkspace; Prj: IBoardProject; OutJob: IPCB_OutJob; begin WS := GetWorkspace; Prj := WS.DM_FocusedProject; // Configure and run OutJob OutJob := Prj.DM_OutJob; // Generate outputs end; ``` -------------------------------- ### Set Pin Function Properties Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/pcblib-schlib-operations.md Demonstrates how to configure the electrical type and visibility state of a schematic pin. ```pascal // Set pin function type Pin.SetState_ElectricalType(eInput); Pin.SetState_Visible(true); ``` -------------------------------- ### Retrieve Product Version Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/project-and-parameters.md Defines the Version function signature for extracting product version components. ```pascal function Version(const dummy: boolean): TStringList; ``` -------------------------------- ### Define Project Parameter Constants Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/configuration.md Constants for INI file section headings and default variant naming conventions. ```pascal const cDummyTuples = 'Area=51 | Answer=42 | Question=forgotten'; TopLevelKey = 'PRJParameters'; // INI section heading NoVariantName = 'No Variation'; // Project-level variant name ``` -------------------------------- ### Manage PCB Layer Colors with IPCB_SystemOptions Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/layer-and-mechanical.md Use IPCB_SystemOptions to retrieve or set layer background colors using the legacy 24-bit RGB integer format. AD21+ users should prefer this over Board.LayerColor() to avoid stale values. ```pascal var SysOpts: IPCB_SystemOptions; LayerColor: integer; begin SysOpts := PCBServer.SystemOptions; // Get color for a layer (RGB integer) LayerColor := SysOpts.LayerColor_Background[Layer]; // Set color for a layer SysOpts.SetState_LayerColor_Background(Layer, $FF0000); // Red end; ``` -------------------------------- ### Define and use TIniFile Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/types.md Defines the TIniFile class interface and demonstrates reading and writing configuration values. ```pascal type TIniFile = class constructor Create(FileName: string); function ReadString(Section, Key, Default: string): string; function ReadInteger(Section, Key, Default: integer): integer; procedure WriteString(Section, Key, Value: string); procedure WriteInteger(Section, Key, Value: integer); procedure EraseSection(Section: string); procedure Free; end; ``` ```pascal var IniFile: TIniFile; Value: string; begin IniFile := TIniFile.Create('config.ini'); try Value := IniFile.ReadString('Section', 'Key', 'DefaultValue'); IniFile.WriteString('Section', 'NewKey', 'NewValue'); finally IniFile.Free; end; end; ``` -------------------------------- ### Combine PCB Libraries Procedure Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/pcblib-schlib-operations.md Merges multiple footprint libraries into a single destination library, automatically handling name collisions. ```pascal procedure CombinePcbLibraries( SourceLibraries: TStringList, OutputLib: IPCB_Library ); ``` -------------------------------- ### File Operation Error Handling in Pascal Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/errors-and-patterns.md Safely reads configuration files by verifying existence and catching I/O exceptions, returning an empty list on failure. ```pascal function SafeReadConfigFile(FilePath: string): TStringList; begin Result := TStringList.Create; try if not FileExists(FilePath) then begin ShowMessage('Configuration file not found: ' + FilePath); Exit; end; Result.LoadFromFile(FilePath); except on E: Exception do begin ShowMessage('Error reading configuration: ' + E.Message); Result.Clear; end; end; end; ``` -------------------------------- ### Define and use TObjectList Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/types.md Defines the TObjectList class interface and demonstrates adding and iterating over primitives. ```pascal type TObjectList = class function Count: integer; function Items[Index: integer]: TObject; procedure Add(Obj: TObject); procedure Clear; procedure Free; end; ``` ```pascal var OutlineList: TObjectList; Primitive: IPCB_Primitive; I: integer; begin OutlineList := TObjectList.Create; try // Add primitives OutlineList.Add(SomePrimitive); // Iterate for I := 0 to (OutlineList.Count - 1) do begin Primitive := IPCB_Primitive(OutlineList.Items[I]); end; finally OutlineList.Free; end; end; ``` -------------------------------- ### DemoAddNewParameters Constants Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/project-and-parameters.md Constants used within the parameter demonstration procedure. ```pascal const cDummyTuples = 'Area=51 | Answer=42 | Question=forgotten'; TopLevelKey = 'PRJParameters'; NoVariantName = 'No Variation'; ``` -------------------------------- ### Mechanical Layer Mapping Procedure Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/pcblib-schlib-operations.md Defines the entry point for managing mechanical layer assignments and pairings. ```pascal procedure MechLayerMapping; ``` -------------------------------- ### Use TCoord conversion functions Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/types.md Demonstrates converting between TCoord and standard units like mils and millimeters. ```pascal var BoardSize: TCoord; SizeInMils: double; SizeInMM: double; begin BoardSize := MilsToCoord(10000); // 10 inches SizeInMils := CoordToMils(BoardSize); // 10000 SizeInMM := CoordToMMs(BoardSize); // 254 end; ``` -------------------------------- ### Retrieve Board Details and Constants Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/pcb-core-operations.md Retrieves board dimensions and workspace parameters, while defining standard conversion constants. ```pascal function GetBoardDetail(const dummy: integer): TCoordRect; ``` ```pascal MilFactor = 10; // Rounding granularity in mils mmInch = 25.4; // Conversion factor ``` -------------------------------- ### Set Altium Live Portal Credentials Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/system-utilities.md Sets portal credentials in the registry, utilizing encrypted storage for the password field. ```pascal procedure SetPortalCredentials(Username, Password: string); var Reg: TRegistry; begin Reg := TRegistry.Create; try Reg.RootKey := HKEY_CURRENT_USER; Reg.OpenKey('Software\Altium\AD21\LivePortal\Authentication', true); Reg.WriteString('Username', Username); Reg.WriteEncryptedString('Password', Password); // Encrypted storage finally Reg.Free; end; end; ``` -------------------------------- ### BlindViaPlanePad Configuration Constants Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/pcb-core-operations.md Constants used for defining mechanical layers during the blind via pad creation process. ```pascal cPlaneMechLayer = 21; // Mechanical layer for plane copies cTempMechLayer1 = 32; // Temporary scratch layer ``` -------------------------------- ### Outline Generation Constants Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/configuration.md Configuration settings for layer mapping, line properties, and report generation during outline creation. ```pascal const cTargetLayer = 13; // Source layer for regions cTargetCuLayer = 0; // Copper layer source (0=top) cDestinLayer = 31; // Destination layer for region outlines cDestinLayer2 = 32; // Destination layer for body outlines cLineWidth = 0.5; // Output line width (mils) ArcResolution = 0.1; // Arc approximation resolution (mils) bDisplay = true; // Display results in UI bLock = false; // Lock generated objects bUnLock = false; // Unlock locked objects bRenameExtrudedBody = true; // Rename blank extruded body names ReportFileSuffix = '_FP-RegLinesRpt'; ReportFileExtension = '.txt'; ReportFolder = 'Reports'; ``` -------------------------------- ### procedure ConfigureReleaseSettings Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/system-utilities.md Configures Altium Releaser settings for the design release workflow, including versioning, output paths, and generation options. ```APIDOC ## procedure ConfigureReleaseSettings ### Description Manages Altium Releaser settings for design release workflow, including version numbering, output folder locations, and file generation options. ### Signature `procedure ConfigureReleaseSettings;` ### Configuration Options - **VersionNumber** (WideString) - Release version numbering - **OutputPath** (WideString) - Output folder location - **DocumentPath** (WideString) - Documentation generation path - **ArchivePath** (WideString) - Archive settings path - **GenerateGerber** (boolean) - Gerber generation toggle - **GenerateDrill** (boolean) - Drill file generation toggle - **GenerateBOM** (boolean) - BOM generation toggle - **GenerateNetlist** (boolean) - Netlist generation toggle - **IncludeSchematic** (boolean) - Schematic inclusion toggle ``` -------------------------------- ### Retrieve Board Classes Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/pcb-core-operations.md Fetches a list of component classes from the specified PCB board. ```pascal function GetBoardClasses( Board: IPCB_Board, const ClassKind: Integer ): TObjectList; ``` -------------------------------- ### OutLineRegions Procedure Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/pcblib-schlib-operations.md Creates polyline outlines around region and component body shapes in PCB library footprints. ```pascal procedure OutLineRegions; ``` -------------------------------- ### Schematic Document Interface Operations Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/schematic-operations.md Shows how to retrieve the current schematic document, access sheets by index, and iterate through components. ```pascal var SchDoc: ISCH_Document; SheetCount: integer; CurrentSheet: ISCH_Sheet; CompCount: integer; begin // Get current schematic SchDoc := SchServer.GetCurrentSchDocument; if SchDoc = nil then begin ShowMessage('No schematic document open'); exit; end; // Sheet operations SheetCount := SchDoc.GetSheetCount; CurrentSheet := SchDoc.GetSheet(1); // Sheet 1-based index // Component iteration CompCount := SchDoc.GetComponentCount; Comp := SchDoc.GetFirstComponent; while Comp <> nil do begin Comp := SchDoc.GetNextComponent; end; end; ``` -------------------------------- ### Set Custom Colours Procedure Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/system-utilities.md Initializes the procedure for managing the custom color palette for PCB and schematic displays. ```pascal procedure SetCustomColours; ``` -------------------------------- ### Version(dummy: boolean): TStringList Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/project-and-parameters.md Extracts product version information from Altium as a TStringList of components. ```APIDOC ## function Version(const dummy: boolean): TStringList ### Description Extracts product version information from Altium. The returned TStringList contains version components parsed by the '.' delimiter. ### Parameters - **dummy** (boolean) - Required - Unused parameter (convention). ### Returns - **TStringList** - Parsed version components (e.g., "21.1.5.42" becomes ["21", "1", "5", "42"]). ### Usage Example ```pascal var VersionList: TStringList; begin VersionList := Version(true); // Access components via index VersionList.Free; end; ``` ``` -------------------------------- ### IBoardProject Interface Definition Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/project-and-parameters.md Defines the structure for accessing project-level data, including documents, variants, and parameters. ```pascal type IBoardProject = interface(IProject) function DM_LogicalDocumentCount: integer; function DM_LogicalDocuments(I: integer): IDocument; function DM_PrimaryImplementationDocument: IDocument; function DM_ProjectVariantCount: integer; function DM_ProjectVariants(I: integer): TProjectVariant; function DM_ParameterCount: integer; function DM_Parameters(I: integer): TParameters; function DM_OutJob: IPCB_OutJob; end; ``` -------------------------------- ### Retrieve and Parse Altium Version Information Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/system-utilities.md Functions to fetch the full version string or extract the major version integer from the Altium client. ```pascal function GetAltiumVersionString: WideString; begin Result := Client.GetProductVersion; // Format: "21.1.5.42" end; function GetAltiumVersionMajor: integer; var VersionStr: WideString; Parts: TStringList; begin VersionStr := Client.GetProductVersion; Parts := TStringList.Create; try Parts.Delimiter := '.'; Parts.DelimitedText := VersionStr; Result := StrToInt(Parts[0]); finally Parts.Free; end; end; ``` -------------------------------- ### Global Configuration Constants Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/pcb-core-operations.md Standard constants used for plane outlines, line widths, text sizing, and geometric ratios. ```pascal const AutoRedrawOutlines = true; // Redraw plane outlines automatically StripAllOutlines = true; // Remove outlines from all layers cLineWidth = 2; // Default line width (2 mils) cTextHeight = 16; // Text height (16 mils) cNoNetName = 'no-net'; // Default net name for unconnected cArcResolution = 0.01; // Arc resolution (0.01 mils) CMPBorder = 4; // Component border offset (4 mils) GRatio = 1.618; // Golden ratio for room sizing ``` -------------------------------- ### Access Schematic Server Methods Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/schematic-operations.md Common methods for retrieving or setting the active schematic document or library via SchServer. ```pascal var SchServer: ISCH_ServerInterface; SchDoc: ISCH_Document; SchLib: ISCH_Library; begin // Get current document SchDoc := SchServer.GetCurrentSchDocument; // Get current library SchLib := SchServer.GetCurrentSchLibrary; // Document by path SchDoc := SchServer.GetSchDocumentByPath(FilePath); // Library by path SchLib := SchServer.GetSchLibraryByPath(FilePath); // Focus document SchServer.SetCurrentSchDocument(SchDoc); // Focus library SchServer.SetCurrentSchLibrary(SchLib); end; ``` -------------------------------- ### Read Configuration with TIniFile Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/overview.md Use TIniFile to manage script configuration settings stored in external .ini files. Ensure the object is freed after use to prevent memory leaks. ```pascal var IniFile: TIniFile; begin IniFile := TIniFile.Create('config.ini'); Value := IniFile.ReadString('Section', 'Key', 'Default'); IniFile.Free; end; ``` -------------------------------- ### Iterate Components in Schematic Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/schematic-operations.md Standard pattern for traversing all components in the current schematic document. ```pascal var SchDoc: ISCH_Document; Comp: ISCH_Component; Count: integer; begin SchDoc := SchServer.GetCurrentSchDocument; if SchDoc = nil then exit; Count := 0; Comp := SchDoc.GetFirstComponent; while Comp <> nil do begin // Process component Inc(Count); Comp := SchDoc.GetNextComponent; end; ShowMessage(IntToStr(Count) + ' components processed'); end; ``` -------------------------------- ### Access the current workspace and project Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/README.md Retrieves the active workspace and the currently focused project. Useful for scripts that need to operate on the user's current design context. ```pascal var WS: IWorkspace; Prj: IBoardProject; begin WS := GetWorkspace; Prj := WS.DM_FocusedProject; end; ``` -------------------------------- ### procedure CombinePcbLibraries Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/pcblib-schlib-operations.md Merges multiple footprint libraries into a single library file. ```APIDOC ## procedure CombinePcbLibraries ### Description Merges multiple footprint libraries into single library. ### Signature `procedure CombinePcbLibraries(SourceLibraries: TStringList, OutputLib: IPCB_Library);` ### Parameters - **SourceLibraries** (TStringList) - Required - List of source library paths - **OutputLib** (IPCB_Library) - Required - Destination library ``` -------------------------------- ### Split and Combine Schematic Libraries Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/pcblib-schlib-operations.md Procedures for managing library file structures by splitting libraries into individual symbols or combining multiple libraries into one. ```pascal procedure SplitSchematicLibrary( SourceLib: ISCH_Library, OutputDirectory: WideString ); ``` ```pascal procedure CombineSchematicLibraries( SourceLibraries: TStringList, OutputLib: ISCH_Library ); ``` -------------------------------- ### SchServer Interface Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/schematic-operations.md Core methods for accessing and managing schematic documents and libraries. ```APIDOC ## SchServer Interface ### Description Provides global access to schematic documents and libraries, including loading by path and setting the active focus. ### Methods - **GetCurrentSchDocument()**: Returns the active schematic document. - **GetCurrentSchLibrary()**: Returns the active schematic library. - **GetSchDocumentByPath(FilePath)**: Retrieves a document by its file path. - **GetSchLibraryByPath(FilePath)**: Retrieves a library by its file path. - **SetCurrentSchDocument(SchDoc)**: Sets the active focus to the provided document. - **SetCurrentSchLibrary(SchLib)**: Sets the active focus to the provided library. ``` -------------------------------- ### BlindViaPlanePad Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/pcb-core-operations.md Creates plane contact pads for microvias on internal plane layers. ```APIDOC ## BlindViaPlanePad ### Description Creates plane contact pads for microvias on internal plane layers. Iterates all vias on board, creates landing pads for microvias, and applies net/clearance rules. ### Signature procedure BlindViaPlanePad; ``` -------------------------------- ### Execute Version-Conditional Logic in Pascal Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/errors-and-patterns.md Uses the product version build number to toggle between legacy and modern API calls. Ensures compatibility across different Altium Designer releases. ```pascal procedure VersionAwareOperation; var VerMajor: integer; Board: IPCB_Board; MechLayer: IPCB_MechanicalLayer; Layer: TLayer; begin VerMajor := GetBuildNumberPart(Client.GetProductVersion, 0); Board := PCBServer.GetCurrentPCBBoard; Layer := LayerUtils.MechanicalLayer(20); if VerMajor >= 19 then begin // Use modern approach MechLayer := Board.LayerStack.LayerObject(Layer); end else begin // Use legacy approach MechLayer := Board.LayerStack_V7.LayerObject_V7(Layer); end; if MechLayer <> nil then MechLayer.MechanicalLayerEnabled := true; end; ``` -------------------------------- ### Configure Legacy Mechanical Layer Support Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/configuration.md Boolean flag logic to toggle between modern and legacy mechanical layer handling. ```pascal var LegacyMLS: boolean; begin LegacyMLS := false; if VerMajor >= AD19VersionMajor then LegacyMLS := false; // Use modern approach // else: Use legacy mechanical layer style (AD17/18) end; ``` -------------------------------- ### Split PCB Library Procedure Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/pcblib-schlib-operations.md Separates a source PCB library into individual library files within a specified directory. ```pascal procedure SplitPcbLibrary( SourceLib: IPCB_Library, OutputDirectory: WideString ); ``` -------------------------------- ### Define INI File Constants Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/project-and-parameters.md Constants defining the structure and default values for project parameter INI files. ```pascal const TopLevelKey = 'PRJParameters'; // INI section heading NoVariantName = 'No Variation'; // Default for project-level cDummyTuples = 'Area=51 | Answer=42 | Question=forgotten'; ``` -------------------------------- ### Archive Project Files Procedure Declaration Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/system-utilities.md Procedure signature for creating compressed archives of project files. ```pascal procedure ArchiveProjectFiles; ``` -------------------------------- ### Configure ExportMechLayerInfo Constants Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/layer-and-mechanical.md Defines the configuration constants required for the ExportMechLayerInfo procedure. ```pascal const TopLevelKey = 'PRJParameters'; cExportMLFilename = 'export-layerstack.stackup'; cExportFNSuffix = '-EML'; ``` -------------------------------- ### Configure Internal Options Procedure Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/system-utilities.md Defines the procedure signature for setting Altium Designer internal configuration options. ```pascal procedure ConfigureInternalOptions; ``` -------------------------------- ### Handle AD17 Display Unit Versioning Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/configuration.md Workaround for Altium Designer 17 where display unit API values are reversed. ```pascal var BUnit: TUnit; VerMajor: integer; begin VerMajor := GetBuildNumberPart(Client.GetProductVersion, 0); BUnit := Board.DisplayUnit; if VerMajor = 17 then begin if BUnit = eImperial then BUnit := eMetric else BUnit := eImperial; end; end; ``` -------------------------------- ### Configuration Constants for OutLineRegions Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/pcblib-schlib-operations.md Constants defining layer targets, line widths, and operational flags for the outline generation process. ```pascal const cTargetLayer = 13; // Source region mechanical layer cTargetCuLayer = 0; // Copper layer (0=top) cDestinLayer = 31; // Destination layer for region outlines cDestinLayer2 = 32; // Destination layer for body outlines cLineWidth = 0.5; // Output line width (mils) ArcResolution = 0.1; // Arc approximation resolution (mils) bDisplay = true; // Show results in UI bRenameExtrudedBody = true; // Rename blank extruded body names ``` -------------------------------- ### Verify Project Parameter Existence Source: https://github.com/brettlmiller/altium-delphiscripts/blob/master/_autodocs/project-and-parameters.md Checks for the presence of a specific parameter within a project and updates it if found. ```pascal Found := ParameterExistsUpdateValue(Prj, Variant, 'ParamName', 'Value', Existing); if not Found then ShowMessage('Parameter does not exist in project'); ```