mechanical-sim
This file is the Ansys Mechanical index. Use DPF for solved .rst files
on disk; use sim-cli/PyMechanical for live Mechanical sessions that mutate,
solve, inspect, or update the GUI-backed project.
This is not the Abaqus plugin. Do not run Abaqus .inp decks or
Abaqus/CAE scripts here. Use solver=abaqus for Dassault SIMULIA Abaqus;
use solver=mechanical only for Ansys Mechanical / PyMechanical sessions.
The /connect response tells you which active layers apply:
json"skills": { "root": "<sim-skills>/mechanical", "active_sdk_layer": "0.12", "active_solver_layer": "24.1" }
Always read base/, then your active sdk/<version>/, then your active
solver/<version>/. Later layers override earlier ones on identically-named
files.
First principles
-
Workbench orchestrates, Mechanical computes. PyWorkbench drives Engineering Data / Geometry / Model. PyMechanical drives Setup / Solution / Results. Do not try to define boundary conditions via Workbench scripting — that belongs here.
-
Observation is SDK+GUI coupled. Every
uv run sim execis amechanical.run_python_script(code)call that mutates Mechanical's in-memory model. Mechanical's window on the desktop redraws after each call. Thereforeuv run sim screenshot(which grabs the desktop) always reflects the current SDK state. This coupling only works withbatch=False— so the driver defaults to GUI mode. Confirm bothui_mode == "gui"andbatch == falsefrominspect session.summarybefore relying on screenshots for GUI sync. -
Scripts run inside Mechanical's IronPython interpreter. Globals
ExtAPI,DataModel,Model,Quantity,Treeare already available — do NOTimport ansys.mechanical. The last expression's string form is whatrun_python_scriptreturns, so end snippets with ajson.dumps(...)literal to get structured output. -
ExtAPI.DataModel.Projectis the root. From there:.Model→ the scene;.Model.Analyses[0]→ the first analysis;.Model.Geometry→ bodies;.Model.Mesh→ meshing controls;.Model.Materials→ material assignments.
base/ — always relevant
| Path | What's there |
|---|---|
base/reference/pymechanical_api.md | PyMechanical SDK surface: launch_mechanical, run_python_script, download_project, file transfer. Read first. |
base/reference/scripting_tree.md | Mechanical's IronPython scripting tree: ExtAPI, DataModel, Model, Tree, common traversal patterns. |
base/reference/capability_discovery.md | Generic method/feature discovery before adding analyses, BCs, results, or solve logic. Use this when the workflow differs from known snippets. |
base/reference/bc_scoping.md | Boundary condition scoping: creating Selection objects, NamedSelection, face IDs, ISelectionInfo. This is the #1 source of errors. |
base/reference/solve_control.md | Triggering solve (analysis.Solution.Solve(True)), monitoring state, reading solve messages. |
base/reference/result_extraction.md | Traversing analysis.Solution to pull deformation/stress values, exporting to CSV, using .rst files. |
base/reference/observation_commands.md | How sim's observation commands couple with Mechanical. Read this before using uv run sim inspect / uv run sim screenshot against a Mechanical session. |
base/snippets/ | Numbered snippets (01_smoke through 06_extract_results). Each ends with a json.dumps(...) literal for structured output. |
base/workflows/static_structural/ | End-to-end walk through cells 4-6, continuing where workbench-sim left off. |
base/workflows/model_review_loop.md | Required checkpoint loop: inspect health, project identity, model summary, then run one bounded snippet. |
base/workflows/debug_failed_exec.md | Failure triage loop for scoping, selections, mesh, solve, and result extraction failures. |
base/workflows/workbench_handoff.md | Workbench-to-Mechanical checklist for Static Structural workflows. |
base/known_issues.md | Quirks: Chinese locale gRPC, batch-mode stdin, IronPython Unicode, Selection vs ISelectionInfo. |
sdk/<active_sdk_layer>/
sdk/0.12/— PyMechanical 0.12 (works with Ansys 24.1–25.2).notes.md—launch_mechanical(version=241, batch=False),wait_till_mechanical_is_ready.
solver/<active_solver_layer>/
solver/24.1/— Ansys Mechanical 24.1.notes.md— scripting namespace: whichExtAPImembers exist in 24.1.
Hard constraints
- Never launch with
batch=Trueunless the user has explicitly asked for headless mode. sim's observation commands need the GUI. - Never
import ansys.mechanical.*inside a snippet that goes throughrun_python_script. The interpreter is Mechanical's embedded IronPython — the Python SDK is the wrong side of the wire. - Always end snippets with
json.dumps(...)to get structured stdout.run_python_scriptreturns only the last expression's repr. - Workbench skill owns cells 1-3. If the user asks for geometry import or material definition, hand back to workbench-sim.
- Never trust raw names or paths as public evidence. Return counts, booleans, self-created ASCII tags, or sanitized strings from snippets.
- Discover live capabilities before coding a new workflow. Use
mechanical.capabilities,mechanical.object.properties:*, and official PyMechanical scripting docs to confirm available analysis, BC, result, and solve APIs. Do not infer physics support fromAnalysisTypestrings alone. - Observe long-running work out-of-band. During solves, updates, imports,
or hangs, use screenshots and file/message polling while the SDK call is
blocked. Read
base/reference/observation_commands.mdbefore starting any expected long-running operation.
Required protocol
If the user's question is about an existing solved project (a .rst on
disk), use DPF on the agent side; do not launch Mechanical at all.
Before every Mechanical script:
- Read
base/workflows/model_review_loop.mdand inspectsession.health,mechanical.project.identity, andmechanical.model.summary. - For any workflow not already proven by a local snippet, read
base/reference/capability_discovery.mdand inspectmechanical.capabilitiesbefore adding setup objects. - Check
base/known_issues.mdfor the operation you are about to do. - If this is a Workbench handoff, read
base/workflows/workbench_handoff.mdand confirm Mechanical sees the expected analysis and non-empty geometry. - For long-running solve/update/import steps, capture a screenshot before the call, then monitor with screenshots and available solver files/messages until it completes or clearly fails.
- Run one bounded snippet, ending with
json.dumps(...). - Inspect
last.result,mechanical.model.summary, andmechanical.messagesafter solve/result failures. In GUI mode, use a screenshot as visual confirmation after significant tree changes. - If execution fails, switch to
base/workflows/debug_failed_exec.mdbefore trying another full script.


