Maya:将脚本推迟到注册VRay之后?

2024-09-30 04:33:46 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图延迟我的管道工具的一部分(在Maya启动期间运行)在注册VRay之后运行。在

我正在延迟初始化用户设置.py是这样的:

def run_my_tool():
    import my_tool
    reload(my_tool)

mc.evalDeferred("run_my_tool()")

我尝试在工具中使用evalDeferred来延迟render_settings脚本的执行,但它在注册VRay之前一直在运行。对于如何为VRay register事件创建侦听器,或者是什么事件,有什么想法?谢谢!在

编辑

提出了一个新的主题来了解如何正确使用西奥多的条件/脚本作业命令建议here。在


Tags: 工具run用户pyimport脚本管道my
1条回答
网友
1楼 · 发布于 2024-09-30 04:33:46

技术部的尤伦-艺术家网教我如何正确地做这件事。这是一个link to the thread

以下是尤伦的帖子:

“除非必须,否则不要将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)

““

相关问题 更多 >

    热门问题