← HomeSeries
Software Through the Ages
EPISODE 38 · 1986 → today

Engineering automation: AutoLISP, CAD macros and test sequencers

Engineers repeat work too: drawing the same flange in twenty sizes, re-running an analysis for every load case, stepping a rig through the same test sequence for a thousand hours. Engineering software grew its own automation layers — AutoLISP inside AutoCAD, VBA and APIs in 3D CAD, command languages and Python in analysis codes, and test sequencers that run rigs unattended.

1986
AutoLISP in AutoCAD 2.18
1990
SCPI: standard commands for instruments
1996
ObjectARX (C++) for AutoCAD R13
1998
NI TestStand test sequencer
2000s
Python scripting in Abaqus, FreeCAD and more
2020s
PyAnsys and Python everywhere in CAE

01The requirement: design and test families, not single items

RequirementWhyWhat automation offered
Standard parts in many sizesFlanges, brackets, gears and fasteners follow rulesParametric programs that draw from a table of dimensions
Company drawing standardsTitle blocks, layers and text styles must be consistentStart-up routines and checking macros
Many analysis casesLoad cases, temperatures and design variantsBatch runs from command files and scripts
Long unattended testsEndurance tests run day and night for weeksTest sequencers with limits, alarms and logs
Instrument controlMeters, supplies and analysers must be set and read the same way every timeGPIB, SCPI, VISA and drivers called from scripts

02Automating CAD

1980s — Script files. AutoCAD could replay a .scr file of typed commands — still useful for batch plotting and simple drawings.
1986 — AutoLISP. AutoCAD 2.18 embedded a dialect of LISP. Draughtsmen and CAD managers wrote thousands of routines — parametric parts, title blocks, layer tools — and shared them in magazines and later on CAD forums. Visual LISP (AutoCAD 2000) added an editor and debugger. AutoLISP still runs in AutoCAD and in compatible programs such as BricsCAD and ZWCAD.
1990–1996 — ADS and ObjectARX. C and then C++ interfaces (ObjectARX, AutoCAD R13) let software houses build vertical products for architecture, piping and mechanical design on AutoCAD.
Late 1990s — VBA everywhere. Microsoft licensed VBA (Episode 36) to CAD vendors. AutoCAD, SolidWorks, CATIA V5 and others gained VBA macros; SolidWorks' macro recorder writes VBA that changes dimensions, rebuilds and exports drawings.
2000s — Full APIs. .NET APIs in AutoCAD and SolidWorks; NX Open (C++, Java, .NET, Python) in Siemens NX; Toolkit and J-Link for Creo; CAA for CATIA. Knowledge-based engineering tools (CATIA Knowledgeware, NX Knowledge Fusion) captured design rules.
2010s → — Python and the cloud. FreeCAD (Episode 30) is scripted entirely in Python; the open-source ezdxf library writes DXF drawings without any CAD program; Onshape uses FeatureScript for custom features.

03Try it: one program, any flange

Set the dimensions. The generator writes the same drawing three ways: an AutoLISP command, an AutoCAD script file, and a Python ezdxf program that writes a DXF without AutoCAD.

04Automating analysis

SoftwareAutomation layerTypical use
ANSYS Mechanical APDLANSYS Parametric Design Language — command files with variables, loops and macros; PyAnsys (Python) since the 2020sParametric models, many load cases, design optimisation
NASTRANText input decks (bulk data cards)Generated by pre-processors or scripts; run in batch
AbaqusPython scripting of Abaqus/CAE; every GUI action is journalled as PythonModel generation, result extraction
COMSOLLiveLink for MATLAB, Java API, applications built in the Application BuilderPackaging simulations as simple apps for non-specialists
MATLAB / OctaveScripts and functions; matlab -batch (R2019a and later) runs without the desktopPost-processing test data overnight (Episode 27)
FreeCAD, CalculiX, Code_AsterPython and text input filesFully scripted open-source workflows (Episodes 19, 29)

05Automating test rigs

