================================================================================
  LionPCB Gerber Generator
  LION PCB.ir
================================================================================

One click inside Altium Designer produces the exact same Gerber and NC Drill set
that the LION PCB.ir website produces, written next to your own project.


--------------------------------------------------------------------------------
  WHAT IT DOES
--------------------------------------------------------------------------------

With a .PcbDoc open in Altium, choose:

      Tools  ->  LionPCB Gerber

The tool then:

  1. reads the board and works out which layers are actually used
  2. drives the LIONPCB.outjob template - the very same file the website's
     server pipeline uses, so the output set is identical
  3. writes the Gerber and NC Drill files to

         <folder of your .PcbDoc>\Project Outputs for <board name>\

  4. waits until Altium has genuinely released the files, then packs them into

         <folder of your .PcbDoc>\<board name>_<date>_<time>.rar

     e.g.  MainBoard_2026-09-04_06-49-36.rar

  5. shows how long it took and where everything went

Nothing is uploaded anywhere. Everything happens on your machine.


--------------------------------------------------------------------------------
  WHY THE OUTPUT MATCHES THE WEBSITE
--------------------------------------------------------------------------------

This is not a re-implementation. The layer selection, the OutJob rewriting, the
temporary project context and the wait logic are the same code that runs on the
LION PCB.ir production server, and LIONPCB.outjob is byte for byte the same
template file. What differs is only where the result is written: beside your
project instead of into the server's queue.


--------------------------------------------------------------------------------
  REQUIREMENTS
--------------------------------------------------------------------------------

  * Altium Designer (tested on AD26 / 26.7.1)
  * Windows 10 or 11, 64-bit
  * WinRAR - optional. If it is installed the archive is a .rar, otherwise the
    tool falls back to a .zip automatically. Nothing to configure either way.

No administrator rights are needed. Nothing is installed into Program Files.


--------------------------------------------------------------------------------
  INSTALLING
--------------------------------------------------------------------------------

  1. Close Altium Designer completely (File > Exit).
     This matters: Altium rewrites its own menu configuration when it exits, so
     a change made while it is running would simply be discarded.

  2. Run LionPCB_Gerber_Setup.exe

The setup checks three things before writing anything at all:

     Step 1  Is Altium Designer installed?
     Step 2  Has this user started Altium at least once?
     Step 3  Is Altium closed right now?

If any check fails it stops and explains why, and your machine is left exactly
as it was.

Files are installed to:

     %LOCALAPPDATA%\LionPCB\Gerber Tool

A desktop shortcut is also created. It launches Altium straight into the tool,
which is handy when Altium is not already running.


--------------------------------------------------------------------------------
  SETTINGS
--------------------------------------------------------------------------------

Edit:

     %LOCALAPPDATA%\LionPCB\Gerber Tool\Settings.ini

     ArchiveDir=

  empty            the archive is written next to the .PcbDoc  (default)
  a folder path    every archive is collected in that one folder instead

Example:

     ArchiveDir=D:\Gerber Archive

A folder that does not exist is ignored rather than failing the run.


--------------------------------------------------------------------------------
  IF SOMETHING GOES WRONG
--------------------------------------------------------------------------------

The tool writes a log next to the .PcbDoc:

     LionPCB_Gerber_Log.txt

It records every step - opening the board, locating the template, running the
OutJob, waiting for the report, packing - so it is usually obvious where a run
stopped.

Things worth knowing:

  * "Timed out" means Altium did not finish generating within 45 minutes. The
    archive is deliberately NOT written in that case: a partial archive reported
    as a success is worse than no archive. Raise GerberTimeoutMinutes at the top
    of LionPCB_GerberSimple.pas if you routinely work with very large boards.

  * "outputs still locked after 30s" means something else was holding the output
    files open. The archive is still created, but check its contents.

  * If the menu item does nothing, the most likely cause is that Altium was
    running during installation and discarded the menu record. Close Altium and
    run the setup again.


--------------------------------------------------------------------------------
  REMOVING IT
--------------------------------------------------------------------------------

Close Altium, then run:

     LionPCB_Gerber_Setup.exe /uninstall

That removes the installed files, the desktop shortcut and the menu entry, and
puts Altium back exactly as it was.


--------------------------------------------------------------------------------
  WHAT GETS TOUCHED ON YOUR MACHINE
--------------------------------------------------------------------------------

  %LOCALAPPDATA%\LionPCB\Gerber Tool\        the tool itself
  %APPDATA%\Altium\Altium Designer {GUID}\DXP.RCS
                                            one menu command is added here
  Desktop\LionPCB Gerber.lnk                shortcut

DXP.RCS is backed up as DXP.RCS.lionpcb-backup before it is touched. Nothing
else on the system is modified, and no service, driver or registry key is
installed.


--------------------------------------------------------------------------------
  LION PCB.ir
--------------------------------------------------------------------------------
