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 30-05-2003, 07:15 AM   #1
olivermagno
Registered User
 
olivermagno's Avatar
 
Join Date: Mar 2003
Location: Philippines
Posts: 94
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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.

__________________
------------------------------------------------
our decisions-not the conditions of our lives
determine our destiny.
olivermagno is offline   Reply With Quote
Old 03-06-2003, 10:09 AM   #2
Hugh
Registered User
 
Hugh's Avatar
 
Join Date: Nov 2002
Location: Bristol, UK
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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 10:12 AM.
Hugh is offline   Reply With Quote
Old 04-06-2003, 01:12 PM   #3
olivermagno
Registered User
 
olivermagno's Avatar
 
Join Date: Mar 2003
Location: Philippines
Posts: 94
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.
olivermagno is offline   Reply With Quote
Old 04-06-2003, 02:48 PM   #4
kbrown
Moderator
 
kbrown's Avatar
 
Join Date: Sep 2002
Location: London, UK
Posts: 3,198
Thanks: 0
Thanked 8 Times in 8 Posts
Default

`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 02:51 PM.
kbrown is offline   Reply With Quote
Old 05-06-2003, 01:04 AM   #5
mark_wilkins
Registered User
 
mark_wilkins's Avatar
 
Join Date: Jan 2003
Posts: 161
Thanks: 0
Thanked 1 Time in 1 Post
Default

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 07:19 PM.
mark_wilkins is offline   Reply With Quote
Old 05-06-2003, 08:33 AM   #6
Hugh
Registered User
 
Hugh's Avatar
 
Join Date: Nov 2002
Location: Bristol, UK
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
Hugh is offline   Reply With Quote
Old 05-06-2003, 10:14 AM   #7
kbrown
Moderator
 
kbrown's Avatar
 
Join Date: Sep 2002
Location: London, UK
Posts: 3,198
Thanks: 0
Thanked 8 Times in 8 Posts
Default

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!
kbrown is offline   Reply With Quote
Old 05-06-2003, 12:04 PM   #8
olivermagno
Registered User
 
olivermagno's Avatar
 
Join Date: Mar 2003
Location: Philippines
Posts: 94
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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 12:54 PM.
olivermagno is offline   Reply With Quote
Old 05-06-2003, 05:52 PM   #9
Hugh
Registered User
 
Hugh's Avatar
 
Join Date: Nov 2002
Location: Bristol, UK
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
Hugh is offline   Reply With Quote
Old 05-06-2003, 07:19 PM   #10
mark_wilkins
Registered User
 
mark_wilkins's Avatar
 
Join Date: Jan 2003
Posts: 161
Thanks: 0
Thanked 1 Time in 1 Post
Default

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
mark_wilkins is offline   Reply With Quote
Old 06-06-2003, 03:36 AM   #11
olivermagno
Registered User
 
olivermagno's Avatar
 
Join Date: Mar 2003
Location: Philippines
Posts: 94
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.
olivermagno is offline   Reply With Quote
Old 06-06-2003, 05:45 AM   #12
mark_wilkins
Registered User
 
mark_wilkins's Avatar
 
Join Date: Jan 2003
Posts: 161
Thanks: 0
Thanked 1 Time in 1 Post
Default

not "-type camera"?

-- Mark
__________________
Mark R. Wilkins
author of MEL Scripting for Maya Animators
www.melscripting.com
mark_wilkins is offline   Reply With Quote
Old 07-06-2003, 04:01 AM   #13
olivermagno
Registered User
 
olivermagno's Avatar
 
Join Date: Mar 2003
Location: Philippines
Posts: 94
Thanks: 0
Thanked 0 Times in 0 Posts
Default

is this answer ?

string $camera [] = `ls -sl -dag -type camera`;
__________________
------------------------------------------------
our decisions-not the conditions of our lives
determine our destiny.
olivermagno is offline   Reply With Quote
Old 07-06-2003, 04:06 AM   #14
mark_wilkins
Registered User
 
mark_wilkins's Avatar
 
Join Date: Jan 2003
Posts: 161
Thanks: 0
Thanked 1 Time in 1 Post
Default

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
mark_wilkins is offline   Reply With Quote
Old 07-06-2003, 05:10 AM   #15
olivermagno
Registered User
 
olivermagno's Avatar
 
Join Date: Mar 2003
Location: Philippines
Posts: 94
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanx
__________________
------------------------------------------------
our decisions-not the conditions of our lives
determine our destiny.
olivermagno is offline   Reply With Quote
Reply


Similar Threads
Thread Thread Starter Forum Replies Last Post
MEL headache! happymat27 Members Lounge 5 05-12-2010 09:43 AM
MEL headache!! happymat27 Mel Scripts & Programming 1 03-12-2010 04:41 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.