1970s–80s — HP BASIC and GPIB. Hewlett-Packard's desktop computers ran "Rocky Mountain BASIC" with built-in commands for HP-IB (GPIB, Episode 28) instruments; it was the standard for automated test for a decade.
1990 — SCPI. The Standard Commands for Programmable Instruments gave meters and sources common text commands such as *IDN?, MEAS:VOLT:DC? and *RST.
1995–1998 — VISA and IVI. The VISA library hid the difference between GPIB, serial, USB and Ethernet connections; IVI drivers made instruments of the same class interchangeable.
1998 — TestStand. National Instruments' sequencer separated the sequence (steps, limits, loops, reporting) from the code modules (LabVIEW, C, .NET, Python). Production lines and qualification labs adopted it widely; other sequencers include ATEasy and in-house frameworks.
2000s → — Python. PyVISA, pySerial, Modbus and OPC UA libraries, and vendor packages (nidaqmx) made Python a common choice for rig control and data handling, often beside LabVIEW or DEWESoft.

06Try it: run a test sequence

A sequencer runs steps in order, compares each measurement with its limits, and writes a report. Inject a fault and run again: the sequence stops safely at the first critical failure.

07Ready-to-use scripts

A. Change a dimension and rebuild (SolidWorks VBA macro)

' Tools → Macro → New; set the dimension name to one in your model
' (right-click a dimension → Properties shows names like D1@Sketch1).
Dim swApp As Object

Sub main()
    Dim part As Object
    Set swApp = Application.SldWorks
    Set part = swApp.ActiveDoc
    If part Is Nothing Then MsgBox "Open a part first": Exit Sub
    part.Parameter("D1@Sketch1").SystemValue = 0.2   ' API units are metres: 200 mm
    part.EditRebuild3
End Sub

B. Read a meter through SCPI (Python + PyVISA)

# pip install pyvisa pyvisa-py   (or install NI-VISA / Keysight IO Libraries)
import time
import pyvisa

rm = pyvisa.ResourceManager()
print(rm.list_resources())                       # find your instrument's address
dmm = rm.open_resource("GPIB0::22::INSTR")       # replace with the address listed above
dmm.timeout = 5000                               # ms
print(dmm.query("*IDN?").strip())
dmm.write("*RST")
dmm.write("CONF:VOLT:DC 10")                     # 10 V range
with open("dmm_log.csv", "w") as f:
    f.write("time_s,volts\n")
    t0 = time.time()
    for _ in range(60):                          # one reading per second for a minute
        v = float(dmm.query("READ?"))
        f.write(f"{time.time() - t0:.1f},{v:.6f}\n")
        time.sleep(1)
dmm.close()

C. Process every run overnight (MATLAB batch from a Windows task)

rem run_matlab.bat — schedule with Task Scheduler (Episode 35); needs MATLAB R2019a or later
"C:\Program Files\MATLAB\R2026a\bin\matlab.exe" -batch "process_runs('D:\Archive\Data')" > D:\Archive\matlab_log.txt 2>&1

process_runs.m is your own function on the MATLAB path; -batch exits with a non-zero code if it fails, so the log and Task Scheduler history show errors.

08Version explorer

Blue chips: CAD and CAE automation. Amber chips: test and instrument automation.

See also: Episode 28: LabVIEW and data acquisition — the DAQ software these sequences drive · Episode 09: AutoCAD and engineering CAD — AutoCAD itself. A–Z application index.

09Lessons for engineers

  1. Put the rules in one place. A table of dimensions driving one program beats twenty hand-drawn variants.
  2. Separate sequence from code. Limits and step order belong in a sequence file engineers can review; instrument code belongs in tested modules.
  3. Fail safe. Every automated rig sequence needs a defined safe state on error, loss of communication or operator stop.
  4. Version and validate scripts. A script that sets test conditions is part of the test procedure; review and record it as such.

Sources & further reading

  1. Wikipedia — AutoLISP · ObjectARX
  2. SOLIDWORKS help (API section) · ezdxf documentation
  3. Wikipedia — SCPI · VISA · PyVISA
  4. Wikipedia — TestStand · MATLAB command-line options (-batch)
  5. PyAnsys · FreeCAD Python scripting