PDA

View Full Version : Frame Mel script


Mules
12-12-2012, 12:51 PM
Hi,

I'm looking for the Mel script code for a script that is executed when the timeslider is at a specific frame. Is this possible in Maya and where do you state it ?

I try to set up a scene for still batch rendering with different output image sizes. So from this scene I need 3 different image size renderings. At three different frames the composition of objects changes (keyed) slighty depending on the image size. So now I try to set up batch rendering so that I don't have to switch image sizes manually at the 3 frames, but that it is done automatically when batch rendering, but if possible also in the user interface. I already have the mel code to change the render image size and pixel & device aspect ratio, which I currently use as a shelf command to easily swap render image size manually.

Thanks,
m.

Kecal
12-12-2012, 02:42 PM
Hi,
under Render Settings, there are Render Options. You can execute mel every frame that way.

Mules
12-13-2012, 09:31 AM
Hi, thanks for the starting point.

m,

Mules
12-13-2012, 02:47 PM
Hi,

I created this script :

global int $current_frame;
$current_frame = `currentTime -query`;
print $current_frame;
if ($current_frame == 1) {
setAttr "defaultResolution.width" 994;
setAttr "defaultResolution.height" 800;
setAttr "defaultResolution.deviceAspectRatio" ((float) 994/800);
setAttr "defaultResolution.pixelAspect" 1;
}

if ($current_frame == 10) {
setAttr "defaultResolution.width" 601;
setAttr "defaultResolution.height" 800;
setAttr "defaultResolution.deviceAspectRatio" ((float) 601/800);
setAttr "defaultResolution.pixelAspect" 1;
}

if ($current_frame == 19) {
setAttr "defaultResolution.width" 1250;
setAttr "defaultResolution.height" 650;
setAttr "defaultResolution.deviceAspectRatio" ((float) 1250/650);
setAttr "defaultResolution.pixelAspect" 1;
}

If I add this as an expression in the expression editor, the render/image size changes when going to the specific frame. When I use a batch render, with a frame jump of 9, it renders in different sizes but not at the exact frames. I guess this is because the script gets loaded after the render. So it renders frame 1, at the currect image size, the next frame is rendered at that same size, then he reads the expression, changes the image size and the last image is rendered with the frame size of that has been changed, after that he changes the image size again, but it's not used in the render.

When I use the script in the pre render frame MEL input field I get an error in the render output log and the batch render fails.
"$current_frame is an undeclated variable."

When I use it in the other pre render input fields, the frames are render but he seems to do the script but only once.

m.

Kecal
12-14-2012, 07:47 AM
Pre render is executed only once before render.
Just guesses, but you copy this script in textField?
Try create procedure and call only this procedure or maybe enclose whole code in parenthesis.

CGTalk Moderation
12-14-2012, 07:47 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.