SimplyMaya Forums

Welcome to the forum, feel free to ask questions here.

Home / forum / Animation / Mel Scripts & Programming / camera filmback mel
Register FAQ Members List Calendar Mark Forums Read

New Thread
 
Thread Tools
Old 30-05-2003, 06: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, 09: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 09:12 AM.
Hugh is offline   Reply With Quote
Old 04-06-2003, 12: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, 01: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 01:51 PM.
kbrown is offline   Reply With Quote
Old 05-06-2003, 12: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 06:19 PM.
mark_wilkins is offline   Reply With Quote
Old 05-06-2003, 07: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, 09: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, 11:04 AM   #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 11:54 AM.
olivermagno is offline   Reply With Quote
Old 05-06-2003, 04: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, 06: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, 02: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, 04: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, 03: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, 03: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, 04: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
New Thread

« Previous Thread | Next Thread »

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
MEL headache! happymat27 Members Lounge 5 05-12-2010 08:43 AM
MEL headache!! happymat27 Mel Scripts & Programming 1 03-12-2010 03:41 PM

1 Month

$34

Month-to-month billing
$34/month
Unlimited access to all videos
Project files to download
Easy to cancel at anytime
 
 

3 months

$87

Billing every 3 months
$29/month
Unlimited access to all videos
Project files to download
Easy to cancel at anytime
Save $5 per month or $15 in total compared to monthly billing with this package.

12 months

$288

Billing every 12 months
$24/month
Unlimited access to all videos
Project files to download
Easy to cancel at anytime
Save $10 per month or $120 in total compared to monthly billing with this package.

Your plan will automatically renew. You can cancel at any time via your PayPal account to avoid being charged again.

You can view the FAQ on our video plans here. You can contact us directly here. By clicking one of the buttons above, you agree to our Terms and Privacy Policy.