Substance Painter
In this start to finish texturing project within Substance Painter we cover all the techniques you need to texture the robot character.
# 1 30-05-2003 , 06:15 AM
olivermagno's Avatar
Registered User
Join Date: Mar 2003
Location: Philippines
Posts: 94

camera filmback mel

hi there,

iam writing a simple script that will change the filmback settings of the camera and the settings of the render globals, so i have a global proc.
and here is the mel:

global proc cameraSetUp ()
{

select perspShape;
setAttr perspShape.horizontalFilmAperture 0.85;
setAttr perspShape.verticalFilmAperture 0.466;
setAttr perspShape.lensSqueezeRatio 1.0;
setAttr defaultResolution.aspectLock true;
setAttr defaultResolution.width 2048;
setAttr defaultResolution.height 1108;
camera -e -displayFilmGate on -displayResolution off -filmFit fill -displaySafeAction on -overscan 1.3 persp;

}

all of the settings in the render globals works fine,
but the filmback of the camera did not change, no error in the script editor.
then i checked the AEcameraFilmbackNew.mel and saw that the script is executing the default filmback attribute of the camera.

THE QUESTION IS: HOW CAN I MAKE THE DEFAULT FILMBACK SETTING OF THE CAMERA'S FILMGATE TO "35mm 1.85 projection"? IS THERE SOMETHING MISSING IN MY SCRIPT?

thanx for the help.

user added image


------------------------------------------------
our decisions-not the conditions of our lives
determine our destiny.
# 2 03-06-2003 , 09:09 AM
Hugh's Avatar
Registered User
Join Date: Nov 2002
Location: Bristol, UK
Posts: 25
If you check the Script Editor when you change this (with Echo All Commands turned on), you'll see that changing the 'Film Gate' only calls AE... functions - (AE functions are for changing things in the Attribute Editor)

In the code that comes up for me, the following variables are mentioned:
perspShape.horizontalFilmAperture
perspShape.verticalFilmAperture
perspShape.lensSqueezeRatio
perspShape.focalLength

So the variables in here are the only ones that you need to change to set it up - the drop down box itself just tells it to set these variables to a group of presets.


Hugh Macdonald

UnFramed Productions
Goodnight Opus - TD Lead

VFXTalk.com - Online Compositing Community - Admin

Last edited by Hugh; 03-06-2003 at 09:12 AM.
# 3 04-06-2003 , 12:12 PM
olivermagno's Avatar
Registered User
Join Date: Mar 2003
Location: Philippines
Posts: 94
gotcha hugh, thanx.

one more thing,

if an object was declared as string e.g. string $camera [] = `ls -sl`; and we now tha some of the camera attributes has a boolean data type,

how should i shift from string to boolean?


------------------------------------------------
our decisions-not the conditions of our lives
determine our destiny.
# 4 04-06-2003 , 01:48 PM
kbrown's Avatar
Moderator
Join Date: Sep 2002
Location: London, UK
Posts: 3,198
`ls -sl`will return names of all selected objects. In your example you are storing the names in a string array. To get a value of an attribute of some selected object you use the getAttr command. An example:

Let's say we want to find out if a poly object (a mesh) called myObjectShape is in the selection and if it's displayVertices attribute is set.

Code:
string $sSel[] = `ls -sl -dag -typ mesh`;	// Notice the use of -dag and -typ switches.
						// Normally you're only selecting transform nodes in the Maya view ports.
						// The -dag is used to list all the shape nodes (among other things) as well.
						// We're only interested in mesh objects so with the -typ mesh we'll limit the
						// ls command to list meshes only in the selection
int $iSize = size($sSel), $i;

if($iSize > 0)
{
	for($i = 0; $i < $iSize; $i++)
	{
		if($sSel[$i] == "myObjectShape")
		{
			// By looking in to the DG Node reference we know that the .dv attribute is a boolean.
			// However we define booleans as integers because there is no bool type in mel.

			int $bDv = `getAttr ($sSel[$i] + ".dv")`; // Now the $bDv variable contains the value of myObjectShape.dv

			// Let's find out if it's set
			if($bDv)
			{
				print("myObjectShape.dv is on\n");
				// <Do other stuff what needs to be done if the attribute is set>
			}
			else
			{
				print("myObjectShape.dv is off\n");
				// <Do other stuff what needs to be done if the attribute is not set>
			}
		}
		else
			warning("myObjectShape could not be found in the selection!\n");
	}
}
else
{
	warning("Nothing selected...\n");
}
Not sure if this is a good example. Lemme know if there's something that needs to be clarified more elaborately.


Kari
- My Website
- My IMDB

Do a lot, Fail a lot and Learn a lot!

Last edited by kbrown; 04-06-2003 at 01:51 PM.
# 5 05-06-2003 , 12:04 AM
mark_wilkins's Avatar
Registered User
Join Date: Jan 2003
Posts: 161
AAAAAAAAA!!!!! MY EYES!!!!

