0

I'm writing some small Delphi script for Altium Designer that create an HTML report based on the PCB file.

Which API command should I use to open the HTML file created before from that script?

For now, I can only display the TEXT file by using: "Document := Client.OpenDocument('Text', FileName);"

Below, I attached my script.

Procedure DisplayReport;
Var
    Board           : IPCB_Board;
    Rpt             : TStringList;
    FileName        : TPCBString;
    Document        : IServerDocument;

Begin
    // Retrieve the current board
    Board := PCBServer.GetCurrentPCBBoard;
    If Board = Nil Then Exit;

    FileName := ChangeFileExt(Board.FileName,'.html');
    Rpt := TStringList.Create;
    
    Rpt.Add('<h1>html header</h1>');
    Rpt.Add('<table border="1">');
    Rpt.Add('<tr>');
    Rpt.Add('<tr style="background-color: yellow; ">');
    Rpt.Add('<th>#</th>');
    Rpt.Add('<th>RefDes</th>');
    Rpt.Add('<th>Layer</th>');
    Rpt.Add('<th>Footprint</th>');
    Rpt.Add('</tr>');

    Rpt.Add('<tr>');
    Rpt.Add('<th>1</th>');
    Rpt.Add('<th>R1</th>');
    Rpt.Add('<th>TOP</th>');
    Rpt.Add('<th>SMD_0603</th>');
    Rpt.Add('</tr>');

    Rpt.Add('<tr>');
    Rpt.Add('<th>1</th>');
    Rpt.Add('<th>R2</th>');
    Rpt.Add('<th>TOP</th>');
    Rpt.Add('<th>SMD_0603</th>');
    Rpt.Add('</tr>');

    Rpt.Add('<tr>');
    Rpt.Add('<th>1</th>');
    Rpt.Add('<th>R3</th>');
    Rpt.Add('<th>BOT</th>');
    Rpt.Add('<th>SMD_0085</th>');
    Rpt.Add('</tr>');

    Rpt.Add('</table>');

    Rpt.SaveToFile(Filename);
    Rpt.Free;

    //open TXT file
    //Document  := Client.OpenDocument('Text', FileName);
    
    //try to open HTML file
    Document  := Client.OpenDocument(Client.GetDocumentKindFromDocumentPath(Filename), Filename);
    If Document <> Nil Then
        Client.ShowDocument(Document);

End;

1 Answers1

0

Try this repository: https://github.com/Altium-Designer-addons/scripts-libraries

There is an Example to run any program out of Altium in the Folder "\Scripts - Examples\Run_exe"

You can start your desired browser and pass the path & name of the HTML file as parameter to the Browser

schwdk
  • 547
  • 3
  • 13