From 9a4c43b06b086d0dd6cbb231a062bd119bfc0323 Mon Sep 17 00:00:00 2001 From: rs-bh-n Date: Tue, 27 Feb 2024 12:12:08 +0530 Subject: [PATCH] added add_mechanical_python_libraries and Enum arg --- .../pymechanical_script.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/cheat_sheets/pymechanical_cheat_sheet/pymechanical_script.py b/cheat_sheets/pymechanical_cheat_sheet/pymechanical_script.py index 46f78da..fecb108 100644 --- a/cheat_sheets/pymechanical_cheat_sheet/pymechanical_script.py +++ b/cheat_sheets/pymechanical_cheat_sheet/pymechanical_script.py @@ -69,7 +69,6 @@ # BREAK BLOCK from ansys.mechanical.core import App - app = App(version=241) print(app) # BREAK BLOCK @@ -77,7 +76,11 @@ # Extract the global API entry points (available from built-in Mechanical scripting) from ansys.mechanical.core import global_variables # Merge them into your Python global variables -globals().update(global_variables(app)) +# Optional argument for Enums without namespaces +globals().update(global_variables(app),True) +# Import python modules shipped with Mechanical +from ansys.mechanical.core.embedding import add_mechanical_python_libraries +add_mechanical_python_libraries(241) # BREAK BLOCK ExtAPI # Application.ExtAPI DataModel # Application.DataModel @@ -89,16 +92,13 @@ file = r"D:\\Workdir\\bracket.mechdb" app.open(file) allbodies = DataModel.Project.Model.GetChildren( - Ansys.Mechanical.DataModel.Enums.DataModelObjectCategory.Body, - True) + DataModelObjectCategory.Body,True) print(allbodies.Count) # BREAK BLOCK import logging from ansys.mechanical.core import App from ansys.mechanical.core.embedding.logger import ( - Configuration, - Logger) - + Configuration,Logger) Configuration.configure(level=logging.WARNING, to_stdout=True) app = App(version=241) Logger.error("message") \ No newline at end of file