LSK Panelizer 1.2.3 - Installation and first run
=============================================

Package layout
--------------
LSK_Panelizer_Addin/
    LSK_Panelizer_Addin.py
    LSK_Panelizer_Addin.manifest
    lsk_runtime.py
    engine/
    resources/
    LSK_Panelizer_Script/
        LSK_Panelizer_Script.py
        LSK_Panelizer_Script.manifest

The Add-in and Script share the SAME engine. Extract the complete package.
Do not move the nested Script folder or individual Python/ULP files elsewhere.
No additional Python packages are required.

Before installing an update
---------------------------
Keep the previous working version as a backup outside folders scanned by Fusion.
Stop the old Add-in in Scripts and Add-Ins before replacing its folder. Extract
into a clean location or replace the entire old folder, rather than merging
engine files and __pycache__ from different releases. Do not run two registered
Add-in installations with the same toolbar IDs.

A. Install as a toolbar Add-in
-----------------------------
1. Open Autodesk Fusion and open Scripts and Add-Ins (Utilities > Add-Ins /
   Scripts and Add-Ins; the exact menu location depends on the workspace).
2. Use + / Add / Script or add-in from device and select the OUTER folder:
       LSK_Panelizer_Addin
   Select the folder containing the Add-in .py and .manifest files.
3. Select LSK_Panelizer_Addin, click Run and enable Run on Startup if desired.
4. Open the original single PCB in the 2D PCB editor.
5. Use Manufacturing > LSK > LSK Panelizer.

If updating in the same folder, reuse the existing registration. Do not create
an extra nested LSK_Panelizer_Addin/LSK_Panelizer_Addin directory accidentally.
Restart Fusion after replacing files of an Add-in that was already loaded if
its old launcher remains active.

B. Run directly as a Script
--------------------------
1. Keep the complete extracted package together.
2. In Scripts and Add-Ins, add the NESTED folder:
       LSK_Panelizer_Addin/LSK_Panelizer_Script
3. On the Scripts tab, select LSK_Panelizer_Script.
4. Open the original single PCB, save it (Ctrl+S), and click Run.

Do not run engine/LSK_Panelizer_V1.py or a helper ULP separately. Use the public
LSK_Panelizer_Script launcher so that shared-engine loading and protection
against concurrent runs remain active.

C. Configure and generate a panel
---------------------------------
1. Use the original saved single PCB, not a previous panel. Save pending edits.
2. Set panel version, X/Y quantity, separation method, gaps and rails.
   Rails: 0 disables a rail; an enabled rail is at least 4 mm wide.
   On a top rail, TOP SIDE UP automatically falls back to separate TOP and UP
   words in clear sections when needed. Both words stay at least 1 mm high.
   If neither label layout fits safely, enlarge the rail/sections.
3. For Tab routes, set tabs, router and mouse-bite options. Source tab locations
   must have suitable straight edge sections. Check clearance to real circuitry.
4. On Copper / Registration, choose panel fiducials: Off / 2 / 3 / 4.
   The default is 2; Bottom fiducials remain independently selectable.
5. Optionally choose NPTH tooling holes: Off / 2 / 3 / 4 (default Off) and their
   diameter (default 2 mm). This setting is NOT the mouse-bite drill size.
6. On Export, select TXT, CSV and/or Export Gerber files (+info file). For Gerbers, enter the
   CAM job path or use Browse...; choose a job suitable for the board stack.
   Check / Continue remembers the path and all three flags. TXT/CSV start on,
   Gerbers off. Set defaults restores those flags but keeps the CAM path.
   With all three off, the panel/tables are made without a manufacturing ZIP.
   Review CAD stack thickness in the Export tab. Optionally select Use suggested
   nominal thickness. Exact CAD thickness is the default; the choice and suggestion
   are reset from the current PCB on every run and also apply to the panel table.
7. Choose Check / Continue and inspect the confirmation summary. The program
   verifies feature fit before making a new panel document. Counts are not
   silently reduced and hole diameters are not silently shrunk.
8. Confirm panel creation and let the script finish. Do not switch the active
   document or edit geometry while generation is running.
9. After success, choose where to save the manufacturing/setup ZIP if at least
   one format is selected on Export.
10. Inspect the panel, copper pours and CAM/drill outputs. The separate panel
   is saved automatically even when Gerbers or all file exports are disabled.
   Saving the ZIP is separate from saving the PCB. Save any later edits as usual.

Registration-feature placement rules
------------------------------------------
- Counts are totals for the panel, NOT per rail. Bottom fiducials repeat the
  same physical positions on the other side; tooling holes pass through.
- No rails: set fiducials AND tooling holes to Off.
- One rail: at most 2 fiducials and/or 2 tooling holes. These lie on one line;
  they are not a three-point alignment pattern.
