Native Macros & Automation

Your CAD system's own macros and journals, the Automation Hub that turns them into named commands, scheduled tasks, and the odd jobs around a CAD job — spreadsheets, dialogs and scripts. For SphereHarness's own recorded macros, see Macros.

Which one do I want?

Native CAD macros and journals

SphereHarness can drive your CAD system's own recorder, and can run scripts that already exist.

Recording in the CAD system's own format

Start recording a native macro, and stop it when I say — save it to C:\macros\hole_pattern.swp

Support differs by CAD system:

CAD systemNative recordingFormat
SOLIDWORKSYesVBA macro (.swp, .swb)
Siemens NXYesJournal (.cs, .vb)
Solid EdgeYesMacro (.bas)
Autodesk InventorNo — Inventor has no equivalent recorder exposed to SphereHarnessUse iLogic rules (.iLogicVb) instead
AutoCADNo - AutoCAD has no recorder exposed to SphereHarnessRun AutoCAD's own SCRIPT or a LISP routine as a command, run a compiled .NET assembly through the Automation Hub, or use a SphereHarness macro

Running an existing script

Run the VBA macro at C:\macros\export_step.swp on the active part
Write an iLogic rule that drives the plate thickness from the "Thickness" parameter, then run it
NX journals play inside the NX session you are sitting in, on the work part, so a recorded journal works on what you have open and you can undo it normally. A journal that needs a work part when nothing is open is refused before it plays rather than failing halfway, and one that fails reports its own exception and its own line number. A self-contained journal that opens and saves its own files can still be run in a separate session if you ask for that explicitly. See the Automation Hub.

The Automation Hub

The Automation Hub is a catalogue of scripts with declared parameters. Import a script once, and afterwards anyone can run it by name with values filled in, without touching the code. The short version is below; the Automation Hub page has the whole of it, including .NET assemblies, what each CAD system does differently, and a worked example on a folder of somebody else's scripts.

Importing

Accepted files: .cs and .vb (NX journals, and the plain .vb files most Inventor iLogic rules are saved as), .swp and .swb (SOLIDWORKS macros), .iLogicVb (Inventor), .bas (Solid Edge) and .dll (.NET assemblies, on any of the five CAD systems). Importing never runs anything.

Import C:\macros\rename_features.swp into the Automation Hub

Browsing and running

What automations are available for SOLIDWORKS?
Show me the parameters of the "Rename features" automation
Run the "Rename features" automation with prefix set to BR- on the active part

Asking for the parameters first is worth the extra prompt: it tells you the types, defaults and allowed values before anything runs.

Running one automation over many inputs

Run the "Export STEP" automation once for every .sldprt in C:\parts, writing the output to C:\step

Improving an automation

SphereHarness can read the code of a stored automation and either critique it or change it.

Analyse the "Rename features" automation and suggest improvements
Edit the "Export STEP" automation to add error handling and log each file it processes
An AI edit to a working script is a draft. Read the diff, and run it on a copy of a real file before it touches production data.

Scheduled tasks

Any chat request, automation or script can be put on a schedule — one-time, daily, weekly or monthly.

Every weekday at 6 am, export the BOM of C:\projects\frame.sldasm to C:\reports\frame_bom.xlsx
Tomorrow at 18:30, run a DFM report on the active part and save it to C:\reports
List my scheduled tasks
Show me the run history of the nightly BOM export
Cancel the nightly BOM export
Scheduled work runs on the workstation, through the CAD system. The machine must be on, and the CAD application reachable, at the scheduled time.

Driving a CAD command's dialog

Some jobs are only reachable through a dialog. SphereHarness can find a command, open it, read what is on screen, fill the fields in and confirm — the same actions you would perform with the mouse.

What CAD commands are available for sheet metal?
Search the commands for anything to do with "pattern"
Open the Fillet command dialog
Read the open dialog and tell me what fields it has and their current values
Set the radius field to 5 and click OK
Cancel the open dialog
Opening a command only opens the UI — it does not create geometry. Reach for this when there is no direct operation for what you need; for ordinary modelling, the direct operations in Part Modeling are faster and more reliable. If a dialog is waiting for input, the chat cannot continue until it is answered, so either let SphereHarness confirm it or click it yourself.

A full-screen capture including all dialogs and panels is available when you want to show SphereHarness — or a colleague — the exact state of the screen.

Take a full-screen screenshot including the ribbon and any open dialogs

Spreadsheets and data

Much repetitive CAD work is really data work: a list of sizes in, a table of results out. SphereHarness reads and writes Excel workbooks and CSV files directly.

Read C:\input\sizes.xlsx and tell me what columns it has
Create one plate part per row of C:\input\sizes.xlsx, named from the Part Number column, and save them in C:\parts
Write the mass and bounding box of every part in C:\parts to a new sheet in C:\reports\summary.xlsx
Build a workbook from our quotation template with the BOM of this assembly filled in

Workbooks can also be exported to CSV or HTML, worksheets added, and cells formatted. For sending the result on to another system — ERP, email, a REST endpoint — see Connections.

Scripting, when nothing else fits

SphereHarness can also run Python, PowerShell and shell commands on the workstation — useful for the file-handling around a CAD job (renaming an export batch, tidying a folder, reading a CSV of dimensions before it drives a model).

Read C:\input\sizes.csv and create one plate part per row, named from the Part Number column
These tools run with your Windows account's permissions. Treat a request that writes or deletes files the way you would treat running the same command yourself — read what it proposes before you agree to it.

See also