How to suppress/mute script editor warning correctly?

Anonymous

How to suppress/mute script editor warning correctly?

Anonymous
Not applicable

Hi everyone 

I need to open some large/messy scenes from other artists. It always prompts out a lot of warnings and freezes Maya for a long time.  I try to write a custom "open file" with python to suppress warning messages. But it seems not really "mute"  script editor entirely. Let's say, when I open Hypershade window after open file, warnings prompt out again since I have lots of missing textures.  The script I use now is:

 

import maya.cmds as cmds
import maya.mel as mel
filename = cmds.fileDialog2(fileMode=1)
reporter = mel.eval( 'string $tmp = $gCommandReporter;' )
cmds.scriptEditorInfo(reporter,suppressWarnings=True,suppressInfo=1,se=1,ch=1)
cmds.disableIncorrectNameWarning() 
cmds.file( filename[0], i=True );

Not sure if I use this API correctly, Many thanks for your advice.  

 

Thank you

0 Likes
Reply
Accepted solutions (1)
10,374 Views
7 Replies
Replies (7)

rajasekaransurjen
Collaborator
Collaborator

hi,

Try this....

In the Script Editor, turn off History > Echo All Commands.

0 Likes

Anonymous
Not applicable

Hi. it's not working, warning and error are not effect by this option.

And I expect to use a script instead of menu action. 

Thanks

0 Likes

Anonymous
Not applicable
Accepted solution

Finally, succeed. So basically this works:

    import maya.cmds as cmds
    cmds.scriptEditorInfo(suppressWarnings=0,suppressInfo=0,se=0)


The reason I couldn't get it to work is that I use Charcoal Editor for Maya to write python. It somehow not suppress warnings. After I unload it everything is ok.

 

pandalope
Participant
Participant

what would the correct settings be to set it back to the default?

0 Likes

Anonymous
Not applicable

http://help.autodesk.com/cloudhelp/2016/CHS/Maya-Tech-Docs/CommandsPython/

The document doesn't mention the default value but I guess you can query the flag value before you do any changes.

 

import maya.cmds as cmds

info = cmds.scriptEditorInfo(query=True, suppressInfo = True)
print(info)

Hans_Redman
Advocate
Advocate

Hi,
You also can try this: History > Suppress Warning Messages.
Hope this helps

0 Likes

brent8S64J
Contributor
Contributor

Store the settings of the scriptEditor window in a dictionary called "state":

flags = ["se", "si", "sr", "sw", "ssw"]
state = {}
for x in flags:
    kwargs = {"q" : True, x : True}
    val = maya.cmds.scriptEditorInfo(**kwargs)
    state[x] = val
print(state)

 

Do your settings.  In my case, I want to suppress warnings

 

maya.cmds.scriptEditorInfo(e=True, sw=True)

 

Then reset things back to the way they were:

 

for x, val in state.iteritems():
    kwargs = {"e" : True, x : val}
    maya.cmds.scriptEditorInfo(**kwargs)

 

You may want to clear the stack before you do this, it can chugalug a bit if you've got a long history.

0 Likes