Maya Training

Introduction to Hard Surface Modeling

Maya Training

Interiors and Furniture Vol 1 & 2 - Modeling & Cloth

Maya Training

Shading, Lighting and Rendering the Bedroom in MR

Maya Training

Robot volume one - Modeling with animation in mind

Maya Training

Spach-Alspaugh House the complete courseware

Maya Training

Burt The Cartoon Dinosaur Vol 01 - Modeling

New Maya Training

Robot Volume 02 - Hybrid Rigging
You are here > Home > SimplyMaya Community Forums
Loading

Welcome to Simply Maya

Please Sign in or Sign up for an account

Member Login

Lost your password?

Not a member yet? Sign Up!

Old 27-07-2003, 01:49 PM   #1
Alan
Moderator
 
Alan's Avatar
 
Join Date: Oct 2002
Location: London, UK
Posts: 2,800
Thanks: 0
Thanked 5 Times in 5 Posts
Default 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
__________________
Technical Director - Framestore

Currently working on: Your Highness

IMDB
Alan is offline   Reply With Quote
Old 27-07-2003, 02:16 PM   #2
BabyDuck
Subscriber
 
BabyDuck's Avatar
 
Join Date: Nov 2002
Location: USA
Posts: 1,170
Thanks: 3
Thanked 12 Times in 12 Posts
Default

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.
BabyDuck is offline   Reply With Quote
Old 27-07-2003, 02:26 PM   #3
Alan
Moderator
 
Alan's Avatar
 
Join Date: Oct 2002
Location: London, UK
Posts: 2,800
Thanks: 0
Thanked 5 Times in 5 Posts
Default

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
Alan is offline   Reply With Quote
Old 27-07-2003, 02:33 PM   #4
BabyDuck
Subscriber
 
BabyDuck's Avatar
 
Join Date: Nov 2002
Location: USA
Posts: 1,170
Thanks: 3
Thanked 12 Times in 12 Posts
Default

aehm, give me some minutes (maybe an even an hour) and i get something tested that is based on more solid ground ...
BabyDuck is offline   Reply With Quote
Old 27-07-2003, 02:35 PM   #5
Alan
Moderator
 
Alan's Avatar
 
Join Date: Oct 2002
Location: London, UK
Posts: 2,800
Thanks: 0
Thanked 5 Times in 5 Posts
Default

thanks mate, i'm gonna be trying too.
__________________
Technical Director - Framestore

Currently working on: Your Highness

IMDB
Alan is offline   Reply With Quote
Old 27-07-2003, 02:53 PM   #6
Alan
Moderator
 
Alan's Avatar
 
Join Date: Oct 2002
Location: London, UK
Posts: 2,800
Thanks: 0
Thanked 5 Times in 5 Posts
Default

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... ?
__________________
Technical Director - Framestore

Currently working on: Your Highness

IMDB
Alan is offline   Reply With Quote
Old 27-07-2003, 03:06 PM   #7
BabyDuck
Subscriber
 
BabyDuck's Avatar
 
Join Date: Nov 2002
Location: USA
Posts: 1,170
Thanks: 3
Thanked 12 Times in 12 Posts
Default

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 ???
BabyDuck is offline   Reply With Quote
Old 27-07-2003, 03:07 PM   #8
Alan
Moderator
 
Alan's Avatar
 
Join Date: Oct 2002
Location: London, UK
Posts: 2,800
Thanks: 0
Thanked 5 Times in 5 Posts
Default

ok let me try that
__________________
Technical Director - Framestore

Currently working on: Your Highness

IMDB
Alan is offline   Reply With Quote
Old 27-07-2003, 03:41 PM   #9
Alan
Moderator
 
Alan's Avatar
 
Join Date: Oct 2002
Location: London, UK
Posts: 2,800
Thanks: 0
Thanked 5 Times in 5 Posts
Default

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
__________________
Technical Director - Framestore

Currently working on: Your Highness

IMDB
Alan is offline   Reply With Quote
Old 27-07-2003, 03:44 PM   #10
BabyDuck
Subscriber
 
BabyDuck's Avatar
 
Join Date: Nov 2002
Location: USA
Posts: 1,170
Thanks: 3
Thanked 12 Times in 12 Posts
Default

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 ...
BabyDuck is offline   Reply With Quote
Old 27-07-2003, 03:50 PM   #11
Alan
Moderator
 
Alan's Avatar
 
Join Date: Oct 2002
Location: London, UK
Posts: 2,800
Thanks: 0
Thanked 5 Times in 5 Posts
Default

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
__________________
Technical Director - Framestore

Currently working on: Your Highness

IMDB
Alan is offline   Reply With Quote
Old 27-07-2003, 04:21 PM   #12
BabyDuck
Subscriber
 
BabyDuck's Avatar
 
Join Date: Nov 2002
Location: USA
Posts: 1,170
Thanks: 3
Thanked 12 Times in 12 Posts
Default

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 is offline   Reply With Quote
Old 27-07-2003, 04:24 PM   #13
BabyDuck
Subscriber
 
BabyDuck's Avatar
 
Join Date: Nov 2002
Location: USA
Posts: 1,170
Thanks: 3
Thanked 12 Times in 12 Posts
Default

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

but if you render out a bigger project, it is not economically at all to have maya eat up resources while you render ...
BabyDuck is offline   Reply With Quote
Old 27-07-2003, 04:25 PM   #14
Alan
Moderator
 
Alan's Avatar
 
Join Date: Oct 2002
Location: London, UK
Posts: 2,800
Thanks: 0
Thanked 5 Times in 5 Posts
Default

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
__________________
Technical Director - Framestore

Currently working on: Your Highness

IMDB
Alan is offline   Reply With Quote
Old 27-07-2003, 04:29 PM   #15
BabyDuck
Subscriber
 
BabyDuck's Avatar
 
Join Date: Nov 2002
Location: USA
Posts: 1,170
Thanks: 3
Thanked 12 Times in 12 Posts
Default

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
BabyDuck is offline   Reply With Quote
Reply


Similar Threads
Thread Thread Starter Forum Replies Last Post
Batch Rending Render Layers Ozgalis Lighting & Rendering 7 07-01-2011 07:04 PM

Thread Tools





A little bit about who we are
Links you might find useful
Catch up with SimplyMaya
SimplyMaya specialises in Maya tutorials. We offer over 1,000 individual Maya training videos, ranging from basic Maya tutorials through to intermediate Maya tutorials. Our tutorials are created by instructors with industry experience and are designed to get you up and running in Maya quickly without making it seem like hard work.

Copyright © 1999-2015 SimplyMaya - vBulletin® Copyright © 2000-2015, Jelsoft Enterprises Ltd.