Introduction to Maya - Modeling Fundamentals Vol 1
This course will look at the fundamentals of modeling in Maya with an emphasis on creating good topology. We'll look at what makes a good model in Maya and why objects are modeled in the way they are.
# 1 27-07-2003 , 12:49 PM
Alan's Avatar
Moderator
Join Date: Oct 2002
Location: London, UK
Posts: 2,800

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?

user added image

Alan


Technical Director - Framestore

Currently working on: Your Highness

IMDB
# 2 27-07-2003 , 01:16 PM
BabyDuck's Avatar
Subscriber
Join Date: Nov 2002
Location: USA
Posts: 1,170
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.

# 3 27-07-2003 , 01:26 PM
Alan's Avatar
Moderator
Join Date: Oct 2002
Location: London, UK
Posts: 2,800
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


Technical Director - Framestore

Currently working on: Your Highness

IMDB
# 4 27-07-2003 , 01:33 PM
BabyDuck's Avatar
Subscriber
Join Date: Nov 2002
Location: USA
Posts: 1,170
aehm, give me some minutes (maybe an even an hour) and i get something tested that is based on more solid ground ...

# 5 27-07-2003 , 01:35 PM
Alan's Avatar
Moderator
Join Date: Oct 2002
Location: London, UK
Posts: 2,800
thanks mate, i'm gonna be trying too. user added image


Technical Director - Framestore

Currently working on: Your Highness

IMDB
# 6 27-07-2003 , 01:53 PM
Alan's Avatar
Moderator
Join Date: Oct 2002
Location: London, UK
Posts: 2,800
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... ? user added image


Technical Director - Framestore

Currently working on: Your Highness

IMDB
# 7 27-07-2003 , 02:06 PM
BabyDuck's Avatar
Subscriber
Join Date: Nov 2002
Location: USA
Posts: 1,170
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 ???

# 8 27-07-2003 , 02:07 PM
Alan's Avatar
Moderator
Join Date: Oct 2002
Location: London, UK
Posts: 2,800
ok let me try that user added image


Technical Director - Framestore

Currently working on: Your Highness

IMDB
# 9 27-07-2003 , 02:41 PM
Alan's Avatar
Moderator
Join Date: Oct 2002
Location: London, UK
Posts: 2,800
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! user added image

thanks for your help babyduck you're a star user added image

Alan


Technical Director - Framestore

Currently working on: Your Highness

IMDB
# 10 27-07-2003 , 02:44 PM
BabyDuck's Avatar
Subscriber
Join Date: Nov 2002
Location: USA
Posts: 1,170
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 ...

# 11 27-07-2003 , 02:50 PM
Alan's Avatar
Moderator
Join Date: Oct 2002
Location: London, UK
Posts: 2,800
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?

user added image

Alan


Technical Director - Framestore

Currently working on: Your Highness

IMDB
# 12 27-07-2003 , 03:21 PM
BabyDuck's Avatar
Subscriber
Join Date: Nov 2002
Location: USA
Posts: 1,170
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.

# 13 27-07-2003 , 03:24 PM
BabyDuck's Avatar
Subscriber
Join Date: Nov 2002
Location: USA
Posts: 1,170

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 user added image

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

# 14 27-07-2003 , 03:25 PM
Alan's Avatar
Moderator
Join Date: Oct 2002
Location: London, UK
Posts: 2,800
ok man you've been a big big help! user added image there's a programmer within you just waiting to burst out!! user added image

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!! user added image

ALan


Technical Director - Framestore

Currently working on: Your Highness

IMDB
# 15 27-07-2003 , 03:29 PM
BabyDuck's Avatar
Subscriber
Join Date: Nov 2002
Location: USA
Posts: 1,170
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

Posting Rules Forum Rules
You may not post new threads | You may not post replies | You may not post attachments | You may not edit your posts | BB code is On | Smilies are On | [IMG] code is On | HTML code is Off

Similar Threads