Babylon Maya Exporter - Automated process with Python/MEL hangs

Hi all,
I’m working on a script that prepares a Maya (2019) scene file for export to glTF, and then invokes the Babylon Maya Exporter (20200701.2) to do the actual export using the MEL command “ScriptToBabylon” as documented here Exporters/exportScriptExemple.mel at master · BabylonJS/Exporters · GitHub.

The problem I’m running into is that when the “ScriptToBabylon” command is invoked, the exporter outputs “// Export Started //” to the console and doesn’t proceed. Likely related, the Maya UI and Viewport don’t get blocked the same way they are when you run the export manually through the Babylon Exporter window. And curiously, if I scrub the timeline in Maya by hand, the export process proceeds bit by bit, but slowly, and I have to keep scrubbing the timeline or else it stops again. Also, if I run the export command on its own, without any of the preceding commands that prepare the scene, it doesn’t hang. But I want to make exporting a single automated process, rather than one in which someone has to run a script that prepares the scene, wait for it to finish, then run the export command separately.

Anyone have any idea what’s going on? If it makes a difference, the main script I’m running is in Python, which then calls the export command using the mel.eval() command.

Pinging @Drigax

Hi @pnut welcome to the forum,

We don’t officially support python/MEL, can you test if invoking the export via just MEL works?

hi @Drigax,
taking Python out of the equation doesn’t seem to help. What I’ve found so far is if the script (whether it’s MEL or Python) opens a file as part of the process, the export will hang, but if it’s just changing something in the scene without opening anything, the export seems to run fine. The simplest way to reproduce this is to run a MEL script that opens any Maya file using the “file” command and then calls the “ScriptToBabylon” command. Do you want to give it a try? Below is the MEL code (you’ll have to update the maya file path and the output path to run it):

file -open -force “[MAYA FILE PATH]”;
string $parameters[] = `GenerateExportersParameter`;
$parameters[0] = “[OUTPUT PATH]”;
$parameters[1] = “gltf”;
$parameters[2] = “”;
$parameters[3] = “1”;
$parameters[4] = “False”;
$parameters[5] = “True”;
$parameters[6] = “False”;
$parameters[7] = “False”;
$parameters[8] = “False”;
$parameters[9] = “False”;
$parameters[10] = “True”;
$parameters[11] = “True”;
$parameters[12] = “False”;
$parameters[13] = “False”;
$parameters[14] = “False”;
$parameters[15] = “False”;
$parameters[16] = “True”;
$parameters[17] = “False”;
$parameters[18] = “False”;
$parameters[19] = “100”;
$parameters[20] = “True”;
$parameters[21] = “False”;
$parameters[22] = “False”;
$parameters[23] = “False”;
$parameters[24] = “False”;
$parameters[25] = “False”;
$parameters[26] = “False”;
$parameters[27] = “False”;
$parameters[28] = “”;
ScriptToBabylon -exportParameters $parameters;

1 Like

sure, thanks for the script, I’ll run this on a simple scene under a debugger to see what happens.

Looks like we’re hanging on Application.DoEvents() consistently:

To be honest I’m not sure why we even invoke this call every message…

EDIT: looks like we do this in the Export form code behind in order to update the exporter window application to redraw as we generate new messages, but this doesn’t seem necessary in the MEL entry point. I’ll remove this call and see what happens.

1 Like

fix should be available shortly:

Thanks so much, this fix is going to save me a lot of time!