Notifications
Clear all

Printing to Console in Flownex

4 Posts
2 Users
1 Reactions
667 Views
Posts: 19
Moderator
Topic starter
(@chris-settanni)
Member
Joined: 2 years ago

Console printouts are an easy and accessible way to add transparency to specific properties during a simulation. Printing to the console allows you to quickly track convergence across multiple steady state iterations while using a designer.

 

Read the full blog post here.

3 Replies
Posts: 2
(@aendres)
Member
Joined: 1 year ago

Thanks for the interesting post! In my case, I want to output to the console not only during the simulation, but also when executing something under ' HandleObjectEvent'. In this case, the IPS.Task.ConsoleSolverOutputProvider.GetConsoleOutputWindow().AddTextLine("text") function does not seem to print anything to the console (for debugging and informing the user about what is happening in the script). Do you know how I can access the console when not executing the solver? Thanks in advance for your help!

Reply
2 Replies
Moderator
(@chris-settanni)
Joined: 2 years ago

Member
Posts: 19

@aendres,

Thanks for your post!

You will need to refresh the console after printing to console when the solver is inactive. Below is an example of an override for the  HandleObjectEvent() method to print to console with an event (push button):

    public override void HandleObjectEvent(object sender)
    {
        // Clear console - This line may optionally be used to clear the Console prior to printing
        IPS.Task.ConsoleSolverOutputProvider.GetConsoleOutputWindow().Clear();
        // Write to console - This will write a lien to the console
        IPS.Task.ConsoleSolverOutputProvider.GetConsoleOutputWindow().AddTextLine("Console output here...");
        // Refresh console - You will need this to view lines printed to the console
        IPS.Task.ConsoleSolverOutputProvider.GetConsoleOutputWindow().RefreshTextbox();
    }

You can also use a quick script to expose values through instance variables (see attached image) - in addition to third party debugging.

These are variables relatively easy to setup, read, and the constructors may be copy/pasted to a script component.

 

Reply
(@aendres)
Joined: 1 year ago

Member
Posts: 2

@chris-settanni,

this solution works, thank you very much!

So far, I have used the Windows message box with "System.Windows.Forms.MessageBox.Show("Output");", which can be dangerous if there are too many outputs e.g. in a loop.

Reply
Share:

Search the PADT Site

Contact Us

Please fill out the form with as much information as possible, and someone will get back to your shortly.

Or reach out directly: 

No Fields Found.