PDA

View Full Version : Render from the gui script ?


MikeBracken
10-13-2011, 06:20 PM
I have an unusual request. I have a scene file that will not render correctly when batched. It does, however, render just fine in the gui. We were given this file by the client. We have been trouble shooting it for 3 days now with no success. I have zero scripting experiance.

Could someone, anyone, write or share a script that can batch render the gui ? I read about someone doing just that, here on CGtalk. I have searched everywhere for such a script, but cant find anything.

I am not usually one to ask for things like this, but as the deadline looms I am getting desperate.

Regards,
Mike

dbsmith
10-13-2011, 08:14 PM
What exactly do you mean "does not render correctly"?
Have you tried stripping away scene elements until it DOES render properly in order to determine the problem?

In any case, here's some code that may help you.
Obviously you want to switch the settings for your own.
- Change the number of frames in your sequence
- Change the name of your camera
- Change myFilename to be where you want the files saved to
You may need to check the maya docs for the render command to do more specific stuff (or post here of course!)

One small snag is when it saves out the images, it asks you if you want to overwrite the image for every single image. Thus, delete the images first before rendering, or render to a new path every time.


editor = 'renderView'

# Settings
numFrames = 100
myCamera = 'persp'
myFilename = 'E:/Temp/Temp'

for i in xrange(numFrames):
maya.cmds.currentTime(i)
maya.cmds.render()
maya.cmds.renderWindowEditor(editor, e=True, currentCamera=myCamera, writeImage=myFilename + '%04d' % i)

MikeBracken
10-13-2011, 08:23 PM
Thanks a million. Testing now.

Yes, we have been in and out of this file for weeks.

Regards,
Mike

MikeBracken
10-13-2011, 08:29 PM
I get a syntax error for line one....


Error: editor = 'renderView'

//

// Error: Syntax error //

Im on Maya 2008, and rendering in mentalray if that helps.

Regards,
Mike

shcmack
10-13-2011, 08:34 PM
Thanks a million. Testing now.

Yes, we have been in and out of this file for weeks.

Regards,
Mike
Have you tried rendering it from the command prompt?

I fumbler together a quick and dirty MEL script before I saw dbsmith posted a script for you, bet you don't need it, but what the heck :p

//Define the start-frame and the end-frame
int $startFrame = 1;
int $endFrame = 20;

//For each frame within the range specified
for($a = $startFrame; $a < $endFrame; $a++)
{
//Set the time to the current frame
currentTime $a;
//Render the camera "persp"
string $renderOutput = `render persp`;
//Print information
print ("\nRendered frame " + $a + ": ");
print $renderOutput;
}

Oh, and if you want to define a layer you just use this command instead:
string $renderOutput = `render -layer layer1 persp`;

MikeBracken
10-13-2011, 08:53 PM
We tried to batch with the command promt. I am a lighting/shading guy. Our maya guy has been trying to track dow the problems in this file.
I keep hearing "nested zero point scale". Not to mention EVERY surface/object is made from nubs. It is an animation of a couch being put together. This file was obviously created by a noob.
Everytime we think we have found the problem and try to batch, another problem pops up. It is really ugly.

Thanks for the help. Going to test your script now.

Regards,
Mike

dbsmith
10-13-2011, 09:03 PM
I'd say you're getting an error from my script Mike because you are trying to run it in a MEL tab (not a Python tab).

In the script editor, if you dont already have a Python tab open, go Command > New Tab > Python

I hope this works in 2008 as I am testing it in 2009 though...

dbsmith
10-13-2011, 09:10 PM
Here's an updated script for Mental Ray rendering:
It will output to whereever your maya project settings images folder is (last print line in the code will say where the files went)

Remember to run it in a Python tab in the script editor, not a MEL tab!


editor = 'renderView'

# Settings
numFrames = 10
myCamera = 'persp'

for i in xrange(numFrames):
maya.cmds.currentTime(i)
maya.cmds.Mayatomr(preview=True, camera=myCamera)

print maya.cmds.Mayatomr(preview=True, camera=myCamera)

MikeBracken
10-13-2011, 09:15 PM
Thanks for the reply db. We ran it both ways. This is the error from python....

# IndentationError: unexpected indent #

Regards,
Mike

Edit....Looks like its working....will let you know.

MikeBracken
10-13-2011, 09:29 PM
Thanks ! The script is working. The only problem is how to set a frame range. We need to render alot of different ranges, like 1326 through 1380. Any ideas ?


Thanks again for your help.

Regards,
Mike

dbsmith
10-13-2011, 09:35 PM
That should do it.
The indent error is just making sure the 2 lines of code under the "for i..." line are indented in the maya script editor. Just delete the spacing in front, and press tab I guess.


editor = 'renderView'

# Settings
startFrame = 1326
endFrame = 1380
myCamera = 'persp'
myFilename = 'E:/Temp/Temp'

for i in xrange(startFrame, endFrame + 1):
maya.cmds.currentTime(i)
maya.cmds.Mayatomr(preview=True, camera='persp')

print maya.cmds.Mayatomr(preview=True, camera='persp')

MikeBracken
10-13-2011, 09:58 PM
Thanks a million ! You have saved my a**. I dont know how I can thank you.


Regards,
Mike

dbsmith
10-13-2011, 10:09 PM
No worries man, that's what these forums are all about!
:D

CGTalk Moderation
10-13-2011, 10:09 PM
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.