1月23日のはうまく動かなかった。
デバッグしたついでに各種エラーメッセージの表示とMELとPythonの両方に対応して
みた。
import maya.cmds as maya
import maya.mel as mel
import re
def evalMelNote():
# select an object which note includes MEL command, then invoke me
tmp = maya.ls(selection=True)
if not tmp:
maya.confirmDialog(message="Please select node(s)")
return
obj = tmp[0]
note = maya.getAttr(obj + ".nts", asString=True)
if not note:
maya.confirmDialog(message="no note in %s" % obj)
return
try:
if re.search('^[ \t]*#', note):
return eval(note)
else:
return mel.eval(note)
except Exception, e:
maya.confirmDialog(message="An error occured: %s" % e)