timV = cmds.timeField(changeCommand = (cmds.polyCone()))
i want to create a cone every time the frame is updated. so when i run the script the cone created but
when i drag on time slider and move to a frame then it doesnt run. basically whenever the time slider
is updated i want to create a cone.
So the chamgeCommand flag takes either a string (that it will attempt to exec as code) or a callable, what you’ve handed it is actually the result of the call to cmds.polyCone which turns out to be a string, so no error, but isn’t really viable command to be run.
Instead what you probably want to do is cmds.timeField(changeCommand=lambda *x: cmds.polyCone()) as this will hand it a simple callable (the lambda) which will accept any number of arguments (and throw them away) and when invoked will call cmds.polyCone().
I’m not in front of Maya right now so I’m not able to test if this actually works. Another thing to keep in mind is that there are ways to move the time slider that won’t trigger this, they are detailed in the documentation for cmds.timeField
As you suggested i tried the lambda statement but the cone is not being created. suppose I’m on 60 frame and with mouse i drag the pointer to frame 70 or if I move to next frame with shortcut, the script should be executed and the cone should be created.
I’m not getting the condition to put in the If statement, I stored the value of current frame in the the variable, now if the value has changed then print hi. how do I get the new changed value and compare it with previous value.