Home Technical Talk

Mel script: Create a code that works for any cam I have selected

polycounter lvl 2
Offline / Send Message
Fran127 polycounter lvl 2
Hi there!

Right now I am hard-coding a piece of code, and I dont know almost anything about mel (but i am trying)
The thing is I want this code works for any cam i have selected, right now only work if the camara names that way

setAttr "cameraShape1.filmFit" 3;

setAttr "cameraShape1.overscan" 1;

setAttr cameraShape1.displayGateMaskOpacity 1;

setAttr "cameraShape1.displayGateMaskColor" -type double3 0 0 0 ;



Replies

  • throttlekitty
    Options
    Offline / Send Message
    What you'll want to do is use a variable to store the cameraShape name and use string concatenation, like so:

    <div>// Get the name of the currently selected camera transform.
    
    </div><div>string $myCam[] = `ls -sl`;
    
    // We can't be certain of the exact name of the camera Shape node, so let's get it from the transform.
    
    </div><div>string $myCamShape[] = `listRelatives -shapes $myCam`;
    
    </div><div>// listRelatives returns an array, even though the camera has one shape, but let's still use only the first index.
    <br>print myCamShape[0];
    
    </div>setAttr ($myCamShape[0] + ".filmFit") 3;
    
    // Draw the rest of the owl.

  • Fran127
    Options
    Offline / Send Message
    Fran127 polycounter lvl 2
    It works perfect! Than you so much!! :smiley: !! 
Sign In or Register to comment.