Search code examples
pythonmayamelpymel

How can I clear the Maya Script Editor programatically?


While creating and debugging scripts, I generate lots of feedback for myself, but if I don't clear the Script Editor, I can get confused about which attempt the feedback I'm looking at came from.

Is there a way (preferably with PyMEL, but MEL is ok) to clear the Script Editor History?


Solution

  • Try:

    cmds.scriptEditorInfo(ch=True)
    

    Or (PyMEL version):

    import pymel.core as pm
    pm.scriptEditorInfo(clearHistory=True)
    

    You should also take a look at python's built-in logging module. It allows you to define logging formatters which include the file name and line number where the log message was generated so you can see precisely where things came from.