Skip to content

How to get the app.print_tree() into logger.....? #1059

Closed Answered by B-Naveen-Kumar
B-Naveen-Kumar asked this question in Q&A
Discussion options

You must be logged in to vote

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()

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
2 replies
@dipinknair
Comment options

@B-Naveen-Kumar
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by B-Naveen-Kumar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants