如何在Maya场景中设置镜头的帧率

huangapple go评论154阅读模式
英文:

How to set frame rate of a shot in maya scene

问题

基本上,我需要从Shotgun中检索镜头的帧速率值,然后将其设置给在Maya中打开的镜头,但我无法看到帧速率值的任何更改:

def query_frame_rate():
    """
    镜头级别如果存在则返回镜头的帧速率值
    层次级别如果镜头中不存在帧速率值它会查找相应的项目
              然后从项目中提取帧速率值
    """
    sht_entity = db_query.query_context("entity")
    result = sg.find_one("Shot", [["id", "is", sht_entity["id"]]], ["sg_frame_rate"])

    frame_rate = result["sg_frame_rate"]

    if frame_rate == None:

        project = sg.find_one("Shot", [["id", "is", sht_entity["id"]]], ["project"])
        project_id = project["project"]["id"]
        result = sg.find_one("Project", [["id", "is", project_id]], ["sg_frame_rate"])

        frame_rate = result["sg_frame_rate"]

    return frame_rate 


if __name__ == "__main__":

    frame_per_second = query_frame_rate()
    frame_per_second = 16.0
    import maya.cmds as cmds

    cmds.playbackOptions(minTime=cmds.playbackOptions(q=True, minTime=True),
                     maxTime=cmds.playbackOptions(q=True, maxTime=True),
                     fps=16.0)

    #cmds.playbackOptions( fps=frame_per_second )
    print("已完成帧速率已设置为 {}".format(frame_per_second))

所以这是我在这里面遇到的唯一问题,任何帮助都将很有帮助。谢谢!

英文:

So basically i have to retrieve the value of frame rate of a shot from shotgun and then set it to the shot opened in Maya but I am not able to see any changes in the frame rate value:

def query_frame_rate():
    """
    Shot level : return frame_rate value for shot if it's present
    Hierarchy level : If frame_rate is not present in shot it goes for corresponding project 
                      and then extract the frame_rate value from the Project
    """
    sht_entity = db_query.query_context("entity")
    result = sg.find_one("Shot", [["id", "is", sht_entity["id"]]], ["sg_frame_rate"])

    frame_rate = result["sg_frame_rate"]
    
    if frame_rate == None:

        project = sg.find_one("Shot", [["id", "is", sht_entity["id"]]], ["project"])
        project_id = project["project"]["id"]
        result = sg.find_one("Project", [["id", "is", project_id]], ["sg_frame_rate"])
        
        frame_rate = result["sg_frame_rate"]
  
    return frame_rate 
    

if __name__ == "__main__":
     
    frame_per_second = query_frame_rate()
    frame_per_second = 16.0
    import maya.cmds as cmds


    cmds.playbackOptions(minTime=cmds.playbackOptions(q=True, minTime=True),
                     maxTime=cmds.playbackOptions(q=True, maxTime=True),
                     fps=16.0)

    #cmds.playbackOptions( fps=frame_per_second )
    print("Done frame rate has been set to {}".format(frame_per_second))

So yes that's the only issue i am facing here, any help would be great
Thanks

答案1

得分: 1

playbackOptions命令可用于查询该值,为了设置该值,您可以使用currentUnit命令https://help.autodesk.com/cloudhelp/2019/ENU/Maya-Tech-Docs/Commands/currentUnit.html
但是,您必须将您的值设置为速率标准字符串名称,如pal、ntsc

例如
// 将当前时间单位更改为ntsc
currentUnit -time ntsc;

这也是github上关于这个主题的一个有用的要点 - https://gist.github.com/gansaibow/c30b93bd80dd9a0396d926c31832c4f7

英文:

playbackOptions command can be used to query the value, in order to set the value you can use currentUnit command https://help.autodesk.com/cloudhelp/2019/ENU/Maya-Tech-Docs/Commands/currentUnit.html
but you have to set your value as a rate standard string name like pal, ntsc

for example
// Change the current time unit to ntsc
currentUnit -time ntsc;

this is also an useful gist on github for the topic - https://gist.github.com/gansaibow/c30b93bd80dd9a0396d926c31832c4f7

huangapple
  • 本文由 发表于 2023年2月16日 14:02:48
  • 转载请务必保留本文链接:https://go.coder-hub.com/75468399.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定