2016-07-27 4 views
0

私は、VRayが登録された後に実行するパイプラインツール(Mayaの起動時に実行される)の一部を遅らせようとしています。Maya:VRayを登録するまでスクリプトを延期しますか?

def run_my_tool(): 
    import my_tool 
    reload(my_tool) 

mc.evalDeferred("run_my_tool()") 

私はrender_settingsスクリプトの実行を遅らせるためにツール内evalDeferredを使用して試してみたが、それは続けて:

私は現在、そのようuserSetup.pyにツールの初期化を遅らせていますVRayが登録される前に実行されています。 VRay登録イベントのリスナーを作成する方法や、それがどのようなイベントですか?ありがとう!

EDIT:正しくtheodoxの条件を使用する方法を理解するための新しいトピックを作った

は/ scriptJobが提案hereコマンド。

答えて

0

Uiron over tech-artists.comでは、これを正しく行う方法がわかりました。ここでlink to the thread

だ。ここuironによってポストです:あなたがする必要がある場合を除き

は「(それはほとんどどこにでもMayaのAPIにはどこにでもありませんが、)Pythonのコールバックが受理された場合はいつでも文字列としてPythonコードを渡しません。すべてのロードが完了するまで延期するかなり一般的な方法です

# 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) 

+1

:、これらのいずれかを試してみてください。 'condition'コマンドと' scriptJob(ct = True) 'を使ってロードするときにプラグインと起動をチェックするカスタム条件を作成することもできます。 – theodox

+0

素晴らしい音です。 –

+0

@theodox私はあなたの提案を試していますが、モジュールから条件スクリプトを実行するときに問題が発生しています。スクリプトエディタから実行するとうまく動作します。 EDITの元の投稿にコードを投稿しました –

関連する問題