我正在尝试延迟我的管道工具的一部分(在Maya启动时运行),以便在VRay注册之后运行。
我目前正在推迟userSetup.py中工具的初始化,如下所示:
def run_my_tool():
import my_tool
reload(my_tool)
mc.evalDeferred("run_my_tool()")
我尝试在工具中使用evalDeferred来延迟render_settings脚本的执行,但是在VRay被注册之前它一直在运行。对于如何为VRay注册事件创建侦听器,或者是什么事件,有任何想法吗?谢谢!
编辑
提出了一个新的主题,以了解如何正确使用传统的条件/脚本作业命令建议这里。
发布于 2016-07-27 00:13:48
在Techno-Arsts.com网站上,Uiron向我展示了如何正确地做这件事。这是一个链接到线程
这是uiron的帖子:
“除非有必要,否则不要将python代码作为字符串传递。无论哪里接受python回调(在Maya的api中并不是所有的地方,但大部分是在任何地方),都可以尝试其中的一个:
# notice that we're passing a function, not function call
mc.scriptJob(runOnce=True, e=["idle", myObject.myMethod], permanent=True)
mc.scriptJob(runOnce=True, e=["idle", myGlobalFunction], permanent=True)
# when in doubt, wrap into temporary function; remember that in Python you can
# declare functions anywhere in the code, even inside other functions
open_file_path = '...'
def idle_handler(*args):
# here's where you solve the 'how to pass the argument into the handler' problem -
# use variable from outer scope
file_manip_open_fn(open_file_path)
mc.scriptJob(runOnce=True, e=["idle", idle_handler], permanent=True)
“
https://stackoverflow.com/questions/38601706
复制相似问题