PDA

View Full Version : sorry: Layer Visibility


chris.scherer
08-30-2006, 07:52 AM
Hello world,

I am, as always, fully incompatible with the Maya Help system. All I'd like to do is to set the visibility (or other attributes) of a layer to 1 or 0. Watching the Script Editor tells me that I can do a "toggle" all right, and even " layerSetTo Selected".visibility" "to a value, but I cannot find any hint on this in the help files.

I've tried "layerSetTo "mylayername.visibility" 1;" and others, but none work. I can't find help in the help files. All other threads that might have answered this are closed down with no conclusive answer or point to dead links.

Thanks world

Andimation
08-30-2006, 08:02 AM
Just use the setAttr command -

setAttr layer1.visibility 1;

Andy

chris.scherer
08-30-2006, 10:19 AM
Thanks a lot. Of course, the setAttr command...

As always I just figured it out myself about 5 minutes before my mailbox rang.

Mikademius
08-31-2006, 08:28 AM
What you do when you wonder how things like that work:

step1: Turn on echo all commands in the scriptEditor.
step2: Do the action (click the V for a layer) to see what the scriptEditor prints out.
step3: Copy the proc (in this case "layerEditorLayerButtonVisibilityChange")...Long proc :) and copy it from the history field to your scriptField. Then add "whatIs" in front (without quotes)

whatIs layerEditorLayerButtonVisibilityChange;

step4:Maya prints:

// Result: Mel procedure found in: C:/Program Files/Alias/Maya7.0/scripts/startup/layerEditor.mel //


step5: Open the layerEditor.mel file and search for the proc. Then you find this:

global proc layerEditorLayerButtonVisibilityChange(string $layer)
//
// Description:
// This procedure is called whenever the user presses the visibility
// indicator in a display layer button.
//
// Toggle the visibility of the layer.
//
// Arguments:
// $layer - The layer.
//
{
int $visible = `getAttr ($layer + ".visibility")`;

if (0 == $visible) $visible = true;
else $visible = false;

setAttr ($layer + ".visibility") $visible;
}


Here you can easily see that if you extract the bottom line there, you just scored a goal in the world of mel;)

CGTalk Moderation
08-31-2006, 08:28 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.