Skip to main content

Ansys Mechanical (PyMechanical) driver for sim-cli, distributed as an out-of-tree plugin

Project description

sim-plugin-mechanical

Use Codex, Claude Code, or another AI agent to work with Ansys Mechanical models through sim-cli.

sim-plugin-mechanical gives an agent practical Mechanical control paths: drive a live Mechanical GUI through PyMechanical, inspect runtime health, add loads/supports/solution objects, solve, summarize the model tree, and extract or describe result artifacts.

The Mechanical application and SDK are not bundled. Bring your own Mechanical installation. See LICENSE-NOTICE.md.

This plugin is for Ansys Mechanical, not Dassault SIMULIA Abaqus. Use the Abaqus plugin for Abaqus decks and Abaqus/CAE scripts.

What an agent can do with Mechanical

  • Mutate a live Mechanical model through Mechanical's IronPython API.
  • Keep GUI-visible work synchronized with SDK state in gui mode.
  • Inspect session.health, mechanical.project.identity, and mechanical.model.summary before each bounded setup or solve step.
  • Add and inspect supports, loads, mesh state, solution objects, and result objects.
  • Detect solver/result artifacts such as result files, solver output, error files, and exported CSV data.
  • Continue a Workbench Static Structural handoff once the Model cell is ready.

Choose the right Mechanical workflow

1. Live GUI session

Use this when the user wants to watch or review the Mechanical tree while the agent works:

sim connect --solver mechanical --ui-mode gui
sim inspect session.health
sim exec --file setup_step.py
sim inspect mechanical.model.summary

In GUI mode, Mechanical's visible window and PyMechanical client mutate the same in-memory model. Use screenshots for visual review, but use structured inspect targets for acceptance decisions.

2. Headless smoke or batch-style checks

Use --ui-mode no_gui only when visual confirmation is not needed:

sim connect --solver mechanical --ui-mode no_gui

Headless mode is faster but screenshot confirmation is unavailable. Inspect session.health.ui_capabilities before relying on GUI observations.

3. Workbench handoff

Workbench owns Engineering Data, Geometry, and Model. Mechanical owns setup, solve, and results. Before applying Mechanical loads or supports, inspect:

sim inspect mechanical.project.identity
sim inspect mechanical.model.summary

Continue only when the expected analysis exists and the geometry/body state is non-empty.

Prerequisites

Install these before asking an agent to use this plugin:

  • Python 3.10 or newer.
  • uv for Python environment and package installs.
  • git when installing from GitHub source refs.
  • sim-cli or a project environment where sim-cli can be installed.
  • A local Ansys Mechanical installation compatible with PyMechanical.

The plugin does not include Mechanical or vendor SDK binaries. It installs the Python adapter and its Python dependencies only.

Install

For most users and agents, install the latest published PyPI version:

uv pip install sim-plugin-mechanical

PyPI releases are intentionally infrequent. For quick testing of the current source branch, install from GitHub:

uv pip install "git+https://github.com/svd-ai-lab/sim-plugin-mechanical.git@main"

For a reproducible agent run, pin a commit SHA:

uv pip install "git+https://github.com/svd-ai-lab/sim-plugin-mechanical.git@<commit-sha>"

If your environment uses SSH authentication:

uv pip install "git+ssh://git@github.com/svd-ai-lab/sim-plugin-mechanical.git@<commit-sha>"

Verify Install

After installation, sim-cli should auto-discover the driver and bundled skill:

sim check mechanical

If sim check mechanical reports that Mechanical itself is unavailable, first confirm the Python package installed correctly, then fix the local Mechanical or SDK prerequisites.

Connect And Inspect Health

Use GUI mode for agent-visible Mechanical workflows:

sim connect --solver mechanical --ui-mode gui
sim inspect session.health
sim inspect mechanical.project.identity
sim inspect mechanical.model.summary

Use headless mode only for non-visual smoke checks:

sim connect --solver mechanical --ui-mode no_gui

Common Agent Workflow

  1. Connect in GUI mode unless the user explicitly wants headless mode.
  2. Inspect session.health, mechanical.project.identity, and mechanical.model.summary.
  3. Run one bounded IronPython snippet.
  4. Inspect last.result and mechanical.model.summary.
  5. Continue only when the model state matches the expected analysis, geometry, mesh, and result state.
  6. Treat mechanical.solve.not_completed as a failed solve, even if the SDK transport returned successfully.

