# Standalone Roof Platform Engine Audit

## Goal

Move parameter processing out of Autodesk Inventor and compile a browser-renderable assembly catalog directly from JSON.

## Current Standalone Engine

Entry point:

```powershell
python tools/standalone_platform_engine.py preview_exports/assembly/submitted_parameters.json
```

Output:

- `preview_exports/assembly/roof_mount_platform_engine_assembly.json`
- `preview_exports/assembly/standalone_engine_report.json`

The browser now submits parameter edits to `/api/engine-parameters`, which calls the standalone engine instead of Inventor.

## Confirmed Inputs

Top-level editable parameters are in:

- `preview_exports/assembly/editable_parameters.json`

Important parameters currently used by the standalone engine:

- `PLATFORM_INITIAL_LENGTH`
- `PLATFORM_WIDTH_TRUSS_LENGHT`
- `SCREEN_FRONT`
- `SCREEN_BACK`
- `SCREEN_LEFT`
- `SCREEN_RIGHT`
- `SCREEN_HEIGHT`
- `SCREEN_EXTENSION_HEIGHT`
- `PITCH_ANGLE`

Derived values observed from the Inventor model:

- `PLATFORM_LENGHT = PLATFORM_INITIAL_LENGTH + 166 mm`
- `SCREEN_WIDTH = PLATFORM_WIDTH_TRUSS_LENGHT + 1000 mm`
- baseline `truss_spacing = 1166.66666666667 mm`

## Discovered iLogic/Event Structure

OLE stream probing found rule/event references:

- `ROOF_MOUNT_PLATFORM.iam`
  - `AfterAnyUserParamChange0/1/2/3`
  - `AfterDocOpen0`
  - `MASTER_RULE`
  - `BOM_Rule`
- `03 Screen/SCREEN_MAIN_ASM.iam`
  - `AfterAnyUserParamChange0 -> SIZE`
- `03 Screen/03 LEFT/SCREEN_LEFT_ASM.iam`
  - `AfterAnyUserParamChange0 -> SIZE_RULE`
- `01 Truss/TRUSS_LAYOUT_ASM.iam`
  - `DrawingSet`
  - `GeometrySet`

Visible external `.iLogicVb` files under `06 Drawings/04 ExternalRules` are drawing automation helpers, not the main assembly generator.

## Screen Rule Clues

`03 Screen/03 LEFT/SIZE_RULE_DIAG.txt` shows screen logic around:

- `PushPostLeftParams`
- `DoorAdjustment`
- `ScreenSetup`

Observed screen parameters:

- `PLATFORM_WIDTH`
- `SCREEN_HEIGHT`
- `SCREEN_EXTENSION_TYPE`
- `DOOR_WIDTH`
- `SCREEN_TYPE`
- `DOORS_DATA`
- `DOORS_LOCATION`

Example observed door data:

- `DOORS_DATA = "1,R"`
- generated door range similar to `108...1242`
- `DOORS_LOCATION = "108,1242"`

## First-Pass Engine Rules

The current engine is a fast parametric compiler over the exported baseline occurrence graph:

- applies longitudinal scaling from `PLATFORM_INITIAL_LENGTH`
- applies lateral scaling from `PLATFORM_WIDTH_TRUSS_LENGHT`
- suppresses screen side occurrences from the four screen booleans
- scales screen vertical geometry from `SCREEN_HEIGHT + SCREEN_EXTENSION_HEIGHT`
- applies pitch delta to building and mounting folders from `PITCH_ANGLE`
- recomputes active parts, instance counts, folder counts, triangles, and world bounds

Inventor is not used by this path.

## Known Limitations

This is not yet a full replacement for Inventor feature regeneration. It transforms exported baseline meshes and occurrence matrices. Hidden iLogic formulas, adaptive part feature edits, detailed truss member selection, floor opening cuts, door placement generation, purlin count, and mounting bracket layout should be reimplemented as explicit rules next.

## Recommended Next Rule Modules

1. `truss_layout`
   - compute truss count and spacing
   - select repeated truss members
   - generate bracing/post hardware arrays

2. `floor_mesh`
   - generate mesh/batten panel layout
   - apply `FLOOR_OPENINGS_DATA`

3. `screen_layout`
   - generate front/back/left/right sides independently
   - parse door data strings
   - place posts, slats, brackets, flashing, doors, locks, hinges

4. `roof_mounting`
   - derive purlin rows from `PURLIN_SPACING` and `FIRST_PURLIN_TO_ORIGIN`
   - place stirrup/washer/rod groups
   - handle roof type and mounting type options

5. `part_feature_engine`
   - replace mesh stretching with procedural section/profile generation for long RHS/slat/purlin parts
   - emit mesh JSON directly from dimensions
