Simply Maya User Community

Simply Maya User Community (https://simplymaya.com/forum/index.php)
-   Maya Basics & Newbie Lounge (https://simplymaya.com/forum/forumdisplay.php?f=31)
-   -   running a script before the batch render of a frame (https://simplymaya.com/forum/showthread.php?t=7135)

Alan 27-07-2003 12:49 PM

running a script before the batch render of a frame
 
ok I need to figure out a way of making a script run before each rendered frame. I know I can use the pre and post mel commands in the render globals to run a script before the render. But I need to run that script before each frame. any ideas? I have got a solution but it sucks:

create a MEL for loop, run the script command, use the render MEL command.

Only problem with this is that it doesnt give me a good file name because it doesnt pick it up from the render globals.

Anyone got any good ideas?

:)

Alan

BabyDuck 27-07-2003 01:16 PM

let me think - if you create an expression for an attribute - cant you set it to run always? might be a real bad and unclean thing, but who prevents you to start a mel script to "change a attribute" i think they will be run only once a frame. and maya cannot know that the dummy object really gets an attribute changed, or if it moves (your spiders ?? ) around.

Alan 27-07-2003 01:26 PM

ok I see, where would I set this attribute? thing is that it's for a LOD script I wrote. And it will basically loop through each spider and calculate how far from the camera it is and then opacity blend the two objects together.... so yeah if I could set it to run every frame then that would work fine.

ALan

BabyDuck 27-07-2003 01:33 PM

aehm, give me some minutes (maybe an even an hour) and i get something tested that is based on more solid ground ...

Alan 27-07-2003 01:35 PM

thanks mate, i'm gonna be trying too. :)

Alan 27-07-2003 01:53 PM

ok babyduck i got it working ish..... i added an expression to the camera1shape node. I just made it call the global proc I have created to do the LOD stuff. And in the viewport when I play the thing back it works.... only problem is it doesnt do it when I batch render it... ? :(

BabyDuck 27-07-2003 02:06 PM

i successfully did it. and it worked in batch render (i only tested from starting outside of maya). i create a very simple thing like:
Code:

expression -s "print \"test\\n\";"  -o locator1 -n "runEveryFrame" -ae 1 -uc all ;
and it printed the "test" in batch render before each frame. it was just the default - add expression to anything in the locator1 and name it "run every frame" with "run always" checked. worked like a charm.

maybe you must not start it from within maya ???

Alan 27-07-2003 02:07 PM

ok let me try that :)

Alan 27-07-2003 02:41 PM

I cant get it to work still:

I set up the locator and then added the expression but it's still only doing it in the viewport. the expression I have added is:

print("Doing LOD \n");
doLod;

I replaced the part of yours that just printed out "test". But i cant get it to pick it up in the batch render. What is the command that you are using to render from the command prompt? cause i have tried render -f filename etc and it says that I am specifying more than one file name:

render -cam cam E:\maya work\spiderHme\scenes\finalSpiderRigging\lodTest.m b -s 1 -e 19

arghhh this is so frustrating! :)

thanks for your help babyduck you're a star :)

Alan

BabyDuck 27-07-2003 02:44 PM

i used

Code:

render -s 1 -e 10 test.mb
and i am pretty sure it is not a 4.0 vs. 4.5 issue ...

Alan 27-07-2003 02:50 PM

ok it works if i batch render from the CMD but it says that it cant find my procedure because I havent define it yet. I have saved the project file with the script defined and everything. Is there a way I can tell it to use that script/procedure and define it beforehand so that it knows it exists?

:)

Alan

BabyDuck 27-07-2003 03:21 PM

i think that is better asked in the mel scripting forum - it is too advanced for basic and newbie forum imho - and it is too advanced for me anyway :p - i can program, but i have not learned mel yet - only playing aroung with it.

BabyDuck 27-07-2003 03:24 PM

Quote:

Originally posted by Pure_Morning
ok it works if i batch render from the CMD ...
and by the way - i dont know any other way to start a batch render than from command prompt. there is actually a button inside maya to do that fancy stuff? just kidding :D

but if you render out a bigger project, it is not economically at all to have maya eat up resources while you render ...

Alan 27-07-2003 03:25 PM

ok man you've been a big big help! :) there's a programmer within you just waiting to burst out!! ;)

I just checked the maya help file about the pre and post mel commands and this is what is says:

A MEL command or script to run before rendering each frame (Pre Render MEL), or after rendering each frame (Post Render MEL).

Which is just not true, it just runs it once and then then doesnt do it on any other frames.... damn it!! :)

ALan

BabyDuck 27-07-2003 03:29 PM

it does what it says it does - pre render (before it actually starts to render) and post render (after you are done with the whole render job) :p

just not what you want with each frame :p


All times are GMT. The time now is 06:40 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Simply Maya 2018