Community
Maya Programming
Welcome to Autodesk’s Maya Forums. Share your knowledge, ask questions, and explore popular Maya SDK topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How can we reorder an attribute in the channel box?

5 REPLIES 5
Reply
Message 1 of 6
Anonymous
3322 Views, 5 Replies

How can we reorder an attribute in the channel box?

How can we reorder an attributes in the channel box??

In the past we use to work with the Michael Comet tool scripts... who rename for you the attributes and reorder it as you want!!! up or down!

Now this scripts in Maya 2011 work but don't work!!!! no error during scripts execution.... but do nothing....!!! What have change into 2011 and make it not work???

Here the original comet scripts as examples:
Thanks

// --------------------------------------------------------------------------
// cometAttrEditor.mel - MEL Script
// --------------------------------------------------------------------------
//
// DESCRIPTION:
// A util for dealing with some attribute stuff.
//
// REQUIRES:
// Nothing.
//
//
// USAGE:
// source "cometAttrEditor.mel"; cometAttrEditor();
//
// AUTHORS:
// Michael B. Comet - comet@comet-cartoons.com
// Copyright ©2004 Michael B. Comet - All Rights Reserved.
//
// VERSIONS:
// 1.00 - Aug 27, 2004 - Initial Release.
//
// --------------------------------------------------------------------------


/*
* cometAttrEditor() - Main Entry
*/
global proc cometAttrEditor()
{
if (`window -q -ex cometAttrEditorWin`)
{
showWindow cometAttrEditorWin ;
return ;
}


window -w 230 -h 60 -t "Comet Attr. Editor - 1.00" cometAttrEditorWin ;

formLayout mainForm ;

button -l ("Move UP") -c ("cAE_moveAttrs(0)") -ann ("Slide selected channelBox attributes up.") btnUp ;
button -l ("Move DOWN") -c ("cAE_moveAttrs(1)") -ann ("Slide selected channelBox attributes down.") btnDown ;

formLayout -e

-af btnUp "top" 5
-an btnUp "bottom"
-af btnUp "left" 5
-ap btnUp "right" 0 50

-af btnDown "top" 5
-an btnDown "bottom"
-ap btnDown "left" 0 50
-af btnDown "right" 5

mainForm ;


showWindow cometAttrEditorWin ;

}


// --------------------------------------------------------------------------

/*
* cAE_moveAttrs() - Adjust attrs
*/
global proc cAE_moveAttrs(int $dir)
{

// What objs and attrs are highlighted in the channel box?
string $cbObjs[] = `channelBox -q -mol mainChannelBox` ;
string $cbAttrs[] = `channelBox -q -sma mainChannelBox` ;
int $i;

string $obj ;
for ($obj in $cbObjs)
{
if ($dir == 0) // Work top to bottom if moving up
{
for ($i=0; $i < size($cbAttrs); ++$i)
cAE_moveAttr($obj, $cbAttrs, $dir) ;
}
else if ($dir == 1) // Work bottom to top moving down
{
for ($i=size($cbAttrs)-1; $i >= 0; --$i)
cAE_moveAttr($obj, $cbAttrs, $dir) ;
}

// Must do this or channel box won't refresh.
string $sel[] = `ls -sl -l`;
select -cl ;
refresh ;
select -r $sel ;
}


}


// --------------------------------------------------------------------------

/*
* cAE_moveAttr() - Adjust one attr specified up or down.
* $dir: 0=up 1=down
*/
global proc cAE_moveAttr(string $obj, string $attr, int $dir)
{
string $udAttrs[] = `listAttr -ud $obj` ; // Get just user defined ones.
int $i ;

// First find out where in the order of all the user defined attrs this one is.
int $idx = -1 ;
for ($i=0; $i < size($udAttrs); ++$i)
{
if ($udAttrs == $attr)
{
$idx = $i;
break ;
}
}

// If we couldn't find it, it's not a ud, so ignore, we can't shift.
if ($idx < 0)
{
warning -sl 0 ("Can't shift "+$obj+"."+$attr+" it's not user defined.") ;
return ;
}

print ("// Shifting "+($dir==0 ? "Up" : "Down")+" "+$idx+".) "+$obj+"."+$attr+" //\n") ;

// Now shift as needed
if ($dir == 0 && $idx > 0)
{
cAE_dropToBottom($obj, $udAttrs) ; // First this goes down

cAE_dropToBottom($obj, $udAttrs) ; // Then the one above

// Then do the rest
for ($i=$idx+1; $i < size($udAttrs); ++$i)
{
cAE_dropToBottom($obj, $udAttrs) ;
}
}
else if ($dir == 1 && $idx < size($udAttrs)-1)
{
cAE_dropToBottom($obj, $udAttrs) ; // First the one below goes down

cAE_dropToBottom($obj, $udAttrs) ; // First this goes down

// Then do the rest
for ($i=$idx+2; $i < size($udAttrs); ++$i)
{
cAE_dropToBottom($obj, $udAttrs) ;
}
}

}

// --------------------------------------------------------------------------

/*
* cAE_dropToBottom() - Drop an attr to bottom by rename and back
*/
global proc cAE_dropToBottom(string $obj, string $attr)
{
renameAttr ($obj+"."+$attr) ($attr+"TEMPREN") ; // there
renameAttr ($obj+"."+$attr+"TEMPREN") ($attr) ; // and back again
}

// --------------------------------------------------------------------------

cometAttrEditor;
5 REPLIES 5
Message 2 of 6
Anonymous
in reply to: Anonymous

cAE_dropToBottom broke in 2011 because it relies on Maya moving a renamed attribute to the bottom of the list. That no longer works. It's easy to fix because there's still another way of moving an attribute to the bottom; deleting and undoing the deletion. You can fix cAE_dropToBottom as follows:

global proc cAE_dropToBottom(string $obj, string $attr)
{
// renameAttr ($obj+"."+$attr) ($attr+"TEMPREN") ; // there
// renameAttr ($obj+"."+$attr+"TEMPREN") ($attr) ; // and back again
deleteAttr -attribute $attr $obj;
Undo;
}
Message 3 of 6
Anonymous
in reply to: Anonymous

http://0volts.iftopic.com/t9-maya-attribute-reorder-2011
this script is working perfect! in maya 2011 and 2012
Message 4 of 6
Anonymous
in reply to: Anonymous

http://0volts.iftopic.com/t9-maya-attribute-reorder-2011
this script is working perfect! in maya 2011 and 2012
Message 5 of 6
trs_andre
in reply to: Anonymous

Can't find the Download link for this script, is it working? And is it only for user created attributes or for the ones who come by default such as visibility?

André Moreira

Game Developer / Technical Artist

LinkedIn

Message 6 of 6
Anonymous
in reply to: Anonymous

You can try it with this tool too: https://github.com/jlararigger/jlr_sort_attributes
You only have to select one or several attributes in the channel box and in the Edit menu of the channel box choose Move Up Attr or Move Down Attr.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report