Skip to content

Get text output of a TUI command #1407

Answered by mkundu1
francisco-jimmy asked this question in Q&A
Discussion options

You must be logged in to vote

Following is tested on the main branch:

import ansys.fluent.core as pyfluent
from contextlib import contextmanager
import io

@contextmanager
def capture_transcript(solver):
    stream = io.StringIO()
    callback_id = solver.transcript.register_callback(stream.write, keep_new_lines=True)
    yield stream
    solver.transcript.unregister_callback(callback_id)

solver = pyfluent.launch_fluent()
solver.file.read_case(file_name="elbow.cas.h5")
with capture_transcript(solver) as stream:
    solver.tui.define.boundary_conditions.modify_zones.list_zones()
transcript = stream.getvalue()
print(transcript)

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

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

@etiennelame
Comment options

Answer selected by francisco-jimmy
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants