Frame Mel script

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

Thread Tools Search this Thread Display Modes
Old 12 December 2012   #1
Frame Mel script


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.

__________________ - 3d visualisation & animation studio
Old 12 December 2012   #2
under Render Settings, there are Render Options. You can execute mel every frame that way.
Old 12 December 2012   #3
Hi, thanks for the starting point.

__________________ - 3d visualisation & animation studio
Old 12 December 2012   #4

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.

__________________ - 3d visualisation & animation studio
Old 12 December 2012   #5
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.
Old 12 December 2012   #6
Thread automatically closed

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.
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
Thread Closed share thread

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Society of Digital Artists

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump

All times are GMT. The time now is 11:58 AM.

Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.