Feedback

What's your question?

By: [ Editor ] Asked

Suspending viewport updates when creating keyframes via MEL

So I have a traditional bread-and-butter MEL which does

    currentTime $frameNo;
    setAttr ($timeNode + ".outTime") $frameValue;
    setKeyframe ($timeNode + ".outTime");

I am almost always doing this in a scene with an image plane or other viewport-heavy things that need to be loaded or computed. Is there a possibility to suspend viewport updates while I walk the frames?

Add comment viewed 203 times Latest activity 11 months ago

or Cancel

1 answer

  • 0

julian [ Admin ]

Not sure if this helps, but you can drag in the time slider with the middle mouse button to go to a frame without the viewport updating.

Also, I made some mel to disable image planes by disconnecting them from the imagePlane attribute of the camera and connecting them to a dynamic attribute on the camera instead. Its handy for baking and the like. It seems if image planes are connected they always try to load and slow things down, even if the display is set to none. By disconnecting them they don't get evaluated. To re-enable them, just find the connection from the dynamic attribute and reconnect to imagePlane attr.

EDIT

Here's that mel:

proc string[] utility.enableDisableImagePlanes(int $mode) {
    // 0 disable
    // 1 enable
    string $result[];
    string $imagePlanes[] = `ls -type "imagePlane"`;
    for ($ip in $imagePlanes) {
        if ($mode) {
            if (`attributeQuery -n $ip -ex "imageNameStash"`)   {
                string $path = `getAttr ($ip+".imageNameStash")`;
                setAttr -type "string" ($ip + ".imageName")  $path;
            } else {
            //  warning("this image plane was never disabled");
            }
        } else {
            if (! `attributeQuery -n $ip -ex "imageNameStash"`) {
                addAttr -ln  "imageNameStash" -dt "string" $ip;
            }
            string $path = `getAttr ($ip+".imageName")`;
            setAttr -type "string" ($ip + ".imageName") "";
            setAttr -type "string" ($ip + ".imageNameStash") $path;
        }
        $result[`size $result`] = $ip;
    }
    return $result;
}

global proc string[] utility.enableImagePlanes() {
     return utility.enableDisableImagePlanes(1) ;
}
global proc string[] utility.disableImagePlanes() {
     return utility.enableDisableImagePlanes(0) ;
}
NN comments
julik
-

Thanks that does look like an alternative indeed!

or Cancel