PDA

View Full Version : Querying long names of selected channels.


dwalden74
07-21-2003, 03:56 PM
Hi guys-

I have to match selected channelbox channels (`channelBox -q -sma`) with attribute names read in from a text file. The attributes in the text file are in their long-name form("translateX", "rotateZ" ...). However, querying the selected channels using the `channelBox`command only returns the channelsī short names ("tx", "rz" ...). Therefore the strings will not be equal each other (Iīm using "if ($textFileAttr == $selectedChannelAttr)" to test whether or not the strings are equal). On a side note, there is the "-longNames" flag for the `channelBox` command, however this only returns whether or not the queried channelbox is displaying long names (it does not return the channels in there long-name form - what a bummer).

The items in the text file I am reading are queried character set members (`character -q $character`). Once again, a lame paradox: querying the character members only returns attributes in their long-name form, and therefore I have to store the attribute names in the text file using their long names. Argh!

Question:
Does anyone know a fast way of converting attributesī long names to short names, or vice-versa? Or do I need to write another procedure to do this?

:beer:
David

alexx
07-21-2003, 04:14 PM
what a bummer..

i bet there is a hidden MEL for that one..
maybe duncan can help :)

i would say that sounds like you have to make a small procedure, which converts those short to long ones. :(

cheers

alexx

dwalden74
07-21-2003, 04:15 PM
OK, with a simple `switch` statement I just wrote a proc to do this. A bit lame that Maya wonīt do it for you though....

:beer:
David

dwalden74
07-21-2003, 05:38 PM
Also, now the script takes considerably longer to execute, since every character set member must now be fed through this new name-conversion procedure in order to match its value. Again, if there were an internal way to do this in Maya, it would be a great help.

:beer:
David

GDC
07-21-2003, 10:36 PM
Wow, what a pain...
Here's a thought, rather than sending the attributes through some kind of conversion can you do something like this:

if($textFileAttr == "translateX" && $selectedChannelAttr == "tx")

At least then you know you have the same attribute.

--g

Duncan
07-22-2003, 01:38 AM
If you have the object in addition to the attribute short name, you can get the long name with:
string $attrName[] = `listAttr nurbsSphere1.tx`;

In this case $attrName[0] would be translateX. You can go the other way by using listAtt -sn.

Duncan

dwalden74
07-22-2003, 08:58 AM
These are useful suggestions, and I thought Duncanīs would work, however the problem is that I still have to tokenize each character set member to separate its name from its attribute, then get the short name, then put them together to check if the strings are equal. The tokenizing part, I believe, is what is causing the time overhead. This is only because the `character -q`command will only return long names.

Strangely enough, Duncan, after I substituted your suggestion (`listAttr`) in place of my own name-conversion procedure (which "switches" the $attrLongName variable and assigns the short name), the script actually takes longer to execute. The `listAttr`command seems to take quite a bit of time when looping through many character member items.

So I would have a couple suggestions for extending the functionality of some MEL commands:

1) `character -q` should give the user the option of returning long OR short member attributes (add `-ln`and `-sn`flags).

2) `channelBox -q -sma` should give the same possibility. This would allow matching the two (and matching to any queried attribute, regardless of the command) without any expensive tokenizing or name conversion steps.

Thanks for the help!
:beer:
David

CGTalk Moderation
01-15-2006, 04:00 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.