How to get the app.print_tree() into logger.....? #1059
-
Hi team, Im trying to get the app.print_tree() tree data into the logger. Below is the script for you reference: `import os os.environ['PYTHONIOENCODING'] = 'utf8' from ansys.mechanical.core import App logger = logging.getLogger() logger.setLevel(logging.DEBUG) stream_handler = logging.StreamHandler(sys.stdout) stream_handler.setLevel(logging.DEBUG) logger.addHandler(stream_handler) from ansys.mechanical.core import App app = App() app =App(version=242) ansys_tree = app.print_tree() logger.debug(f"Ansys Tree Structure:\n{ansys_tree }") But Im unable to get the tree. I need your assistance here..!! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
@dipinknair or @koubaa any suggesting please.? |
Beta Was this translation helpful? Give feedback.
-
Here how it works: from ansys.mechanical.core import App
ansys_app = App(version=242)
ansys_app.update_globals(globals())
ansys_tree = ansys_app.print_tree()
tempfile = 'simulation_logs.txt'
original_stdout = sys.stdout
with open(tempfile, 'a', encoding="utf-8") as file:
sys.stdout = file
ansys_trees = ansys_app.print_tree()
sys.stdout = original_stdout
with open(tempfile, encoding="utf-8") as file:
ansys_trees = file.read() |
Beta Was this translation helpful? Give feedback.
Here how it works: