Best practices#
Session management#
Reuse the same Mechanical connection across a workflow whenever possible. Repeated launch/connect cycles increase runtime and can create confusion in stateful workflows.
Call
check_mechanical_statusbefore starting each major step.Use
connect_to_mechanicalif a compatible instance already exists.Use
disconnect_from_mechanicalfor clean shutdowns.
Scripting strategy#
Use short, focused script calls rather than very large monolithic scripts. This improves observability and error recovery.
Use
run_python_scriptfor Mechanical API-heavy commands.Use
run_python_codefor lightweight Python processing and orchestration.Pass
file_pathtorun_python_scriptwhen a script lives on disk.
For long setup scripts:
Validate geometry import and named selections early.
Save checkpoints with
save_projectafter expensive setup steps.Keep scripts idempotent where possible to support reruns.
Model setup quality#
Set units explicitly before defining loads and material parameters.
Verify named selection scopes before applying boundary conditions.
Check mesh quality and element sizing before solving.
Confirm material assignment for every relevant body.
Solver and results#
Solve only after confirming analysis settings and boundary condition completeness.
Use
get_model_infoafter setup and after solve to validate state.Export only needed result objects to reduce file churn.
Capture screenshots at key milestones for traceability.
File transfer hygiene#
Use
upload_filefor all client-side artifacts (geometry and scripts).Keep working directory contents organized (prefix or suffix by workflow).
Retrieve only required artifacts with
download_file.
AI workflow guidance#
Call get_guidelines_for at workflow boundaries (geometry, meshing,
analysis setup, and postprocessing). This reduces avoidable script mistakes and
keeps generated commands aligned with Mechanical best practices.
Next steps#
See Tools and capabilities for a complete list of available tools.
Browse Review engineering workflow examples for end-to-end workflow examples.
See Configuration for startup and transport options.