PDA

View Full Version : settings up renderSettings with MEL


moomoor82
01-30-2011, 07:14 PM
Hey guys,
I don't know Mel or Python and I'm trying to write something super basic that does this:

1. sets up the render settings
2. references a light rig in the scene
3. saves the file in a separate folder.

Since I don't know anything about MEL I just turned on echo commands and started copy pasting but unfortunately i could'nt get everything.

this is what I have so far: yellow means I don't know how to do it.


//--------Settings up the renderSettings------------//

setAttr "defaultRenderGlobals.currentRenderer" -type "string" "mentalRay";

My maya file is called proj_101_001_001.ma and I want the output name to be the same proj_101_001_001.#.tga ( I have no idea to force maya to read the file name and put it in the output name)

setAttr "defaultRenderGlobals.imageFormat" 19;

I don't know how to force maya to turn on name.#.ext

setAttr "defaultRenderGlobals.extensionPadding" 4;

I don't know how to force maya to use this camera: name of the camera

setAttr ($plress[0]+".width") 864;
setAttr ($plress[0]+".height") 486;

I don't know how to force maya to render the images in a specific window.
Ideally it should understand where it opened the file from, go there, 1 directory up, and then in the RNDR folder.



//------------Referencing the LightRig------------//

file -r -type "mayaAscii" -gl -loadReferenceDepth "all" -namespace "lightRig_v001" -options "v=0;p=17" "S:/Ep_000/Light_Rig/lightRig_v001.ma";


//------------Saving the file in a separate folder ------------//

I don't know how to force maya to save a new file in the Lighting folder:
where it opened the file from, 1 directory up, and in the LGT folder.




I'm so sorry, I'm stupid. This is probably something super simple but I have no idea how to do it.

I really appreciate your helpppp
thankssssss

dushyantk
01-31-2011, 07:18 AM
Hey guys,
I don't know Mel or Python and I'm trying to write something super basic that does this:

1. sets up the render settings
2. references a light rig in the scene
3. saves the file in a separate folder.

Since I don't know anything about MEL I just turned on echo commands and started copy pasting but unfortunately i could'nt get everything.

this is what I have so far: yellow means I don't know how to do it.


//--------Settings up the renderSettings------------//

setAttr "defaultRenderGlobals.currentRenderer" -type "string" "mentalRay";

My maya file is called proj_101_001_001.ma and I want the output name to be the same proj_101_001_001.#.tga ( I have no idea to force maya to read the file name and put it in the output name)

setAttr "defaultRenderGlobals.imageFormat" 19;

I don't know how to force maya to turn on name.#.ext

setAttr "defaultRenderGlobals.extensionPadding" 4;

I don't know how to force maya to use this camera: name of the camera

setAttr ($plress[0]+".width") 864;
setAttr ($plress[0]+".height") 486;

I don't know how to force maya to render the images in a specific window.
Ideally it should understand where it opened the file from, go there, 1 directory up, and then in the RNDR folder.



//------------Referencing the LightRig------------//

file -r -type "mayaAscii" -gl -loadReferenceDepth "all" -namespace "lightRig_v001" -options "v=0;p=17" "S:/Ep_000/Light_Rig/lightRig_v001.ma";


//------------Saving the file in a separate folder ------------//

I don't know how to force maya to save a new file in the Lighting folder:
where it opened the file from, 1 directory up, and in the LGT folder.




I'm so sorry, I'm stupid. This is probably something super simple but I have no idea how to do it.

I really appreciate your helpppp
thankssssss

Here are few solutions in RED, I love red. :deal:

//--------Settings up the renderSettings------------//

setAttr "defaultRenderGlobals.currentRenderer" -type "string" "mentalRay";


//Setting the Directory here itself
$fileName = `file -q -sn`;
$imName = `basenameEx($fileName)`;
string $baseName = basename( $fileName, "" );
string $dirName = `substitute $baseName $fileName ""`;
string $buffer[];
$numTokens = `tokenize $dirName "//" $buffer`;
int $lastDirIndex = `size($buffer)`-1;
stringArrayRemoveAtIndex($lastDirIndex, $buffer);

string $oneUp = stringArrayToString($buffer, "/");
string $renderPath = ($oneUp + "/RNDR/" + $imName);

///////////////////////////////////////////////////////////////////////////
setAttr -type "string" defaultRenderGlobals.imageFilePrefix ($renderPath);
I'm not changing the IMAGE field, because that will mess-up with your workspace.mel/Project settings. Cheers!!!

