maya设置与获取帧速率

设置帧速率

cmds:
import maya.cmds as cmds

cmds.currentUnit(t='25fps')  # 设置当前帧速率为25每秒,必须带fps
pymel
import pymel.core as pm

pm.currentUnit(t='25fps')  # 设置当前帧速率为25每秒,必须带fps

获取帧速率

maya的python命令不能直接获取fps,很挫!自己写个函数吧。

def getFrameRate():
    '''
    Return an int of the current frame rate
    '''
    currentUnit = mc.currentUnit(query=True, time=True)
    if currentUnit == 'film':
        return 24
    if currentUnit == 'show':
        return 48
    if currentUnit == 'pal':
        return 25
    if currentUnit == 'ntsc':
        return 30
    if currentUnit == 'palf':
        return 50
    if currentUnit == 'ntscf':
        return 60
    if 'fps' in currentUnit:
        return int(currentUnit.substitute('fps',''))
建议用python调用mel语句来获取
import maya.mel as mel
fps = mel.eval('currentTimeUnitToFPS')  # 返回的是一个float
print(int(fps))   # 24

你可能感兴趣的:(maya设置与获取帧速率)