0

我可以使用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会显示(奇怪的行为)。

我很感激任何帮助。

4

1 回答 1

0

在 Maya 2016 之前,插件代码与 Maya 的 UI 在同一线程中运行。这意味着每当您的插件执行任何操作时,Maya 的 UI 都会被冻结。

在您的 compute() 中,MProgressWindow 调用正在排队一堆 UI 操作,但直到 compute() 返回并且线程可以将控制权交还给 UI 之后才会处理它们。

从 Maya 2016 开始,它变得更加复杂。您的插件代码是否与 Maya 的 UI 在同一线程中运行取决于评估管理器节点类型设置。

尝试使用MComputation而不是 MProgressWindow。我没有在 compute() 方法中尝试过 MComputation,所以它可能不起作用,但它的设计至少更适合这种用法。

于 2017-12-24T11:06:08.130 回答