About maya python commands that cannot be found in the Script Editor

About maya python commands that cannot be found in the Script Editor

243202504
Enthusiast Enthusiast
593 Views
3 Replies
Message 1 of 4

About maya python commands that cannot be found in the Script Editor

243202504
Enthusiast
Enthusiast

I'm writing a script recently, and the last function involved is the scaling curve. First, you can find that the scaling curve corresponds to the 

scaleKey

command.

Various parameters are also known. You can achieve the effect of scaling the animation curve through the given vs value.

I posted the code:

cmds.scaleKey('', attribute='tz', iub=0, ts=1, tp=0, fs=1, fp=0, vs= ,vp=0)

The first quotation mark is the object, and vs is equal to a number, you can scale the curve.

but! The problem is that every time I pass in a value, the curve changes, and the next change is based on the last change. So whether I write the UI externally, create a slider, link the value of the slider to the function, or pass the value to the function, I can’t achieve it. In Maya, press and hold the left mouse button on the zoom curve slider. Drop and drag the effect of the slider.

So I want to know if there is a corresponding command, or other solutions?

 

最近在写一个脚本,最后涉及一个功能是缩放曲线,首先可以查到缩放曲线是对应ScaleKey这个命令,各种参数也知道了,可以通过给定的vs值,达到对动画曲线进行缩放的效果。

我把代码贴下来:

cmds.scaleKey('', attribute='tz', iub=0, ts=1, tp=0, fs=1, fp=0, vs= ,vp=0)

第一个引号是物体, vs等于一个数,就可以对曲线进行缩放。

但是!问题在于,每次我传入一个值,曲线都会发生变化,而且下次变化是基于上次变化的。所以无论我是在外部写了UI,创建滑块,链接滑块的值传入函数,还是传值给函数,都没法达成,在maya里面按住鼠标左键在缩放曲线的滑块上不放,拖动滑块的那个效果。

所以想知道有没有对应的命令,或者其他解决方法?

0 Likes
Replies (3)
Message 2 of 4

lee.dunham
Collaborator
Collaborator

If I'm understanding you correctly, the issue is your `valuePivot` - https://help.autodesk.com/cloudhelp/2020/ENU/Maya-Tech-Docs/CommandsPython/scaleKey.html#flagvaluePi...

 

If using a slider, you want to scale around the current value. This general logic should be considered;

  1. On mouseClicked - get the current value.
  2. Pause Undo (without Flush) - this prevents the valueChanged commands from spamming the undo stack.
  3. On valueChanged - scale the key using the cached value as the pivot.
  4. On mouseReleased - Unpause Undo and reapply the new current value as the value - this adds a valid entry to the undo stack.

There will be other ways to achieve this also.

Message 3 of 4

243202504
Enthusiast
Enthusiast

not `valuePivot`,  and i want to use scale to a value ,like scale the curve  to end frame value to  20.  but i used  'nef' 'nsf', it doesnt work.

and i fixed my problem yesterday. i use Adjustment Blend to scale run animation.

i want to know how scaleKey commond nef and nsf work.

and thx for ur  unswer, its a good way to deal the slider's problem

0 Likes
Message 4 of 4

243202504
Enthusiast
Enthusiast

and I also have a question, how to connect the mouseClicked' event to Maya. In China community and search engine ,cant find more detail about them . I cant google.

0 Likes