Simply Maya User Community

Simply Maya User Community (https://simplymaya.com/forum/index.php)
-   Programming (https://simplymaya.com/forum/forumdisplay.php?f=32)
-   -   camera filmback mel (https://simplymaya.com/forum/showthread.php?t=6026)

olivermagno 30-05-2003 06:15 AM

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.

:rolleyes:

Hugh 03-06-2003 09:09 AM

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.

olivermagno 04-06-2003 12:12 PM

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?

kbrown 04-06-2003 01:48 PM

`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.

mark_wilkins 05-06-2003 12:04 AM

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

Hugh 05-06-2003 07:33 AM

Mark: what's the difference between:

foreach($currSelection in $sSel)

and

for($currSelection in $sSel)

?

kbrown 05-06-2003 09:14 AM

Didn't know you can write:
Code:

foreach($foo in $bar)
        // blah blah
else
        // blah blah

Gonna try to remember that...

Thanks.

olivermagno 05-06-2003 11:04 AM

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?

Hugh 05-06-2003 04:52 PM

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.

mark_wilkins 05-06-2003 06:19 PM

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

olivermagno 06-06-2003 02:36 AM

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.

mark_wilkins 06-06-2003 04:45 AM

not "-type camera"?

-- Mark

olivermagno 07-06-2003 03:01 AM

is this answer ?

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

mark_wilkins 07-06-2003 03:06 AM

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

olivermagno 07-06-2003 04:10 AM

thanx


All times are GMT. The time now is 03:19 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Simply Maya 2018