Community
Maya Programming
Welcome to Autodesk’s Maya Forums. Share your knowledge, ask questions, and explore popular Maya SDK topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to suppress/mute script editor warning correctly?

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
aboutvenice
9152 Views, 7 Replies

How to suppress/mute script editor warning correctly?

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

7 REPLIES 7
Message 2 of 8

hi,

Try this....

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

Message 3 of 8

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

Message 4 of 8
aboutvenice
in reply to: aboutvenice

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.

 

Message 5 of 8
pandalope
in reply to: aboutvenice

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

Message 6 of 8
aboutvenice
in reply to: pandalope

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)
Message 7 of 8
Hans_Redman
in reply to: aboutvenice

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

Message 8 of 8
brent8S64J
in reply to: pandalope

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.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report