- At least two suitable rails: 3 or 4 features may be selected. The algorithm
  prefers a long opposite pair. Three features form a spread triangle; four
  occupy four corner regions. Extra rails are considered if the first pair
  cannot accommodate the requested hole diameter/clearances.
- Fiducial centres are 2 mm from the PCB-facing rail edge. Their end insets
  differ by at least 10 mm across the pattern.
- Tooling holes have at least 1 mm of material between their rim and rail edges,
  and at least 3 mm from their rim to the fiducial's 2.4 mm clearance square.
  Holes also avoid score lines and drilled tab roots. Their end-inset range is
  at least 5 mm, to avoid a symmetric pin pattern relative to the panel.
- Diameter input range is 0.5-10 mm, but actual rail width/clearance limits apply.
  Example: with normal 0.5 mm copper clearance, a 4 mm rail can accommodate at
  most a 2 mm hole while retaining the 1 mm edge material on both sides.
  A 3 mm hole therefore needs at least a 5 mm rail BEFORE other exclusions.
- These are panelizer design rules, not a universal assembly-house standard.
  Confirm tooling diameter, pin tolerances, positioning and rail width with the
  intended assembler. Do not use a tooling hole as an optical fiducial.
- Long rail labels may cross a V-score annotation if necessary, but the new
  registration features are kept clear. If the full label cannot fit clear of
  features, increase available space, reduce the feature count, or shorten the
  source filename. The label is not silently truncated.

Important: Fusion Upload Options
-------------------------------
For spline / 3D-driven outlines, Fusion may show an Upload Options dialog while
an independent manufacturing PCB is being prepared:

    [ ] Create Electronics Design

UNCHECK Create Electronics Design, then click OK. The panelizer needs a
standalone 2D PCB, not a grouped Electronics Design. This checkbox is not
controlled automatically by the tool.

The original source is not altered. After verified saving and successful CAM
export (if enabled), the temporary _LSK_TRANSFER_WORK_... cloud helper from
this run is closed and deleted by its recorded file ID. Save, audit or CAM
failure retains it. If Fusion refuses cleanup, a warning identifies the helper
for manual removal; the saved panel and completed exports remain valid. Older
helpers, the original source and the finished panel are not cleanup targets.

The finished panel remains open after helper cleanup. If cleanup fails, the
warning includes an LSK_Transfer_Cleanup_*.json report in the Panelizer data
folder under Cleanup. The report records document names, IDs and cleanup
stages; it is not included in the manufacturing ZIP.


Output ZIPs, diagnostics and temporary files
-------------------------------------------
Every enabled manufacturing ZIP includes:
    PCB_MANUFACTURING_INFO.txt (panel dimensions and fabrication requirements)

It also contains the selected outputs:

Export Pick and Place setup file (TXT):
    PICK_AND_PLACE_SETUP.txt

Export Pick and Place setup files (CSV):
    PICK_AND_PLACE_SETUP.csv   (combined TOP/BOT reference table)
    PICK_AND_PLACE_TOP.csv     (TOP only)
    PICK_AND_PLACE_BOT.csv     (BOT only)

Export Gerber files (+info file):
    Fabrication/              (Gerbers, drilling and other configured CAM output)

Every completed panel is saved, including when Gerbers or all exports are off.
The panelizer waits for the new saved version to finish processing, checks the
panel and verifies that the correct document is active. CAM follows only when Gerber export is enabled.
The source PCB is not changed. The selected CAM file is used unchanged. Exported
filenames and job-defined subfolders are preserved. No extra CAM save-location
dialog is requested by the script. Fusion warnings are not auto-confirmed.
The original CAM file and diagnostics are not included in the manufacturing ZIP.

The same selections apply to the local recovery report folder. The manufacturing
information file is always included when at least one export is enabled; disabled
setup TXT/CSV formats are not required. No PANEL_SUMMARY.txt is created.
The internal setup JSON and audit files are not in the manufacturing ZIP.
They may appear in failure diagnostics, which are unaffected by export choices.
With all three checkboxes off, no manufacturing ZIP or empty report folder is made;
normal successful-run cleanup still runs. Information tables and dimensions on d1
are NOT disabled by these file options. Export settings persist after Continue.
Set defaults enables TXT/CSV, disables Gerbers and preserves the chosen CAM path.
Gerber-only export works with TXT and CSV disabled.

The TOP/BOT tables and exported data include every generated FID and TH tooling
hole, with centres relative to the relevant panel corner. Bottom uses horizontal
reflection. The first Bottom PCB is the original lower-right instance. Check
the original component export origin and avoid applying Bottom mirroring twice.

Manufacturing details are listed once beside the panel on d1 and in
PCB_MANUFACTURING_INFO.txt:
- Complete panel size: X/Y dimensions in mm.
- PCB quantity [pcs]: X/Y board counts.
- Min. spacing: the smaller of minimum track width and all nine general
  copper-to-copper clearance limits, in mil and mm.
