Attribute executing and changing a MEL command?


Is it possible to have an attribute value output a MEL command?
Like, say I have a sphere, I want the sphere’s ty to drive a mel command like this:

float $driver = nurbsSphere1.ty;
keyframe -option over -index 0 -absolute -floatChange $driver blendScaleKeeper_blender ;

I know this is possible with a slider using the # sign, but how do I do it with an attribute?

As I realize, this is maybe not a very fast way of doing what I want, any other suggestions? What I want to do is to change the keyframes “time” values dynamically on a set driven key curve.


Hi zkanal,

how about using an expression?




Yes, that was my thought too… however the expression doesn’t seem to update when I move my sphere in y. It doesn’t output the command I want.


So, you want the position-in-time of the keyframe [on a single curve?] with index ‘0’ to vary according to the y-translation of your sphere? Is that right? Perhaps you could elaborate a bit - e.g. what this is for?

Kind regards,


BTW, in general you can use a scriptJob to execute a script when an attribute changes. For example:[size=2]scriptJob -ac “pSphere1.ty” "setAttr pSphere1.tx getAttr pSphere1.ty";

Will automatically set the value of pSphere1.tx to that of pSphere1.ty when the latter is changed. The final string above is the command / script to be executed, and the former the attribute which drives the ‘event’.

Does that help?



Aah, I know about scriptJobs, however, I do not want to change an attribute … I want it to be like when I move my sphere in y it should take the value from the sphere, change and execute the following command.

keyframe -option over -index 0 -absolute -floatChange THIS_SHOULD_BE_THE_VALUE_OF_SPHERE_TY_DYNAMICALLY_CHANGING_WHEN_I_MOVE_MY_SPHERE_IN_Y blendScaleKeeper_blender ;

So what I want to do, it change the time at index 0 on a set driven key curve .

It’s really hard to explain why I would want to do this… actually I´d rather have the time being an attribute. The whole problem here is that time at index # isn’t an attribute, and must be changed via the keyFrame command.

How else (without setDriven keys) could I manipulate the blender attribute of a blendColor within a dynamically changing range?? Say I want the blender attribute to blend between a value coming from another node between 10 and 20… and then be able to change this value to whatever I want, for example between 30 and 40 instead?

Am I just having brain fart or what? :banghead:

Anyhow, thanks for the help so far. :thumbsup:


and what about direct connections with a multiply/divide node?


I would love to, if you tell me how to “directly” connect a MEL command, NOT an attribute.


how about this:

scriptJob -ac “nurbsSphere1.ty” “keyframe -option over -index 0 -absolute -floatChange (getAttr nurbsSphere1.ty) blendScaleKeeper_blender”;



oki doki… :slight_smile:

but I’m not quite sure that I’m understanding it correctly… but why not just use the SetDrivenKey to control the blending depending on were the nurbsSphere1.ty is?

could you e.g. post an image or something of it?

or e.g. tell a bit more, how many things are or should be controlling or changning the blendcolor thingie, which is dependant on the nurbsSphere1.ty?

btw. are you using mac, linux or windows?

maybe if none or a lot of utility nodes or things were needed, we could e.g. make a little new utilityNode which does this… :slight_smile:




Like I said zkanal, and zylphyr illustrates, the final argument to scriptJob is the command to be executed - it doesn’t have to be an attribute which is changed - my example was purely to give a simple demonstration of the command.

You could even do something like, for example:

scriptJob -ac “pSphere1.ty” “sphere”;

Which would make a new sphere each time you change pSphere1.ty - the sky’s the limit with scriptJob…!

I don’t know if this will do exactly what you want [since I still don’t entirely understand what you require!], but as zylphyr points out - it solves your original way of tackling the problem…


Thanks for the great response! :slight_smile: I dig the scriptjob, but I have one qwirk with it, if I understand it correctly, it only works when running maya in gui mode, meaning it will not behave as I want when I render.
However, I found another solution , I used two setRange nodes , one to control -10 to 0 , and one to control 0 to 10. based on the sphere.ty within a certain range:) Does exactly what I want , and Strarup, if there is some kind of utility node I would like it would be a setRange for multiple ranges, so I don’t have to use two. eg, when I move sphere from -20 to +20 , it goes between -10 to 0,waits a bit until it leaves 0, and then continues to 10. As I said before , overwhealming great response! Thank you all! :thumbsup: :thumbsup: :thumbsup: :bounce:


And btw Strarup, I’m using both Windows and OSX.
And what I use this stuff for? A squash and stretch rig for legs with individual controls for squash and stretch so that one can make a super-exaggerated SQ/ST :slight_smile:
The blendcolor originally blended two stages of a condition nodes output, to avoid “choppyness” between squash and stretch.


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.