techartorg / MXSPyCOM

A modern version of MXSCOM, to allow for editing & execution of 3ds Max MaxScript and Python files from external code editors.
MIT License
176 stars 23 forks source link

Suppressdialogs #3

Closed garytyler closed 6 years ago

garytyler commented 6 years ago

Relevant history and description here : https://github.com/JeffHanna/MXSPyCOM/issues/2

The current implementation here is working reliably. It takes the maxscript command string and wraps it in more maxscript code before giving it to 3ds max for execution. That extra code consists of a try() catch() to subvert error dialogs if the command raises an exception when called in 3ds Max, and some language-dependent code for generating a homemade exception message to be output in the Max listener window.

A solution which finds and closes the error dialog popups would give a native exception output. I haven't attempted that, mostly because wrapping it all in a try() catch() is just more contained, avoids interference with GUI elements.

I'm happy to make any requested adjustments in the implementation. I'll include some detail here about the current output messages.

How the output messages are generated

If running a Python file, a decent error message is made from only the array given by the maxscript command getCurrentException().

If running a Maxscript file, the filename, position, and line number are retrieved with maxscript commands getErrorSourceFileName(), getErrorSourceFileOffset(), getErrorSourceFileLine(), and getCurrentException() respectively.

I've just formatted these commands in a reasonably conformed way, leaning towards keeping things simple.

Improvements to the output messages

Double Quotes

Currently, each line has to be printed with double quotes. I think using setListenerSelText from this doc page to print the output may rectify this. I will try this within the next week, possibly the next few days.

The current implementation includes an extra \n on the first line. That is a personalization that I'll remove.

Content

The current messages differ quite a bit from the one generated by Max, but I don't know if there's a standard to the anatomy of exception messages. In this case, I find it handy to have the start of the trace readout on the last line, so that it's displayed in the mini-listener in Max. The tracebacks from getCurrentException() lack detail in most cases, but not all. I went through the commands in the MAXScript Try Expression Documentation and wasn't able to get anything from getCurrentExceptionCallStack in 3ds Max 2018.

Color

The Max exceptions print in red. I'm pretty sure there's no way to get anything except blue with user-generated output.

garytyler commented 6 years ago

Update: I just pushed a new commit that implements setListenerSelText. This has 3 effects:

JeffHanna commented 6 years ago

I've merged your pull request, rebuilt the binary, and made a new release on GitHub. https://github.com/JeffHanna/MXSPyCOM/releases/tag/1.0.1.0

Thank you, Gary! Your work is a very nice addition to the tool.

On Tue, Apr 24, 2018 at 5:38 PM Gary Tyler McLeod notifications@github.com wrote:

Update: I just pushed a new commit that implements setListenerSelText. This has 3 effects:

  • Black text highlight color, which is nice in my opinion.
  • No more extraneous double quotes on each line
  • If the listener is closed, this command opens it.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/JeffHanna/MXSPyCOM/pull/3#issuecomment-384102039, or mute the thread https://github.com/notifications/unsubscribe-auth/AAJN19BCXFhI0ihN86lq18NyvGCfQQzEks5tr6lwgaJpZM4Tg4sm .

garytyler commented 6 years ago

Nice! Thanks Jeff. I have used this tool quite a bit. I'm pleased to be able to contribute!