- Min. hole size: the smallest round drill diameter in the finished panel,
  including vias, component pads, board/footprint holes, mouse-bites and tooling
  holes. A panel without drilled holes is shown as None.
- Copper layers: the number of active copper layers in the board stack.
- PCB thickness: the exact configured CAD stack sum, or the suggested nominal
  value explicitly selected in Export. The CAD sum includes every core/prepreg
  row, copper, mask and finish; it remains in Notes when a nominal value is used.
  It is not a guaranteed finished measurement. A unique nearby nominal value
  is proposed within 5%; this suggestion rule is not a manufacturing tolerance.
  Unreadable full stack data or a changed stack stops further processing.
- Panel separation method: V-scoring, tab routing or combined separation as
  applicable to the configured gaps and panel connections.

The spacing value reports general DRC settings; it does not measure actual
copper spacing or evaluate custom rules. Hole size comes from actual panel
drill data, not the DRC minimum drill setting. Routed slots are excluded.
The separate manufacturing info file is also included in Gerber-only export.

Assembly info contains single-PCB size, complete panel size, first-PCB offset
to origin, X/Y quantity, PCB pitch, gap and all generated fiducial centres.
Tooling-hole centres are retained when present. Assembly TXT/CSV files and
TOP/BOT tables contain no duplicate manufacturing block. Their respective
origins and coordinate mapping guidance are in separate Notes sections below
the main data. Manufacturing notes are likewise below manufacturing data.
The d1 tables use compact column widths with long notes and titles wrapped into
additional lines. Text size, manufacturing values and coordinate mapping are
preserved. TXT/CSV output formats are unchanged by this layout adjustment.

The TXT/CSV files are setup references, not a complete component XY program.
Fabrication contains the native CAM output when Gerber export is enabled.
Include all active copper layers and PTH/NPTH drilling in the chosen CAM job.
Inspect m1 routing/V-score, tooling holes, mouse-bites and the common origin.

On failure, choose where to save the diagnostic ZIP. A save/CAM/output failure
after panel creation keeps the panel open in its current save state and does not
offer an incomplete manufacturing ZIP as completed output. Diagnostics contain PCB
design data; review them before sharing. Nothing is sent automatically.

Cancelling a Save dialog retains the local recovery ZIP and does not discard a
completed panel. A Save/write error is separate from a panel-geometry failure.
Local report and diagnostic paths are shown in the final message. Successful
working folders are cleaned after the selected reports, fabrication files and
complete ZIP have been secured, or after verified saving when all exports are
off. Old temporary folders and cloud helpers from previous runs are not deleted.

Voluntary contribution
----------------------
The Support the author tab explains that the tool was built for our own use and
is shared as-is without dedicated support. A small voluntary contribution is
welcome when it saves substantial time. All features remain available without
a contribution. Contributions do not include support or guaranteed updates.
The project website opens only when clicked:
https://www.lskelectronics.com/lsk-fusion-pcb-panelizer

Known scope / checks before production
-------------------------------------
This is an independent tool, not an Autodesk product. Check the generated output
with your own boards and assembly process. The Windows Fusion workflow has been
used during development; other environments require validation as well.
Panel generation, automatic saving, Gerber export and transfer-helper cleanup
have been confirmed in Fusion during development. For the four-layer CAM job
used for comparison, automated and manual exports had identical manufacturing
data; only creation timestamps differed.

Full stack transfer, including custom inner-copper names, and manufacturing
information were confirmed by user testing on a four-layer PCB in Fusion
2705.1.30. Its configured CAD thickness sum is 1.1978 mm. The final compact d1
table layout has offline validation and has not been separately confirmed in
Fusion. See BUILD_INFO.json for the validation details of this release.

The target's complete preferences are read back before electrical transfer;
a mismatch stops the run and preserves diagnostics. The same source-to-panel
comparison also runs before final reporting and after saving.

Whole-layer padlocks or unsupported geometry may still require manual attention.
Spline conversion precision is export-dependent. Final copper pours, masks,
cutouts, machining and Gerbers must be inspected. Geometric tab placement does
not replace checking component/copper clearance and mechanical panel rigidity.

Technical references
--------------------
Autodesk Scripts and Add-Ins:
https://help.autodesk.com/cloudhelp/ENU/Fusion-360-API/files/WritingDebugging_UM.htm
Autodesk HOLE command:
https://help.autodesk.com/cloudhelp/ENU/Fusion-ECAD/files/ECD-CLI-H.htm
Eurocircuits optical fiducials (printer and Pick & Place):
https://www.eurocircuits.com/technical-guidelines/pcb-assembly-guidelines/fiducials/
PCBWay panel/assembly requirements:
https://www.pcbway.com/pcb_prototype/Panel_Requirements_for_Assembly.html
