From 978b88976a28fd06c04486586c730757a6861404 Mon Sep 17 00:00:00 2001 From: dkunhamb Date: Thu, 15 Aug 2024 09:35:50 -0500 Subject: [PATCH] update examples --- doc/source/conf.py | 25 -------------- examples/00_tips/tips_01.py | 2 +- examples/00_tips/tips_02.py | 2 ++ examples/00_tips/tips_03.py | 6 ++-- examples/00_tips/tips_04.py | 66 ------------------------------------- 5 files changed, 6 insertions(+), 95 deletions(-) delete mode 100644 examples/00_tips/tips_04.py diff --git a/doc/source/conf.py b/doc/source/conf.py index 574224ae..664274ce 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -146,28 +146,3 @@ # Read link all targets from file with open("links.rst") as f: rst_epilog += f.read() - - -def _add_mech_libraries_for_examples(): - import os - import sys - - awp_root = None - for key, value in os.environ.items(): - if key.startswith("AWP_ROOT"): - awp_root = value - print(awp_root) - break - - if awp_root: - location = os.path.join(awp_root, "Addins", "ACT", "libraries", "Mechanical") - if os.path.isdir(location): - sys.path.append(location) - print(f"Added to sys.path: {location}") - else: - print(f"Directory does not exist: {location}") - else: - print("No AWP_ROOT environment variable found.") - - -_add_mech_libraries_for_examples() diff --git a/examples/00_tips/tips_01.py b/examples/00_tips/tips_01.py index d9124c41..2d2587d7 100644 --- a/examples/00_tips/tips_01.py +++ b/examples/00_tips/tips_01.py @@ -43,7 +43,7 @@ # %% # .. note:: -# This visualization is currently available only for geometry. +# This visualization is currently available only for geometry and on version 24R2 or later # %% # Cleanup diff --git a/examples/00_tips/tips_02.py b/examples/00_tips/tips_02.py index 9ed7ed0a..13563962 100644 --- a/examples/00_tips/tips_02.py +++ b/examples/00_tips/tips_02.py @@ -88,6 +88,8 @@ def display_image(image_name): Graphics.ExportImage( os.path.join(cwd, "geometry.png"), image_export_format, settings_720p ) + +# Display image using matplotlib display_image("geometry.png") # %% diff --git a/examples/00_tips/tips_03.py b/examples/00_tips/tips_03.py index b0e6bd10..af2433c8 100644 --- a/examples/00_tips/tips_03.py +++ b/examples/00_tips/tips_03.py @@ -1,9 +1,9 @@ """ .. _ref_tips_03: -Display project tree +Project tree -------------------- -Displays the heirarchial Mechanical project structure. +Display the heirarchial Mechanical project structure. """ # %% @@ -40,7 +40,7 @@ app.print_tree() # %% -# Display only tree under first analysis +# Display tree only under first analysis # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ app.print_tree(Model.Analyses[0]) diff --git a/examples/00_tips/tips_04.py b/examples/00_tips/tips_04.py deleted file mode 100644 index c81190ac..00000000 --- a/examples/00_tips/tips_04.py +++ /dev/null @@ -1,66 +0,0 @@ -""" .. _ref_tips_04: - -Use ``app_libraries`` ---------------------- - -Use app libraries which comes with Mechanical -""" - -# %% -# Import necessary libraries -# ~~~~~~~~~~~~~~~~~~~~~~~~~~ - - -import ansys.mechanical.core as mech -from ansys.mechanical.core.embedding import add_mechanical_python_libraries -from ansys.mechanical.core.examples import delete_downloads, download_file - -# %% -# Embed mechanical and set global variables - -app = mech.App(version=242) -app.update_globals(globals()) -print(app) - -# %% -# Download geometry and import -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# Download geometry - -geometry_path = download_file("Valve.pmdb", "pymechanical", "embedding") - -# %% -# Import geometry - -geometry_import = Model.GeometryImportGroup.AddGeometryImport() -geometry_import.Import(geometry_path) - -# %% -# Print sys path - -import sys - -print(sys.path) -# %% -# Update path to libraries which are found under -# "Addins", "ACT", "libraries", "Mechanical" - -add_mechanical_python_libraries(app) - -# %% -# Import ``materials`` module and use necessary functions - -import materials - -body = DataModel.GeoData.Assemblies[0].Parts[0].Bodies[0] -mat = body.Material - -print(materials.GetListMaterialProperties(mat)) - - -# %% -# Cleanup -# ~~~~~~~ - -delete_downloads() -app.new()