NACA Airfoil script

 From:  Michael Gibson
7265.2 In reply to 7265.1 
Hi Hamish, I don't see anything obvious that would easily be changed to speed that up - what you're probably running into is overhead from inter-process communication. Command scripts run in a separate process called moi_commandprocessor.exe and every property access or method call into a MoI object involve some communication between moi_commandprocessor.exe and the main moi.exe process. Most regular Moi commands only really control high level program flow like showing UI, setting up point pickers, stuff like that which does not involve any significant loops. So the overhead for the interprocess communication is not really noticeable in those cases. But for a script that's doing some kind of loop that per-call overhead can add up.

One thing you can do to improve performance is to move chunks of your script code into the .htm file, scripts that run in that script context are running inside of MoI.exe directly and so have a much lower per-call overhead. But the downside of that is that it's also then more possible for those scripts to lock up MoI if they go into an infinite loop or do heavy processing. One of the main reasons why the scripts run in a separate process normally is so they can't lock up the main process and can be forcibly terminated more easily.

In order to run script code directly in MoI.exe you put the script code inside the .htm part of your command, instead of a <script> block in the <head> of the HTML document, then inside of your .js command file you can call into that .htm script by accessing the HTML global object by using moi.ui.commandUI . So for example if there is a script function called MyScript inside the .htm file it can be run from the regular command script by calling moi.ui.commandUI.MyScript();

That's probably what would be involved to get more performance out of your script, it's difficult to do much to improve loop performance on out of process scripts.

In the future I want to try and improve how remote process access works by kind of batching up property accesses and maintaining a local version of the object being accessed rather than having inter-process calls for each individual property accesses as it currently does. That will probably involve a fair amount of work though.

- Michael