如何以编程方式清除 Maya 脚本编辑器?

如何以编程方式清除 Maya 脚本编辑器?

问题描述:

在创建和调试脚本时,我为自己生成了大量反馈,但如果我不清除脚本编辑器,我可能会混淆我正在查看的反馈来自哪个尝试.

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.

有没有办法(最好使用 PyMEL,但 MEL 可以)清除脚本编辑器历史记录?

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

尝试:

cmds.scriptEditorInfo(ch=True)

或(PyMEL 版本):

Or (PyMEL version):

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

您还应该查看 python 的内置日志记录模块.它允许您定义日志格式化程序,其中包括生成日志消息的文件名和行号,以便您可以准确地查看事物的来源.

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.