//Increases the value of a key that is selected in the Graph Editor.
selectKey -clear ;
selectKey -add -k -t 1 pCube1_translateZ ;
doUpdateTangentFeedback;
dR_updateCounter;
updateAnimLayerEditor("AnimLayerTab");
statusLineUpdateInputField;
if (!`exists polyNormalSizeMenuUpdate`) {eval "source buildDisplayMenu";} polyNormalSizeMenuUpdate;
ikSelectionChanged("MayaWindow|mainKeysMenu|menuItem1991|ikFKStateItem");
ilrUpdateSpreadSheetEditor;
ilrUpdateAEDeferred;
dR_updateCommandPanel;
ilrUpdateAE;
keyframe -e -iub true -r -o over -vc 1.715638 -t 1 pCube1_translateZ ;
doUpdateTangentFeedback;
//Decreases the value of a key that is selected in the Graph Editor.
selectKey -clear ;
selectKey -add -k -t 1 pCube1_translateZ ;
doUpdateTangentFeedback;
dR_updateCounter;
updateAnimLayerEditor("AnimLayerTab");
statusLineUpdateInputField;
if (!`exists polyNormalSizeMenuUpdate`) {eval "source buildDisplayMenu";} polyNormalSizeMenuUpdate;
ikSelectionChanged("MayaWindow|mainKeysMenu|menuItem1991|ikFKStateItem");
ilrUpdateSpreadSheetEditor;
ilrUpdateAEDeferred;
dR_updateCommandPanel;
ilrUpdateAE;
keyframe -e -iub true -r -o over -vc -1.797335 -t 1 pCube1_translateZ ;
doUpdateTangentFeedback;
import maya.cmds as cmds
cmds.ls(sl = True)
cmds.keyframe(edit = True, iub = True, r = True, o = over, vc = 1, t = 1)
Solved! Go to Solution.
Solved by amaterasu-qbb. Go to Solution.
Hi! everyone.
I would like to inform you all.
I have created a command that allows you to increase or decrease the value of the selected key.
I hope you all will try to use it. I would appreciate your help in giving me feedback. Thank you.
The command increases or decreases the value of the key in the graph editor by 0.1, so in some cases, this value may be too much or too little.
I would like to ask for a programming forum to evaluate and fix my code. but please feel free to report it in this post as well.
I will accept the solution to this post for now, once I have assigned my command to a hotkey and confirmed that the command works.
If you have any good ideas, please let me know.
This is the code to increase the value of the key.
import maya.cmds as cmds
# Relative value increase
cmds.keyframe(edit = True, iub = True, relative = True, vc = 0.1)
This is the code to decrease the value of the key.
import maya.cmds as cmds
# Relative value decrease
cmds.keyframe(edit = True, iub = True, relative = True, vc = -0.1)
@Kahylan wrote:Hi!
It works, so that is good. It's a good start into coding.
Two minor suggestions to your code:
1) The flag iub is set to True by default, so you don't need to add it to your command to get the desired effect.
2) I would either have all your flags in long form or all of them in short form. It doesn't make a difference, it just makes it seem more professional.
import maya.cmds as cmds # like this cmds.keyframe(e = True, r = True, vc = 0.1) # or this cmds.keyframe(edit = True, relative = True, valueChange = 0.1)
Now as you mentioned correctly, a big problem with your command is that it feeds a static value at the moment, which depending on scene scale could be way to high or way too low. I thought I'd present a possible solution to this problem.
Creating an option variable (a variable that gets stored in Mayas preferences) to scale the value up and down, combined with a UI that would be called via script or shelf button to easily set the option variable. It would look something like this.
Make value bigger hotkey command:
import maya.cmds as cmds #check if optionVar exists, if it doesn't set it to default value if cmds.optionVar(ex = "animationValueChangeFloat")== 0: cmds.optionVar(fv = ("animationValueChangeFloat", 0.1)) #get Value from optionVar changeValue = cmds.optionVar(q= "animationValueChangeFloat") #change keyframe value cmds.keyframe(e = True, r = True, vc = changeValue)Make value smaller hotkey command:
import maya.cmds as cmds #check if optionVar exists, if it doesn't set it to default value if cmds.optionVar(ex = "animationValueChangeFloat")== 0: cmds.optionVar(fv = ("animationValueChangeFloat", 0.1)) #get Value from optionVar changeValue = cmds.optionVar(q= "animationValueChangeFloat") #change keyframe value cmds.keyframe(e = True, r = True, vc = (-1 * changeValue))
Command to call UI from shelf button:
import maya.cmds as cmds def buildChangeUI(): windowName = "animationValueChangeUI" if cmds.window(windowName, ex = True): cmds.deleteUI(windowName) cmds.window(windowName) v = getValue() cmds.columnLayout("mainLayout") sliderGrp = cmds.floatSliderGrp("ChangeSliderGRP" , l= "Change Value", f = True, min=0, max = 10, fmx = 100000,pre= 3, v= v) cmds.floatSliderGrp(sliderGrp , l= "Change Value", e=True, cc = lambda x = cmds.floatSliderGrp(sliderGrp, q= True, v= True): changeOptionVar(value = x)) cmds.showWindow(windowName) def getValue(): if cmds.optionVar(ex = "animationValueChangeFloat")== 0: cmds.optionVar(fv = ("animationValueChangeFloat", 0.1)) changeValue= 0.1 else: changeValue = cmds.optionVar(q= "animationValueChangeFloat") return changeValue def changeOptionVar(value = None): cmds.optionVar(fv= ("animationValueChangeFloat", value)) buildChangeUI()
Option Variables are stored in the preferences, so this approach will change the value in all scenes on the same machine, you could also approach it more localised by storing the value on a node in the scene.
I hope it helps!
changeValue = cmds.optionVar(q= "animationValueChangeFloat")
I am sorry, but I am going to Accept Solution to share this code with you.
Please note that I do not own this Accept Solution, even though it may increase my ranking in the Top Solution Authors.
Can't find what you're looking for? Ask the community or share your knowledge.