ok I removed the comments just for brevity, but not as a style comment.

Once again, a "for-in" loop will clean this puppy right up, and some curly-brackets have been removed:


Code:
string $sSel[] = `ls -sl -dag -typ mesh`;	
string $currSelection;

for ($currSelection in $sSel)
	{
		if($currSelection == "myObjectShape")
		{

			int $bDv = `getAttr ($currSelection + ".dv")`;

			if($bDv)
				print("myObjectShape.dv is on\n");
			else
				print("myObjectShape.dv is off\n");
		}
		else
			warning("myObjectShape could not be found in the selection!\n");
}
else
	warning("Nothing selected...\n");
-- Mark


Mark R. Wilkins
author of MEL Scripting for Maya Animators
www.melscripting.com

Last edited by mark_wilkins; 05-06-2003 at 06:19 PM.
# 6 05-06-2003 , 07:33 AM
Hugh's Avatar
Registered User
Join Date: Nov 2002
Location: Bristol, UK
Posts: 25
Mark: what's the difference between:

foreach($currSelection in $sSel)

and

for($currSelection in $sSel)

?


Hugh Macdonald

UnFramed Productions
Goodnight Opus - TD Lead

VFXTalk.com - Online Compositing Community - Admin
# 7 05-06-2003 , 09:14 AM
kbrown's Avatar
Moderator
Join Date: Sep 2002
Location: London, UK
Posts: 3,198
Didn't know you can write:
Code:
foreach($foo in $bar)
	// blah blah
else
	// blah blah
Gonna try to remember that...

Thanks.


Kari
- My Website
- My IMDB

Do a lot, Fail a lot and Learn a lot!
# 8 05-06-2003 , 11:04 AM
olivermagno's Avatar
Registered User
Join Date: Mar 2003
Location: Philippines
Posts: 94
thanx to you guys, this is a kind of great help for my
first little script.

so what is the type for the on and off of the resoution gate of the camera?


------------------------------------------------
our decisions-not the conditions of our lives
determine our destiny.

Last edited by olivermagno; 05-06-2003 at 11:54 AM.
# 9 05-06-2003 , 04:52 PM
Hugh's Avatar
Registered User
Join Date: Nov 2002
Location: Bristol, UK
Posts: 25
What's the MEL command to turn it off, you mean? Cos the type is a bool....

The command is:

camera -e -displayFilmGate $filmGate -displayResolution $resGate -overscan $overscan $camName;

where $filmGate and $resGate are booleans (true/on/1 or false/off/0), $overscan is a float and $camName is the name of the camera.


Hugh Macdonald

UnFramed Productions
Goodnight Opus - TD Lead

VFXTalk.com - Online Compositing Community - Admin
# 10 05-06-2003 , 06:19 PM
mark_wilkins's Avatar
Registered User
Join Date: Jan 2003
Posts: 161
hahahaha my computer language neurons are screwed up. "foreach" isn't a MEL thing, it's C-shell.

I've edited my earlier post.

-- Mark


Mark R. Wilkins
author of MEL Scripting for Maya Animators
www.melscripting.com
# 11 06-06-2003 , 02:36 AM
olivermagno's Avatar
Registered User
Join Date: Mar 2003
Location: Philippines
Posts: 94
what i mean hugh is from mark and kbrown's example:

string $sSel[] = `ls -sl -dag -typ mesh`;

i want to be like this for my script:

string $camera[] = `ls -sl -dag -typ ?????`;

i'm just asking for the type so that i can define the booleans as integer, then i'm done with my script.


------------------------------------------------
our decisions-not the conditions of our lives
determine our destiny.
# 12 06-06-2003 , 04:45 AM
mark_wilkins's Avatar
Registered User
Join Date: Jan 2003
Posts: 161
not "-type camera"?

-- Mark


Mark R. Wilkins
author of MEL Scripting for Maya Animators
www.melscripting.com
# 13 07-06-2003 , 03:01 AM
olivermagno's Avatar
Registered User
Join Date: Mar 2003
Location: Philippines
Posts: 94
is this answer ?

string $camera [] = `ls -sl -dag -type camera`;


------------------------------------------------
our decisions-not the conditions of our lives
determine our destiny.
# 14 07-06-2003 , 03:06 AM
mark_wilkins's Avatar
Registered User
Join Date: Jan 2003
Posts: 161
Why not try it and find out?

of course you can always use ls -sl -showType to see what type the selected object is, then use that type as an argument to the -type flag...

-- Mark


Mark R. Wilkins
author of MEL Scripting for Maya Animators
www.melscripting.com
# 15 07-06-2003 , 04:10 AM
olivermagno's Avatar
Registered User
Join Date: Mar 2003
Location: Philippines
Posts: 94
thanx


------------------------------------------------
our decisions-not the conditions of our lives
determine our destiny.
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