← Commit history

0.2.116: export_3d runs Altium's Parasolid/VRML output through an OutJob, headless; File > Export only as a fallback

Colby Knox ·4b61622cb1 · ·parent 01eabe6
9 files changed +79−18
CHANGELOG.md+5
@@ -1,5 +1,10 @@ # Changelog +## 0.2.116++- **`altium_export_3d` works in a fresh Altium.** It opened Altium's Parasolid or VRML exporter as the n-th entry of File > Export, but Altium fills that menu only when it is first opened in a session: in an Altium just started (every battery run) the entry did not exist, and the verb answered `exporter_not_found`. It now runs Altium's own Parasolid / VRML output, from the same generator as STEP, through an OutJob on a throwaway project, as `altium_export_step` does: headless, no window raised, no input approval. The menu route stays as the fallback when the OutJob writes nothing (`lane: menu`, with `outjobFirst` saying why).+- Tested on Altium Designer 26.11.1 and Develop, each freshly started: Parasolid (`.x_t`, the same size the menu route wrote) and VRML (`#VRML V2.0`).+ ## 0.2.115  - **New verb `altium_add_sim_model`: a SPICE model on a library symbol** (#42). Give it a `.SchLib` symbol and a SPICE file (`.MODEL` or `.SUBCKT`: diodes, BJTs, MOSFETs, JFETs, subcircuits). It writes a clean copy of the model beside the library (a vendor's uncommented title line dropped) and puts it on the symbol the way Altium's Sim Model dialog does: the model file linked by its full path with kind `mdl`, Kind, SubKind, Spice Prefix and Netlist on the model, and the symbol's pins mapped onto the model's nodes. The placed part simulates in Altium, and the IntLib compiler packs the model.
bridge-rs/src/geom3d.rs+17
@@ -127,6 +127,21 @@ pub fn export_3d(args: &Value) -> Value {         let dir = s("outputDir").map(std::path::PathBuf::from).unwrap_or_else(|| bpath.parent().unwrap_or(std::path::Path::new(".")).to_path_buf());         dir.join(format!("{stem}.{ext}")).to_string_lossy().to_string()     }).replace('/', "\\");+    // headless first: the OutJob output Altium's STEP generator also makes (ExportPARASOLID, ExportVRML). The File >+    // Export entries the menu route opens exist only once that menu has been opened in the session, so in a fresh+    // Altium the menu route opened nothing (#42 follow-up, 2026-12-01)+    if !std::path::Path::new(&board.replace('\\', "/")).is_file() && !std::path::Path::new(&board).is_file() {+        return json!({"success": false, "errorCode": "file_not_found", "error": format!("{board} is not on this machine")});+    }+    let output_type = if label == "PARASOLID" { "ExportPARASOLID" } else { "ExportVRML" };+    let outjob_err = match crate::outputs::export_3d_outjob(&board, output_type, ext, &out, Duration::from_secs(300)) {+        Ok(path) => {+            let bytes = std::fs::metadata(&path).map(|m| m.len()).unwrap_or(0);+            return json!({"success": bytes > 0, "format": format, "path": path.replace('\\', "/"), "bytes": bytes, "lane": "outjob", "windowEtiquette": "background",+                "_hint": "Written by Altium's own Parasolid/VRML output (an OutJob on a throwaway project), with no window raised. A board open with unsaved changes exports its saved state: altium_save first."});+        }+        Err(e) => e,+    };     if let Err(e) = crate::ab::need_input_approval("answer Altium's export dialogs (the file name and the export options)", 90) { return e; }     if let Some(e) = crate::support::must_open(&board, 60) { return e; }     // a file already there would raise Windows' overwrite question: the caller asked for this path. Its folder must@@ -140,6 +155,8 @@ pub fn export_3d(args: &Value) -> Value {     let start = crate::lifecycle::start(Duration::from_secs(90));     let mut r = r;     r["agentRestarted"] = json!(start.get("success").and_then(|v| v.as_bool()) == Some(true));+    r["lane"] = json!("menu");+    r["outjobFirst"] = outjob_err;     if r.get("success").and_then(|b| b.as_bool()) == Some(true) { r["format"] = json!(format); }     r }
bridge-rs/src/main.rs+1−1
@@ -88,7 +88,7 @@ use tiny_http::{Header, Method, Response, Server}; /// Attached to every failed reply (see the /command handler). const REPORT_ISSUES: &str = "If this looks like an altium-bridge BUG (not a refusal you expected), report it: check for a duplicate with `adom-wiki issue list adom/altium-bridge`, then `adom-wiki issue create adom/altium-bridge --title \"<verb>: <one-line symptom>\" --category bug-report --body \"<what you ran, what you expected, what happened, the VERBATIM response JSON (and errorShot if present), bridgeVersion, the Altium version from altium_status, the OS>\"`. A relay, routing, toast or lifecycle problem belongs on adom/adom-bridge instead. Reports from real machines are how this bridge gets correct: three different Altium builds behaved three different ways in one weekend."; -pub const BRIDGE_VERSION: &str = "0.2.115";+pub const BRIDGE_VERSION: &str = "0.2.116";  fn json_response(status: u16, body: &serde_json::Value) -> Response<std::io::Cursor<Vec<u8>>> {     let data = serde_json::to_vec(body).unwrap_or_else(|_| b"{}".to_vec());
bridge-rs/src/outputs.rs+49−10
@@ -249,7 +249,11 @@ fn step_suffix_type(name: &str) -> Option<u8> {     } } -fn step_outjob_text(args: &Value) -> Result<String, String> {+fn step_outjob_text(args: &Value) -> Result<String, String> { outjob_3d_text(args, "ExportSTEP", "STEP") }++/// An OutJob with one of the 3D outputs Altium's STEP generator makes (ExportSTEP, ExportPARASOLID, ExportVRML: one+/// generator, OUT_ExportSTEP.dll, AD 26 System/ExportSTEP.OUT), configured with the STEP view record.+fn outjob_3d_text(args: &Value, output_type: &str, medium: &str) -> Result<String, String> {     let b = |k: &str, d: bool| args.get(k).and_then(|v| v.as_bool()).unwrap_or(d);     let tf = |v: bool| if v { "True" } else { "False" };     let holes = b("holes", true);@@ -268,15 +272,15 @@ fn step_outjob_text(args: &Value) -> Result<String, String> {         "Record=ExportSTEPView|ExportComponentOptions={}|ExportModelsOption={}|ExportHolesOption=0|CanSelectPrimitives=False|IncludeMechanicalPadHoles={}|IncludeElectricalPadHoles={}|IncludeFreePadHoles={}|ExportFoldedBoard={}|ExportFoldedBoardRate=100|ComponentSuffixType={}|ComponentSuffix={}|ExportCopperOption={}|ExportCopperLayer=1|ExportPadAndViaBarrelsOnly=False|IgnoreBoardCopperLayerColors=False|ExportAsSinglePart={}",         n("componentsOption", 0), n("modelsOption", 2), tf(holes), tf(holes), tf(holes), tf(b("folded", false)),         suffix_type, if suffix.is_empty() { " ".to_string() } else { suffix }, n("copperOption", 0), tf(b("singlePart", false)));-    let lines = [-        "[OutputJobFile]", "Version=1.0", "Caption=", "Description=Adom altium_export_step", "",-        "[OutputGroup1]", "Name=", "Description=", "TargetOutputMedium=STEP", "VariantName=[No Variations]", "VariantScope=0",-        "CurrentConfigurationName=", "TargetPrinter=",-        "PrinterOptions=Record=PrinterOptions|Copies=1|Duplex=1|TrueTypeOptions=3|Collate=1|PrintJobKind=1|PrintWhat=1",-        "OutputMedium1=STEP", "OutputMedium1_Type=GeneratedFiles",-        "OutputType1=ExportSTEP", "OutputName1=STEP", "OutputCategory1=Export", "OutputDocumentPath1=", "OutputVariantName1=",-        "OutputEnabled1=1", "OutputEnabled1_OutputMedium1=1", "OutputDefault1=0",-        "Configuration1_Name1=OutputConfigurationParameter1",+    let lines: Vec<String> = vec![+        "[OutputJobFile]".to_string(), "Version=1.0".into(), "Caption=".into(), format!("Description=Adom {output_type}"), "".into(),+        "[OutputGroup1]".into(), "Name=".into(), "Description=".into(), format!("TargetOutputMedium={medium}"), "VariantName=[No Variations]".into(), "VariantScope=0".into(),+        "CurrentConfigurationName=".into(), "TargetPrinter=".into(),+        "PrinterOptions=Record=PrinterOptions|Copies=1|Duplex=1|TrueTypeOptions=3|Collate=1|PrintJobKind=1|PrintWhat=1".into(),+        format!("OutputMedium1={medium}"), "OutputMedium1_Type=GeneratedFiles".into(),+        format!("OutputType1={output_type}"), format!("OutputName1={medium}"), "OutputCategory1=Export".into(), "OutputDocumentPath1=".into(), "OutputVariantName1=".into(),+        "OutputEnabled1=1".into(), "OutputEnabled1_OutputMedium1=1".into(), "OutputDefault1=0".into(),+        "Configuration1_Name1=OutputConfigurationParameter1".into(),     ];     let mut out = lines.join("\r\n");     out.push_str(&format!("\r\nConfiguration1_Item1={item}\r\n\r\n[PublishSettings]\r\n\r\n[GeneratedFilesSettings]\r\nRelativeOutputPath1=\r\nOpenOutputs1=0\r\nAddToProject1=0\r\nTimestampFolder1=0\r\nUseOutputName1=0\r\nEnableReload1=0\r\n"));@@ -478,6 +482,41 @@ fn export_step_outjob(args: &Value) -> Value {         "_hint": "products[] are the STEP part names: Altium names each component by its DESIGNATOR (suffixType only appends none/board/custom/id), and a 3D model keeps the name inside its own STEP. Each component occurrence is also named after its designator (occurrences.named), as KiCad's STEP does, so step2glb --molecule finds MP1-MP4; nameOccurrences:false keeps Altium's empty names. Pull the file with ab's pull_file."}) } +/// A board's Parasolid or VRML through an OutJob, headless, as altium_export_step does: Altium's File > Export entries+/// exist only once that menu has been opened in the session, so PCB:Export Index=n opened nothing in a fresh Altium+/// (export_3d failed in every battery, 2026-12-01). Ok(path) with the file copied to `out`, Err(reply) otherwise.+pub fn export_3d_outjob(pcb: &str, output_type: &str, ext: &str, out: &str, timeout: Duration) -> Result<String, Value> {+    let outjob = outjob_3d_text(&json!({}), output_type, output_type).map_err(|e| json!({"success": false, "errorCode": "bad_args", "error": e}))?;+    let tmp = std::env::temp_dir().join("adom-altium-3d").join(format!("{}", (support::now() * 1000.0) as u64));+    let proj = tmp.join("Adom3dExport.PrjPcb");+    let oj = tmp.join("Adom3d.OutJob");+    let prj = format!("[Design]\r\nVersion=1.0\r\nHierarchyMode=0\r\n\r\n[Document1]\r\nDocumentPath={}\r\nAnnotationEnabled=1\r\nDocumentUniqueId=\r\n\r\n[Document2]\r\nDocumentPath=Adom3d.OutJob\r\nAnnotationEnabled=1\r\nDocumentUniqueId=\r\n",+        pcb.replace('/', "\\"));+    if let Err(e) = std::fs::create_dir_all(&tmp).and_then(|_| std::fs::write(&oj, outjob)).and_then(|_| std::fs::write(&proj, prj)) {+        return Err(json!({"success": false, "errorCode": "temp_write_failed", "error": e.to_string()}));+    }+    let proj_s = proj.to_string_lossy().to_string();+    let r = run_outjob(&json!({"outjobPath": oj.to_string_lossy(), "medium": output_type, "projectPath": proj_s, "timeout": timeout.as_secs()}));+    // the file lands in a folder named after the output; look in every one+    let mut produced = None;+    let mut stack = vec![tmp.join("Project Outputs for Adom3dExport")];+    while let Some(d) = stack.pop() {+        for e in std::fs::read_dir(&d).into_iter().flatten().flatten() {+            let p = e.path();+            if p.is_dir() { stack.push(p); } else if p.extension().map(|x| x.eq_ignore_ascii_case(ext)).unwrap_or(false) { produced = Some(p); }+        }+    }+    let _ = agent::call("close_document", &[("path", oj.to_string_lossy().to_string())], None, Duration::from_secs(30));+    let _ = agent::call("close_document", &[("path", proj_s.clone())], None, Duration::from_secs(30));+    let Some(src) = produced else {+        return Err(json!({"success": false, "errorCode": "not_written", "outjob": r, "tempDir": tmp.to_string_lossy()}));+    };+    if let Some(parent) = std::path::Path::new(out).parent() { let _ = std::fs::create_dir_all(parent); }+    std::fs::copy(&src, out).map_err(|e| json!({"success": false, "errorCode": "copy_failed", "error": e.to_string()}))?;+    let _ = std::fs::remove_dir_all(&tmp);+    Ok(out.to_string())+}+ /// Headless STEP with real holes/copper/models — Barrett's AdomBridge:ExportStep. fn export_step_extension(args: &Value) -> Value {     if let Some(g) = support::need_licensed() {
bridge-rs/src/verbs.rs+2−2
@@ -521,8 +521,8 @@ fn describe() -> Value {             &["import_kicad", "open_project", "project_info"], &["Altium's Import Wizard also reads PADS, OrCAD, P-CAD, Allegro, xDxDesigner, CADSTAR and Zuken: those are refused by name until the bridge drives them."], json!({"format": "eagle", "filePath": "C:/designs/Board.sch"})),         verb_doc("export_3d", "The board's 3D model in another format than STEP, by Altium's own exporter (File > Export): Parasolid (.x_t) or VRML (.wrl). step answers through export_step; a format Altium does not write is refused by name.",             json!({"filePath": "the .PcbDoc (required)", "format": "parasolid | vrml | step (required; stl, obj, glb, 3mf, iges, ply and pdf3d are refused by name)", "output": "the file to write (default beside the board)", "outputDir": "folder, when output is not given", "timeout": "seconds to wait for the file, default 300"}),-            json!({"path": "the file", "bytes": "int", "format": "string", "exporter": "Altium's exporter", "exporterIndex": "its place on File > Export"}), 360,-            "Altium's exporters ask in dialogs: the bridge answers them (file name, then the export options at their defaults: the whole board, every component with its 3D body, pad holes) and waits for the file.",+            json!({"path": "the file", "bytes": "int", "format": "string", "lane": "outjob (headless, the usual one) | menu (File > Export, when the OutJob wrote nothing)", "exporter": "Altium's exporter (menu lane)", "exporterIndex": "its place on File > Export (menu lane)", "outjobFirst": "why the OutJob wrote nothing (menu lane)"}), 360,+            "Runs Altium's own Parasolid / VRML output (the generator altium_export_step uses) on a throwaway project, with no window raised. Only when that writes nothing does it fall back to File > Export, answering the exporter's dialogs (that menu's entries exist only once it has been opened in the session, so the fallback can find none in a fresh Altium).",             &["export_step", "render_board", "import_step", "bodies"], &["Altium's own defaults: folded boards export folded; components export as their 3D bodies.", "A mesh format (stl, obj, glb) is not Altium's: make it from the STEP outside Altium."], json!({"filePath": "C:/proj/Board.PcbDoc", "format": "parasolid"})),         verb_doc("import_step", "Place a STEP with the board as free 3D geometry (an enclosure, a bracket, a lid) for fit checks: a 3D body of the board itself on a mechanical layer, belonging to no part, and the parts' bodies it now meets.",             json!({"filePath": "the .PcbDoc (required)", "stepPath": "the .step or .stp on this machine (required)", "at": "[x, y] mm in the board model's frame (routing_state): where the STEP's own origin lands, default [0, 0]", "rotation": "[rx, ry, rz] degrees, default [0, 0, 0]", "standoffMm": "height of the model's origin above the board surface, default 0", "side": "top | bottom, default top", "layer": "mechanical layer 1 to 16, default 1"}),
package.json+1−1
@@ -1,6 +1,6 @@ {   "slug": "altium-bridge",-  "version": "0.2.115",+  "version": "0.2.116",   "type": "app",   "description": "Let an AI (Claude, ChatGPT, Codex or any agent) run Altium Designer for you: create symbols and footprints, place parts (also from Altium 365), wire and annotate schematics, Update PCB, set the stack-up and rules, route, pour copper, add mounting holes and stitching vias, run ERC and DRC, and make Gerbers, BOMs and STEP. Free in Hydrogen; bring your own AI and Altium licence.",   "tags": [
page.json+2−2
@@ -4,7 +4,7 @@   "type": "app",   "title": "Altium Bridge: AI for Altium Designer",   "brief": "Let an AI (Claude, ChatGPT, Codex or any agent) run Altium Designer for you: create symbols and footprints, place parts (also from Altium 365), wire and annotate schematics, Update PCB, set the stack-up and rules, route, pour copper, add mounting holes and stitching vias, run ERC and DRC, and make Gerbers, BOMs and STEP. Free in Hydrogen; bring your own AI and Altium licence.",-  "version": "0.2.115",+  "version": "0.2.116",   "hero": {     "type": "image",     "path": "screenshots/hero.png"@@ -159,4 +159,4 @@     "tools/symbol_modes.py",     "uninstall.sh"   ]-}\ No newline at end of file+}
src/BRIDGE_VERSION+1−1
@@ -1 +1 @@-0.2.115+0.2.116
src/bridge.json+1−1
@@ -2,7 +2,7 @@   "manifest_version": 1,   "name": "altium",   "displayName": "Altium Designer",-  "version": "0.2.115",+  "version": "0.2.116",   "description": "Drive Altium Designer from Adom: a resident DelphiScript agent (eval + the 1,100-command process launcher), the X2 -R command line, UIA over the VCL shell, dialogs by PID, screenshots of every Altium window, and Altium 365.",   "homepage": "https://wiki.adom.inc/adom/altium-bridge",   "docs": "https://wiki.adom.inc/adom/altium-bridge",