setAttr "defaultRenderGlobals.imageFormat" 19;

setAttr defaultRenderGlobals.outFormatControl 0;
setAttr defaultRenderGlobals.animation 1;
setAttr defaultRenderGlobals.putFrameBeforeExt 1;

setAttr "defaultRenderGlobals.extensionPadding" 4;

setAttr "frontShape.renderable" 0;
setAttr "perspShape.renderable" 0; //DEPENDS IF YOU WANT TO TURN THESE OFF
setAttr "sideShape.renderable" 0;
setAttr "topShape.renderable" 0;

setAttr "cam1Shape.renderable" 1; //YOUR CAM NAME GOES HERE

setAttr ($plress[0]+".width") 864;
setAttr ($plress[0]+".height") 486;




//------------Referencing the LightRig------------//

file -r -type "mayaAscii" -gl -loadReferenceDepth "all" -namespace "lightRig_v001" -options "v=0;p=17" "S:/Ep_000/Light_Rig/lightRig_v001.ma";


//------------Saving the file in a separate folder ------------//

I don't know how to force maya to save a new file in the Lighting folder:
where it opened the file from, 1 directory up, and in the LGT folder.
Check the code where I'm setting the render directory, you can use the same concept here...

dushyantk
01-31-2011, 07:20 AM
And here the useful command that will solve most of you further queries:

string $globals[] = `listAttr defaultRenderGlobals`;
$globals = `sort $globals`;
print $globals;
:beer:

moomoor82
01-31-2011, 04:00 PM
Thank you so much for your help. It was very helpful.
I just forgot to mention how do I setup the start/end frames in the render settings based on the file's timeline.
so the script should find out what the timeline's set to and set the start/end frames.

alsooooo How do I type the save as command?

Thank you sooooooooooo muchhhh

dushyantk
02-01-2011, 05:36 AM
And here the useful command that will solve most of you further queries:

string $globals[] = `listAttr defaultRenderGlobals`;
$globals = `sort $globals`;
print $globals;
:beer:

did you actually try this? I really doubt, coz everything's here.

setAttr "defaultRenderGlobals.endFrame" 30;
setAttr "defaultRenderGlobals.startFrame" 10;

There's no saveAs command, go through documentation and look for file command..

... :surprised

moomoor82
02-01-2011, 06:20 AM
I did look at the list, but the thing is I don't want to type in numbers for star/end frames manually. I want maya to look at the timeline and type in those numbers automatically. I have different files with different lengths.
I know what you mean but i just don't know the actual commands/words:
setAttr "defaultRenderGlobals.endFrame" // = playbackEnd
setAttr "defaultRenderGlobals.startFrame" //= playbackStart
I'm so sorry, i know i'm making you angry with my stupid questions but I have no experience with MEL.

Thanks again

dushyantk
02-01-2011, 07:18 AM
Try these:

playbackOptions -q -min;
playbackOptions -q -max;

playbackOptions -q -animationStartTime;
playbackOptions -q -animationEndTime;

assign desired value to a variable, and then put it in renderStart/end.

Do let me know when you are finished with Save AS operation. :wip:

moomoor82
02-01-2011, 07:38 AM
cool, thank you. I'll try them when i go back to work tomorrow morning ( its 2:30 a.m now )
what was driving me crazy the most today was assigning a shader to certain objects in a specific render layer.
i want to create a MATTE pass that contains a few objects.
some of them are black and some white.
so using MEL i created a render layer called MATTES and also created 2 surfaceShaders. 1 is black and the other one is white. the problem is when i assign them to the specific objects all my layers will receive that. I need the command for object override.
BELIEVE IT OR NOT THAT IS MY LASTTTTTTT QUESTION ........... U HATE ME ... I KNOW .........
thanksssssssssss a bunch for your help!

dushyantk
02-01-2011, 11:50 AM
layerEditorLayerButtonSelect 0 layer3;
sets -e -forceElement lambert3SG;

seems to work, It works on selected objects only so make sure you select objects, then change renderLayer, then set the shadingGroup. Maybe I'm missing something?

This might not be the best solution, as it takes alot of time during automation !!! Moreover, the same process does not work sometimes when attempted through mel script...
Check if it works for your specific needs! :arteest:

CGTalk Moderation
02-01-2011, 11:50 AM
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.