2017-10-14 61 views
0

我可以在MPxNode::compute方法中使用MProgressWindow方法嗎?即使未被其他進程使用,我的插件實施也不會保留MProgressWindowMPxNode內使用MProgressWindow :: compute

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設置。使用MComputation而不是MProgressWindow嘗試使用。我沒有從compute()方法中嘗試MComputation,因此它可能無法正常工作,但其設計至少更適合該用法。