PyResultExplorer is a Python client library for Ansys Result Explorer, which is a tool to explore and visualize structural simulation results. With PyResultExplorer you can:
- Launch a new or connect to an existing Result Explorer session
- Automate and customize your Result Explorer post-processing workflows
To install PyResultExplorer:
python -m pip install ansys-result-explorer-coreInstalling PyResultExplorer in developer mode allows you to modify the source and enhance it.
Start by cloning this repository:
git clone https://github.com/ansys/pyresultexplorerCreate a fresh-clean Python environment and activate it:
# Create a virtual environment
uv venv
# Activate it in a POSIX system
source .venv/bin/activate
# Activate it in Windows
.venv\Scripts\activateInstall with latest required build system, doc, and testing dependencies:
uv sync --all-groupsThe style checks take advantage of pre-commit. You can install it with pre-commit install.
The following code snippet shows how to launch a new Result Explorer instance, create a solution and load a displacement view.
import os
from ansys.result_explorer.core import launch_result_explorer
# Launch a new Result Explorer session
rx = launch_result_explorer()
# Create a solution from an APDL RST file
sol = rx.create_solution(
name="PyRX Solution",
file_path=os.path.join("tests", "data", "multiple_connections.rst"),
)
# Create a new workspace and load a displacement view
workspace = rx.create_workspace(name="PyRX Workspace")
views = sol.views
print("Views in solution:")
for v in views:
print(f" - {v}")
view = next((v for v in views if "Displacement" in v.name), None)
viewport = workspace.assign_view(view=view, wait=True)
# Take a screenshot of the view and save to disk
snapshot_data = viewport.take_snapshot()
print("Saving snapshot to file...")
with open(view.name + ".png", "wb") as image_file:
image_file.write(snapshot_data)This project is licensed under the Apache 2.0 license agreement. See the LICENSE file for details.
For general PyAnsys questions, email pyansys-core@synopsys.com.