Workbench-To-Mechanical Handoff

Workbench owns Engineering Data, Geometry, and Model cells. Mechanical owns setup, solve, and results. Before applying loads or supports:

sim inspect mechanical.project.identity
sim inspect mechanical.model.summary

Continue only when the expected analysis exists and geometry/body state is non-empty.

Update Or Uninstall

Update to the latest published PyPI version:

uv pip install --upgrade sim-plugin-mechanical

Update from the latest GitHub main branch:

uv pip install --upgrade "git+https://github.com/svd-ai-lab/sim-plugin-mechanical.git@main"

Uninstall:

uv pip uninstall sim-plugin-mechanical

Agent quickstart

Give an agent this instruction when the task is about Mechanical:

Use the bundled Mechanical skill from sim-plugin-mechanical. Connect with
`sim connect --solver mechanical --ui-mode gui` unless the user explicitly
wants headless mode. Before every setup, solve, or result step, inspect
`session.health`, `mechanical.project.identity`, and
`mechanical.model.summary`. Run one bounded IronPython snippet at a time,
return JSON from the last expression, inspect `last.result`, and use screenshots
only as visual confirmation. If the model came from Workbench, confirm the
handoff before applying loads or supports.

The bundled skill entry point is:

src/sim_plugin_mechanical/_skills/mechanical/SKILL.md

How it relates to sim-cli

sim-plugin-mechanical extends sim-cli with the Mechanical-specific driver and bundled Mechanical skill. sim-cli supplies the common runtime surface (connect, exec, inspect, run, screenshot), while this plugin supplies Mechanical detection, PyMechanical launch, IronPython execution, health checks, model summaries, and result artifact diagnostics.

The plugin registers three entry-point groups:

[project.entry-points."sim.drivers"]
mechanical = "sim_plugin_mechanical:MechanicalDriver"

[project.entry-points."sim.skills"]
mechanical = "sim_plugin_mechanical:skills_dir"

[project.entry-points."sim.plugins"]
mechanical = "sim_plugin_mechanical:plugin_info"

Troubleshooting

Secure transport launch failures

Some solver builds require insecure loopback transport for PyMechanical. Set SIM_MECHANICAL_INSECURE_TRANSPORT=1 before starting the sim session if the driver reports a secure-transport launch failure.

Screenshot captures no Mechanical window

Use sim inspect session.health. If ui_capabilities.screenshot_expected is false, the session is headless. If screenshot support is expected but no matching window is found, reconnect in GUI mode and inspect the health payload before mutating more state.

Develop

git clone https://github.com/svd-ai-lab/sim-plugin-mechanical
cd sim-plugin-mechanical
uv sync
uv run pytest tests -m "not integration"

End-to-end tests require a local Mechanical installation and are skipped unless their prerequisites are available.

License

Apache-2.0. See LICENSE and LICENSE-NOTICE.md.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sim_plugin_mechanical-0.1.6.tar.gz (16.4 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sim_plugin_mechanical-0.1.6-py3-none-any.whl (16.3 MB view details)

Uploaded Python 3

File details

Details for the file sim_plugin_mechanical-0.1.6.tar.gz.

File metadata

  • Download URL: sim_plugin_mechanical-0.1.6.tar.gz
  • Upload date:
  • Size: 16.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.9 {"installer":{"name":"uv","version":"0.11.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for sim_plugin_mechanical-0.1.6.tar.gz
Algorithm Hash digest
SHA256 bcff11e0722602f218e30be0e0c7d66fa14bb60eb2eca842e2afba6587f43620
MD5 125ab663d24b758416150bcb2113d57b
BLAKE2b-256 85b84226c2f4ed2e35add1896360d02c7fb222a9877b67cd00c1806ab1e3d8cb

See more details on using hashes here.

File details

Details for the file sim_plugin_mechanical-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: sim_plugin_mechanical-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 16.3 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.9 {"installer":{"name":"uv","version":"0.11.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for sim_plugin_mechanical-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 e1af498474d3e7d7368727a7f3ef988873d0c5ac10669210b27371ec70f6d0bb
MD5 0f0f1eb7bb45f303705deceb8df3d9a6
BLAKE2b-256 0ae0929fb1e7088ec787052cfbffc5297b8595a1c01bcdd200cf637dacfe9924

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page