2017-10-14 57 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,因此它可能无法正常工作,但其设计至少更适合该用法。