by adom
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.
sch_place_part / create_part_project drop SIM models; how to add a SPICE model that reaches the IntLib
altium-bridge 0.2.113 · Altium Designer Develop 26.x (licensed) · Windows 11 (Hydrogen local workspace)
1. altium_sch_place_part and altium_create_part_project drop the symbol's simulation model
What I did: a SchLib symbol (a switching diode) carries three implementations: a PCBLIB footprint, a SIM model (added through Altium's Sim Model dialog from a manufacturer .mdl), and the STRESS model Altium adds with it. I placed it on a sheet two ways:
altium_create_part_project {part, libraryPath, outputDir}(the part lands on the sheet as U1)altium_sch_place_part {sheet, library, symbol, designator:"D1", x, y}
Expected: the placed part carries every implementation of the library symbol, as a placement from the Components panel does.
What happened: both placed parts carry only the footprint. A DelphiScript walk of the sheet's implementations gives, for each:
comp U1 lib=<symbol> src=<path>.SchLib
impl PCBLIB <footprint> cur=True map=(2:2),(1:1)
comp D1 lib=<symbol> src=<path>.SchLib
impl PCBLIB <footprint> cur=True map=(2:2),(1:1)
So altium_simulate {analysis:{type:"op"}} refuses with no_model: "no part of the sheet has a simulation model: the netlist holds no elements" (parts: ["U1"]), and altium_export_spice writes a netlist with no D element. A library with a correct SIM model cannot be tested through the bridge.
altium_sch_update_from_library {sheet, designators} answered "unchanged" (same pins), so it doesn't restore the model either.
Ask: copy all implementations (SIM, STRESS, PCB3D, etc.) when placing, or place through Altium's own library placement. At least, say in the reply which model types were not carried over, so a caller doesn't read a missing model as a library fault.
2. Adding a SPICE model to a SchLib symbol: what works and what doesn't
There's no verb for this (altium_add_models and altium_set_models take footprints only). The skill could document it, or a verb (altium_add_sim_model {libraryPath, symbolName, mdlPath, pinMap}) could do it. What I found:
A scripted SIM implementation is not enough. This saves cleanly:
AddSchImplementation with ModelType SIM, Description Diode, ModelName, AddDataFileLink(name, file.mdl, 'MDL'), MapAsString, plus parameters on the implementation copied from Altium's own example diode (Spice Prefix=D, Kind=General, SubKind=Diode, the Netlist template, Area Factor and the rest).
But the IntLib compiler does not pack it: no MDL/ stream, and LibCrossRef.Txt lists only the PCBLIB model. This held whether the datafile link was relative, absolute, or absent (UseComponentLibrary). Setting Impl.UseComponentLibrary := False from a script did not stick.
The Sim Model dialog writes a different form, and that one works. The user added the model through the dialog and saved. Its records are:
RECORD=45 ... Description=Model Description|ModelName=<name>|ModelType=SIM|DatafileCount=1|ModelDatafile0=<full path>.mdl|ModelDatafileEntity0=<name>|ModelDatafileKind0=mdl|IsCurrent=T(lower-casemdl, no UseComponentLibrary or DatalinksLocked).- Map records (
RECORD=47) as usual. - Parameters on the implementation:
Kind,SubKind,Spice Prefix,Excluded Parts,Syntax,SimulationCacheLocation(ReadOnlyState=3),Source=Local.- A longer
Netlisttemplate (with?DTEMP,?L,?M,?PJ,?SENS_AREA,?T_REL_LOCAL,?Wclauses, stored as%UTF8%Text). - Every
.MODELparameter copied in as its own parameter (IS,RS,BV,IBV,CJO,M/MJSW,N,TT, ...), with SPICE defaults for the ones the file omits.
- A separate
ModelType=STRESSimplementation (ModelNameDiode) with aPortMapand empty derating parameters (IF,IFD,IFS,IRMX,PDM,VR,VD,TJ,RJC,RCA).
After that, the LibPkg compiles to an IntLib with MDL/0.mdl and a SIM entry in LibCrossRef.Txt.
Also worth documenting:
- Vendor SPICE files often have an uncommented title line between the comment header and
.MODEL; strip to a clean.mdlbefore linking. - Add the
.mdlto the LibPkg as a document. - SPICE diode nodes are anode, cathode. With cathode = pin 1, map symbol 1 to model 2 and symbol 2 to model 1.
- A simulation run opens its own window with a second Altium taskbar icon, which a user can mistake for a second Altium instance.