Selecting attributes through MEL

OK, maybe this is really basic but I can't make it work. How do you select an object's attribute in MEL - not the object but one of it's attributes?

You can get a list of object attributes; you can set the value of an attribute directly. But how do you select an attribute so that you can then manually modify it in the channel box?

im havig problems of realy understanding what you ask but here goes.

when you add a atribute it appears in the channelbox by default. Then if you want to connecti it forward either use the connection editor, connectAtr mel command or expressions (combination of both mel and maths that gets executed automaticaly at spesific points, used for behaivoristics).

Now if you want to collect atributes in one place then use sets (such as make character for character sets).

If you want to directly manipulate the value just connectit to a epression.

Maybe it's better if I give a simple example.

Say my goal is to make a button that would select only the translateX attribute on a sphere. It would make that attribute current so that you could middle-mouse to change the values.

Na, dragging the value of an attribute with the MMB is a command to it's own that activates through the interface; "dragger context". Anyway, I don't think there's such a thing as selecting an attribute...

Yeah thats what i tought too thatswhy it sounded so wierd. Unfortunately thers lots of things that might be called selecting the atribute...

But what you are refeering to is somekind of graphical hooc to connectAttr. Something a bit like the buttons in material nodes with the arow in them, right.

Maybe the simplicity of this is escaping people. You can manually click on an attribute in the channel box. It makes that attribute current. How would you do the same thing through MEL?

You are not really "selecting" the attribute in the channel box. When you click on "translate Z" in the channel box, Maya calls changeToolIcon and changes the current tool context to be the move tool. It knows which attribute was selected and locks the move tool so the middle mouse button only "moves" in that direction.

You could emulate the same functionality with your own custom mel script.

g-

Yeah this was one of the things that could have been considered selecting the atribute. You think youre selected the atribute (and in a sense the ui is saying you are), but in reality you arent you are just calling a function, its just a UI gimic. That doesnt mean you cant duplicate this type of call, but you wouldnt find any info on it by searching selecting atribute since there just isnt any info on that (since thats not the way it works internaly).

you can query what attribs are selected. the control for this part of the UI is, strangely enough, the channelBox command. unfortunately, it doesn't appear that you can edit the selection list, only query it. at least, thats what the docs say. you might be able to edit the list (maya doesn't give a syntax error initially) but I'm not sure because I don't know how to query the name of the channelBox.

Anyone know the default name of the channelBox? I guess you could always create your own and test it out on that...

Technically, selection lists can store attributes so you can select attributes as you would select anything else in MEL:

select -r nodeName.attrName

Anyway, the name of the channelBox control is mainChannelBox. The channelBox tool is dragAttrContext which is undocumented so you don't know the flags for the tool. You can write your own dragger tool that is independent of the channelBox using draggerContext.

It would be nice if you could control 3 attributes with one attr per mouse button but Maya API doesn't give you control of the right mouse button.

Isn the selection list just a string? So you could forece anything into it (ok maya seems to check the adress). But can you actualy use this... I guess you can, dam! there it is Ive even used this, stupid me