Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

about integrate mayo TO WPF #232

Open
DDman1984 opened this issue Oct 20, 2023 · 2 comments
Open

about integrate mayo TO WPF #232

DDman1984 opened this issue Oct 20, 2023 · 2 comments

Comments

@DDman1984
Copy link

DDman1984 commented Oct 20, 2023

Hi,
I plan to integrate mayo.exe into my WPF application. I've been trying to capture the progress of file conversion through the process (just like the text you showed in the example this), but the results have been frustrating...
How can I achieve the above requirement?

please give me any advice thank you very much:)

@HuguesDelorme
Copy link
Member

Hello @DDman1984
mayo.exe "refreshes" the whole contents of the progress text each time there's some update(eg task ended or progress change)
So if you connect to the standard ouput channel of mayo.exe this is what you should get with this pseudo-code:

while (mayoProcess.hasOutput) {
    string msg = mayoProcess.readAll();
    print(msg);
}

For example running mayo.exe D:\dev\data\cax-if.org\as1-oc-214.stp --export D:\dev\data\cax-if.org\as1-oc-214.stp.stl would produce these successive messages:
0% Importing...

32% Importing...

37% Importing...

...

100% Imported

100% Imported
0% Exporting as1-oc-214.stp.stl...
100% Imported
40% Exporting as1-oc-214.stp.stl...

...

100% Imported
100% Exporting as1-oc-214.stp.stl...
100% Imported
100% Exported as1-oc-214.stp.stl...

@DDman1984
Copy link
Author

DDman1984 commented Oct 23, 2023

Hi, @HuguesDelorme

Thank you for your advice and response. In fact, I've tried using C# process APIs and consulted the .NET official documentation. However, I still haven't been able to obtain Mayo's output log during the conversion process.

I'm including my code below in the hope that it can help you understand my issue. Thank you very much.

public partial class MainWindow : Window {
    public MainWindow() {
        this.InitializeComponent();
        var proc = new Process
        {
            StartInfo = new ProcessStartInfo
            {
                FileName = "C:\\Program Files\\Fougue\\Mayo\\mayo.exe",
                Arguments = "C:\\Users\\User\\Downloads\\QG76_CFM_5p.stp --export C:\\Users\\User\\Downloads\\test.glb",
                UseShellExecute = false,
                RedirectStandardOutput = true,
                CreateNoWindow = true
            }
        };
        proc.Start();
        string q = "";
        while (!proc.HasExited)
        {
            q += proc.StandardOutput.ReadToEnd();
        }
        Console.WriteLine($"output : {q} ");
    }
}

The above code can launch Mayo and perfectly convert the model to the glb format, but I'm unable to retrieve any output text by the C# process from mayo...@@

update:
hi, @HuguesDelorme
#include <iostream> int main() { std::cout << "Hello World! DDMAN TEST"; std::cout.flush(); }

I made a simple attempt to write a C++ console application that can capture output messages through the C# code above. I reviewed the cli_export.cpp code you wrote, and in terms of output logic, it doesn't seem to be significantly different. However, I noticed that you are managing output messages through tasks. Please forgive me, as I'm not very familiar with C++. Could this be a potential issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants