PDA

View Full Version : MEL: query selected/highlighted display layers ?


deadalvs
02-02-2011, 04:16 PM
hi !

I am trying to get a list of all display layers which are hightlighted / selected. One of them of course can be the "CDL", but I need all of them which are highlighted. (independent of their visibility setting !)

any input on this ? thanks in advance !

deadalvs
02-02-2011, 04:27 PM
as usual - no matter how long you search - you will find the answer two minutes after you post on a forum .. murphy.

code here.
the two procedures are from the layerEditor.mel in the maya startup scripts (provided by autodesk)

$type = getLayerDisplayType(); $currentSelection = getLayerSelection($type);
proc string getLayerDisplayType()
//
// Description:
// Return the current type of layer being displayed in the
// Layer Editor.
//
// Returns:
// "Display" or "Render" or "Anim"
//
{
global string $gCurrentLayerEditor;
// Verify the current layer editor.
//
if ("" == $gCurrentLayerEditor) {
error (uiRes("m_layerEditor.kNoLayerEditor"));
return "";
}
// Set the parent to the current layer editor. We can now use short
// names of our controls and be certain they reference the correct
// control.
//
setParent $gCurrentLayerEditor;
// Get the current type of layers being displayed.
//
string $type = `tabLayout -query -selectTab DisplayLayerUITabLayout`;
//to match previous behavior, return just the name, not the full control name
if ($type == "DisplayLayerTab") return "Display";
else if($type == "AnimLayerTab") return "Anim";
return "Render";
}
global proc string [] getLayerSelection(string $type)
//
// Description:
// Return the current layer selection for the specified layer type.
//
// Arguments:
// $type - Valid values are: "Display", "Render", or
// an emtpy string. In the case of an empty string the
// current layer type displayed in the editor will be used.
//
// Returns:
// A string array containing the names of the selected layers.
//
{
global string $gCurrentLayerEditor;
string $selectionArray[];
string $buttonLayout = "", $button, $buttonArray[];
int $index = 0;
// If type argument not specified then determine it.
//
if ("" == $type) {
$type = getLayerDisplayType();
}
// Set the parent to the current layer editor. We can now use short
// names of our controls and be certain they reference the correct
// control.
//
setParent $gCurrentLayerEditor;
// Get the correct layout of layer buttons depending on the type of
// layers currently being shown.
//
if ("Display" == $type) {
// Get all the buttons in the layout.
//
$buttonArray = `layout -query -childArray LayerEditorDisplayLayerLayout`;
// For each button check to see if it is selected.
//
for ($button in $buttonArray) {
if ("Display" == $type && `layerButton -query -select $button`) {
$selectionArray[$index++] = $button;
}
}
} else {
string $errMsg = (uiRes("m_layerEditor.kInvalidLayerType"));
string $errDisp = `format -s $type $errMsg `;
error ($errDisp);
return $selectionArray;
}
return $selectionArray;
}

CGTalk Moderation
02-02-2011, 04:27 PM
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.