【问题标题】:Using MProgressWindow inside MPxNode::compute在 MPxNode::compute 中使用 MProgressWindow
【发布时间】:2017-10-14 21:29:23
【问题描述】:

我可以在MPxNode::compute 方法中使用MProgressWindow 吗?我的插件实现不会保留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(奇怪的行为)。

感谢您的帮助。

【问题讨论】:

    标签: progress-bar nodes maya-api


    【解决方案1】:

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

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

    从 Maya 2016 开始,它变得更加复杂。您的插件代码是否与 Maya 的 UI 在同一线程中运行取决于 Evaluation Managernode type 设置。

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-18
      • 1970-01-01
      • 2019-11-02
      • 2015-07-20
      • 1970-01-01
      • 2018-06-20
      相关资源
      最近更新 更多