Python maya.cmds 模块,currentUnit() 实例源码

我们从Python开源项目中,提取了以下11个代码示例,用于说明如何使用maya.cmds.currentUnit()

项目:OpenTimelineIO    作者:PixarAnimationStudios    | 项目源码 | 文件源码
def _read_shot(shot):
    rate = FPS.get(cmds.currentUnit(q=True, time=True), 25)
    start = int(cmds.shot(shot, q=True, startTime=True))
    end = int(cmds.shot(shot, q=True, endTime=True)) + 1

    video_reference = otio.media_reference.External(
        target_url=_video_url_for_shot(shot),
        available_range=otio.opentime.TimeRange(
            otio.opentime.RationalTime(value=start, rate=rate),
            otio.opentime.RationalTime(value=end - start, rate=rate)
        )
    )

    return otio.schema.Clip(
        name=cmds.shot(shot, q=True, shotName=True),
        media_reference=video_reference,
        source_range=otio.opentime.TimeRange(
            otio.opentime.RationalTime(value=start, rate=rate),
            otio.opentime.RationalTime(value=end - start, rate=rate)
        )
    )
项目:OpenTimelineIO    作者:PixarAnimationStudios    | 项目源码 | 文件源码
def read_sequence():
    rate = FPS.get(cmds.currentUnit(q=True, time=True), 25)
    shots = cmds.ls(type='shot') or []
    per_track = {}

    for shot in shots:
        track_no = cmds.shot(shot, q=True, track=True)
        if track_no not in per_track:
            per_track[track_no] = []
        per_track[track_no].append(shot)

    timeline = otio.schema.Timeline()
    timeline.global_start_time = otio.opentime.RationalTime(0, rate)

    for track_no in reversed(sorted(per_track.keys())):
        track_shots = per_track[track_no]
        timeline.tracks.append(_read_track(track_shots))

    return timeline
项目:ml_tools    作者:morganloomis    | 项目源码 | 文件源码
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',''))

    return 1
项目:pipeline    作者:liorbenhorin    | 项目源码 | 文件源码
def set_fps(fps = None):
    fps_string = "pal"
    if fps == 25:
        fps_string = "pal"
    if fps == 24:
        fps_string = "film"
    if fps == 30:
        fps_string = "ntsc"                
    cmds.currentUnit(t=fps_string)
项目:BlendTransforms    作者:duncanskertchly    | 项目源码 | 文件源码
def BT_SetUnits():
    if cmds.currentUnit(q = True, linear = True) != "cm":
        cmds.currentUnit(linear = "cm")
        return True
    return False
项目:BlendTransforms    作者:duncanskertchly    | 项目源码 | 文件源码
def BT_SetUnits():
    if cmds.currentUnit(q = True, linear = True) != "cm":
        cmds.currentUnit(linear = "cm")
        return True
    return False
项目:BlendTransforms    作者:duncanskertchly    | 项目源码 | 文件源码
def BT_SetUnits():
    if cmds.currentUnit(q = True, linear = True) != "cm":
        cmds.currentUnit(linear = "cm")
        return True
    return False
项目:BlendTransforms    作者:duncanskertchly    | 项目源码 | 文件源码
def BT_SetUnits():
    if cmds.currentUnit(q = True, linear = True) != "cm":
        cmds.currentUnit(linear = "cm")
        return True
    return False
项目:OpenTimelineIO    作者:PixarAnimationStudios    | 项目源码 | 文件源码
def _get_gap(duration):
    rate = FPS.get(cmds.currentUnit(q=True, time=True), 25)
    gap_range = otio.opentime.TimeRange(
        duration=otio.opentime.RationalTime(duration, rate)
    )
    return otio.schema.Gap(source_range=gap_range)
项目:core    作者:getavalon    | 项目源码 | 文件源码
def reset_frame_range():
    """Set frame range to current asset"""
    shot = api.Session["AVALON_ASSET"]
    shot = io.find_one({"name": shot, "type": "asset"})

    try:
        edit_in = shot["data"]["edit_in"]
        edit_out = shot["data"]["edit_out"]
    except KeyError:
        cmds.warning("No edit information found for %s" % shot["name"])
        return

    fps = {
        "12": "12fps",
        "15": "game",
        "16": "16fps",
        "24": "film",
        "25": "pal",
        "30": "ntsc",
        "48": "show",
        "50": "palf",
        "60": "ntscf"
    }.get(api.Session.get("AVALON_FPS"), "pal")  # Default to "pal"

    cmds.currentUnit(time=fps)

    cmds.playbackOptions(minTime=edit_in)
    cmds.playbackOptions(maxTime=edit_out)
    cmds.playbackOptions(animationStartTime=edit_in)
    cmds.playbackOptions(animationEndTime=edit_out)
    cmds.playbackOptions(minTime=edit_in)
    cmds.playbackOptions(maxTime=edit_out)
    cmds.currentTime(edit_in)
项目:config    作者:mindbender-studio    | 项目源码 | 文件源码
def process(self, context):
        from maya import cmds

        scene_in = cmds.playbackOptions(query=True, animationStartTime=True)
        scene_out = cmds.playbackOptions(query=True, animationEndTime=True)
        scene_fps = {
            "12fps": 12,
            "game": 15,
            "16fps": 16,
            "film": 24,
            "pal": 25,
            "ntsc": 30,
            "show": 48,
            "palf": 50,
            "ntscf": 60}.get(cmds.currentUnit(query=True, time=True))

        if scene_fps is None:
            scene_fps = "a strange "

        env = context.data.get("environment", dict())

        valid_fps = env.get("avalonFps")
        valid_edit_in = env.get("avalonEditIn")
        valid_edit_out = env.get("avalonEditOut")

        skip_on_none = [valid_fps, valid_edit_in, valid_edit_out]

        if None in skip_on_none:
            self.log.debug(" environment not set")
            return

        assert int(valid_fps) == int(scene_fps), (
            "The FPS is set to %sfps and not to %sfps"
            % (scene_fps, valid_fps))

        assert int(scene_in) == int(valid_edit_in), (
            "Animation Start is set to %s and not set to \"%s\""
            % (scene_in, valid_edit_in))

        assert int(scene_out) == int(valid_edit_out), (
            "Animation End is set to %s and not set to \"%s\""
            % (scene_out, valid_edit_out))