Project tree#

The following example demonstrates how to print the heirarchial Mechanical project structure.

Import the necessary libraries#

from ansys.mechanical.core import App
from ansys.mechanical.core.examples import delete_downloads, download_file

Initialize the embedded application#

app = App(globals=globals())
print(app)
Ansys Mechanical [Ansys Mechanical Enterprise]
Product Version:251
Software build date: 11/27/2024 09:34:44

Download the mechdb file#

mechdb_path = download_file("graphics_test.mechdb", "pymechanical", "test_files")

Load the mechdb file inside Mechanical

app.open(mechdb_path)

Display the project tree#

app.print_tree()
├── Project
|  ├── Model
|  |  ├── Geometry Imports (✓)
|  |  |  ├── Geometry Import (✓)
|  |  ├── Geometry (✓)
|  |  |  ├── Part 1
|  |  |  |  ├── Part 1
|  |  ├── Materials (✓)
|  |  |  ├── Structural Steel (✓)
|  |  ├── Coordinate Systems (✓)
|  |  |  ├── Global Coordinate System (✓)
|  |  ├── Remote Points (✓)
|  |  ├── Mesh (✓)
|  |  ├── Static Structural (✓)
|  |  |  ├── Analysis Settings (✓)
|  |  |  ├── Fixed Support (✓)
|  |  |  ├── Force (✓)
|  |  |  ├── Solution (✓)
|  |  |  |  ├── Solution Information (✓)
|  |  |  |  ├── Directional Deformation (✓)

Display the tree only under the first analysis#

first_analysis = app.Model.Analyses[0]
app.print_tree(first_analysis)
├── Static Structural (✓)
|  ├── Analysis Settings (✓)
|  ├── Fixed Support (✓)
|  ├── Force (✓)
|  ├── Solution (✓)
|  |  ├── Solution Information (✓)
|  |  ├── Directional Deformation (✓)

Clean up the downloaded files and app#

# Delete the downloaded files
delete_downloads()

# Close the app
app.close()

Total running time of the script: (0 minutes 2.592 seconds)

Gallery generated by Sphinx-Gallery