2017-10-14 2 views
0

MPxNode::computeの方法で使用できますか?私のプラグインの実装では、別のプロセスで使用されていなくても、MProgressWindowは予約されていません。MPxNode :: compute内でMProgressWindowを使用する

MStatus Node::compute(const MPlug & plug, MDataBlock & data) { 
    if (!MProgressWindow::reserve()) 
     return MS::kFailure; 

    MProgressWindow::setTitle(this->typeName); 
    MProgressWindow::setInterruptable(true); 
    MProgressWindow::setProgressRange(0, 100); 
    MProgressWindow::setProgressStatus("Initializing: 0%"); 
    MProgressWindow::setProgress(0); 

    MProgressWindow::startProgress(); 

    // Some expensive operation. 
    // If the user presses ESC key, this ends the progress window and returns failure. 

    MProgressWindow::endProgress(); 

    return MS::kSuccess; 
} 

注:ノードが削除されると、MProgressWindowが表示されます(奇妙な動作)。

何か助けていただきありがとうございます。

答えて

0

Maya 2016以前のプラグインコードは、MayaのUIと同じスレッドで実行されます。これは、プラグインが何かをしているときはいつでも、MayaのUIがフリーズしていることを意味します。

compute()では、MProgressWindowの呼び出しはUIアクションの束をキューに入れていますが、compute()が返ってスレッドがUIに制御を戻すまで処理されません。

Maya 2016以降、より複雑になりました。プラグインコードがMayaのUIと同じスレッドで実行されるかどうかは、Evaluation Managernode typeの設定に依存します。

MProgressWindowの代わりにMComputationを試してみてください。私はcompute()メソッドの中からMComputationを試していないので動作しないかもしれませんが、そのデザインは少なくともその使用法に適しています。

関連する問題