How do I get the selected curve name?


#1

I’m trying to get the name of the selected curve in the Graph Editor.
For example: pSphere.scaleX (note the period!)

1) If I try this:
… string $curves[] = keyframe -selected -q -name;
I get this: pSphere_scaleX (note the underscore instead of the period!)

2) If I try this:
… string $connection = editor -q -mainListConnection graphEditor1GraphEd;
… string $curves[] = expandSelectionConnectionAsArray $connection;
I get this, but it gives me ALL curves in the channel list, not the selected curve:
… pSphere.scaleX pSphere.scaleY pSphere.scaleZ

keyframe -selected -q -name would work great, if only it didn’t replace the period with an underscore…

Also, I can’t simply substituteAllString “" with “.” because some object names contain underscores, and it would result in this other problem:
Ctrl_Upper_Head.rotateX //this is the real correct curve name
Ctrl_Upper_Head_rotateX //keyframe -selected -q -name would give me this
Ctrl.Upper.Head.rotateX //substituteAllString($curves[0], "
”, “.”) would give me this

Thank you for your help in advance!


#2

Have a look here: http://ewertb.soundlinker.com/mel/mel.084.php

David


#3

Not in front of my PC so I can only think of renaming the string.

In Python it would be very simple to search for the last _ with rfind(’_’) but in Mel It would be a little more complicated. I’m guessing using tokenize to split the name where finds an _, concatenate the parts and replace the last one with a dot.


#4

Thanks djx!
This is what I used to make it work:

string $curves[] = `keyframe -selected -q -name`;   //gets selected curve names
string $channels[] = `listConnections -plugs true $curves[0]`;   //gets affected channel name
print $channels;