Skip to content

feat: add helper methods#1507

Open
dipinknair wants to merge 37 commits intomainfrom
feat/utilities
Open

feat: add helper methods#1507
dipinknair wants to merge 37 commits intomainfrom
feat/utilities

Conversation

@dipinknair
Copy link
Copy Markdown
Collaborator

@dipinknair dipinknair commented Feb 4, 2026

This PR introduces a Helpers class accessible via app.helpers, providing a convenient API for common Mechanical embedding workflows — geometry and material import, image/animation export, and image display.

Usage example

from ansys.mechanical.core import App
from pathlib import Path

app = App(globals=globals(), log_level="DEBUG")
print(app)

output_dir = Path(app.DataModel.Project.ProjectDirectory)

# Import geometry and materials
app.helpers.import_geometry("path/to/model.pmdb")
app.helpers.import_materials("path/to/materials.xml")

# Export an image of the geometry
app.helpers.export_image(
    obj=app.Model.Geometry,
    file_path=str(output_dir / "geometry.png"),
)

# Export with a different camera view
app.helpers.export_image(
    obj=app.Model.Geometry,
    file_path=str(output_dir / "geometry_front.png"),
)

# Display the exported image inline
app.helpers.display_image(image_path=str(output_dir / "geometry_front.png"))

# Export an animation of a result
app.helpers.export_animation(
    obj=total_deformation,
    file_path=str(output_dir / "deformation.gif"),
)

app.close()

New methods on app.helpers

Method Description
import_geometry(file_path, ...) Import a geometry file (.pmdb, .agdb, etc.) with configurable named selections, materials, and coordinate systems
import_materials(file_path) Import a material database (.xml) into the model
export_image(obj, file_path, ...) Export a PNG/JPG of any Mechanical tree object at configurable resolution and background
export_animation(obj, file_path, ...) Export a GIF/MP4 animation of a result object
display_image(image_path, ...) Display an exported image inline via matplotlib

Closes #1487

@github-actions github-actions bot added the enhancement New features or code improvements label Feb 4, 2026
@github-actions github-actions bot added the documentation Improvements or additions to documentation label Feb 4, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Feb 4, 2026

The documentation for this pull request will be available at https://mechanical.docs.pyansys.com/pull/1507. Please allow some time for the documentation to be deployed.

@dipinknair dipinknair marked this pull request as ready for review February 4, 2026 14:58
@dipinknair dipinknair requested a review from a team as a code owner February 4, 2026 14:58
@dipinknair dipinknair requested a review from rs-bh-n February 4, 2026 14:58
@codecov
Copy link
Copy Markdown

codecov bot commented Feb 4, 2026

Codecov Report

❌ Patch coverage is 92.35294% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.78%. Comparing base (4275f11) to head (f07df5d).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1507      +/-   ##
==========================================
+ Coverage   81.18%   81.78%   +0.60%     
==========================================
  Files          42       43       +1     
  Lines        3109     3267     +158     
==========================================
+ Hits         2524     2672     +148     
- Misses        585      595      +10     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Member

@RobPasMue RobPasMue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty cool! Thanks @dipinknair !

@github-actions github-actions bot added the dependencies Related with project dependencies label Feb 8, 2026
@dipinknair dipinknair requested a review from koubaa March 2, 2026 17:04
@dipinknair dipinknair requested a review from koubaa March 2, 2026 20:47
@codacy-production
Copy link
Copy Markdown

codacy-production bot commented Apr 6, 2026

Not up to standards ⛔

🔴 Issues 14 minor

Alerts:
⚠ 14 issues (≤ 0 issues of at least minor severity)

Results:
14 new issues

Category Results
Documentation 14 minor

View in Codacy

🟢 Metrics 38 complexity

Metric Results
Complexity 38

View in Codacy

TIP This summary will be updated as you push new changes. Give us feedback

@github-actions github-actions bot added maintenance Package and maintenance related ci/cd Involves the GitHub workflow files labels Apr 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci/cd Involves the GitHub workflow files dependencies Related with project dependencies documentation Improvements or additions to documentation enhancement New features or code improvements maintenance Package and maintenance related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add utilities module for expanded API coverage

4 participants