Python maya.cmds.playbackOptions() Examples

The following are 15 code examples of maya.cmds.playbackOptions(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module maya.cmds , or try the search function .
Example #1
Source File: maya_warpper.py    From pipeline with MIT License 8 votes vote down vote up
def playblast_snapshot(path = None,format = None, compression = None, hud = None, offscreen = None, range=None, scale = None):
    current_image_format = cmds.getAttr("defaultRenderGlobals.imageFormat")
    cmds.setAttr("defaultRenderGlobals.imageFormat", 32) # *.png

    if range is None:
        
        range = playback_selection_range()
        print range
        if range is None:
        
            start = cmds.playbackOptions( q=True,min=True )
            end  = cmds.playbackOptions( q=True,max=True )
            range = [start, end]
 	
    cmds.playblast(frame =int((range[0] + range[1])/2), cf = path, fmt="image",  orn=hud, os=offscreen, wh = scene_resolution(), p=scale, v=False) 
    
    cmds.setAttr("defaultRenderGlobals.imageFormat", current_image_format) 
Example #2
Source File: capture.py    From pyblish-bumpybox with GNU Lesser General Public License v3.0 7 votes vote down vote up
def parse_active_scene():
    """Parse active scene for arguments for capture()

    *Resolution taken from render settings.

    """

    time_control = mel.eval("$gPlayBackSlider = $gPlayBackSlider")

    return {
        "start_frame": cmds.playbackOptions(minTime=True, query=True),
        "end_frame": cmds.playbackOptions(maxTime=True, query=True),
        "width": cmds.getAttr("defaultResolution.width"),
        "height": cmds.getAttr("defaultResolution.height"),
        "compression": cmds.optionVar(query="playblastCompression"),
        "filename": (cmds.optionVar(query="playblastFile")
                     if cmds.optionVar(query="playblastSaveToFile") else None),
        "format": cmds.optionVar(query="playblastFormat"),
        "off_screen": (True if cmds.optionVar(query="playblastOffscreen")
                       else False),
        "show_ornaments": (True if cmds.optionVar(query="playblastShowOrnaments")
                       else False),
        "quality": cmds.optionVar(query="playblastQuality"),
        "sound": cmds.timeControl(time_control, q=True, sound=True) or None
    } 
Example #3
Source File: tests.py    From maya-capture with MIT License 6 votes vote down vote up
def test_parse_active_scene():
    """parse_active_scene() works"""

    parsed = capture.parse_active_scene()
    reference = {
        "start_frame": cmds.playbackOptions(minTime=True, query=True),
        "end_frame": cmds.playbackOptions(maxTime=True, query=True),
        "width": cmds.getAttr("defaultResolution.width"),
        "height": cmds.getAttr("defaultResolution.height"),
        "compression": cmds.optionVar(query="playblastCompression"),
        "filename": (cmds.optionVar(query="playblastFile")
                     if cmds.optionVar(query="playblastSaveToFile") else None),
        "format": cmds.optionVar(query="playblastFormat"),
        "off_screen": (True if cmds.optionVar(query="playblastOffscreen")
                       else False),
        "show_ornaments": (True if cmds.optionVar(query="playblastShowOrnaments")
                       else False),
        "quality": cmds.optionVar(query="playblastQuality")
    }

    for key, value in reference.items():

        assert parsed[key] == value 
Example #4
Source File: capture.py    From maya-capture with MIT License 6 votes vote down vote up
def parse_active_scene():
    """Parse active scene for arguments for capture()

    *Resolution taken from render settings.

    """

    time_control = mel.eval("$gPlayBackSlider = $gPlayBackSlider")

    return {
        "start_frame": cmds.playbackOptions(minTime=True, query=True),
        "end_frame": cmds.playbackOptions(maxTime=True, query=True),
        "width": cmds.getAttr("defaultResolution.width"),
        "height": cmds.getAttr("defaultResolution.height"),
        "compression": cmds.optionVar(query="playblastCompression"),
        "filename": (cmds.optionVar(query="playblastFile")
                     if cmds.optionVar(query="playblastSaveToFile") else None),
        "format": cmds.optionVar(query="playblastFormat"),
        "off_screen": (True if cmds.optionVar(query="playblastOffscreen")
                       else False),
        "show_ornaments": (True if cmds.optionVar(query="playblastShowOrnaments")
                       else False),
        "quality": cmds.optionVar(query="playblastQuality"),
        "sound": cmds.timeControl(time_control, q=True, sound=True) or None
    } 
Example #5
Source File: ml_utilities.py    From ml_tools with MIT License 6 votes vote down vote up
def frameRange(start=None, end=None):
    '''
    Returns the frame range based on the highlighted timeslider,
    or otherwise the playback range.
    '''

    if not start and not end:
        gPlayBackSlider = mm.eval('$temp=$gPlayBackSlider')
        if mc.timeControl(gPlayBackSlider, query=True, rangeVisible=True):
            frameRange = mc.timeControl(gPlayBackSlider, query=True, rangeArray=True)
            start = frameRange[0]
            end = frameRange[1]-1
        else:
            start = mc.playbackOptions(query=True, min=True)
            end = mc.playbackOptions(query=True, max=True)

    return start,end 
Example #6
Source File: ui.py    From maya-timeline-marker with GNU General Public License v3.0 5 votes vote down vote up
def draw(self):
        """
        Take all the marker information and fill in the utils.QWidget covering the 
        timeline. This function will be called by the update and paintEvent 
        function.
        """
        
        # get animation range
        self.start = cmds.playbackOptions(query=True, min=True)
        self.end   = cmds.playbackOptions(query=True, max=True)
        
        # calculate frame width
        self.total = self.width()
        self.step = (self.total - (self.total*0.01)) / (self.end-self.start+1)

        # validate marker information
        if not self.frames or not self.colors: 
            return
        
        # setup painter and pen
        painter = utils.QPainter(self)
        pen = utils.QPen()
        pen.setWidth(self.step)
            
        # draw Lines for each frame
        for f, c in zip(self.frames, self.colors):
            pen.setColor(utils.QColor(c[0], c[1], c[2], 50))
        
            # calculate line position
            pos = (f-self.start+0.5) * self.step + (self.total*0.005)
            line = utils.QLineF(utils.QPointF(pos, 0), utils.QPointF(pos, 100))
            
            painter.setPen( pen )
            painter.drawLine( line )
            
    # ------------------------------------------------------------------------ 
Example #7
Source File: maya_warpper.py    From pipeline with MIT License 5 votes vote down vote up
def rewind():
    cmds.currentTime(1)    
    cmds.playbackOptions(minTime=1) 
Example #8
Source File: maya_warpper.py    From pipeline with MIT License 5 votes vote down vote up
def playblast(path = None,format = None, compression = None, hud = None, offscreen = None, range=None, scale = None):
    if range is None:
        
        range = playback_selection_range()
        print range
        if range is None:
        
            start = cmds.playbackOptions( q=True,min=True )
            end  = cmds.playbackOptions( q=True,max=True )
            range = [start, end]
 	
    cmds.playblast(startTime =range[0] ,endTime =range[1], f = path, fmt=format,  orn=hud, os=offscreen, wh = scene_resolution(), p=scale, qlt=90,c=compression, v=True, s = qeury_active_sound_node()) 
Example #9
Source File: learningTab.py    From DeformationLearningSolver with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def getTimeRange(self):
        """"""
        if self.isStartEnd():
            start = int(self.getStartTime())
            end = int(self.getEndTime())
            return start, end
            
        start = int(cmds.playbackOptions(q=1, min=1))
        end = int(cmds.playbackOptions(q=1, max=1))
        return start, end
    
    #---------------------------------------------------------------------- 
Example #10
Source File: dm2skin.py    From dm2skin with The Unlicense 5 votes vote down vote up
def createMush(self):
        mesh = self.sourceField.text()
        if not mesh:
            return
        if cmds.objExists(mesh + '_Mush'):
            print(mesh + '_Mush already exists!')
            return
        cmds.currentTime(cmds.playbackOptions(q=True, min=True))
        dup = cmds.duplicate(mesh, inputConnections=True, n=mesh + '_Mush')
        cmds.deltaMush(dup, smoothingIterations=20, smoothingStep=0.5, pinBorderVertices=True, envelope=1) 
Example #11
Source File: lib.py    From maya-capture-gui with MIT License 5 votes vote down vote up
def get_time_slider_range(highlighted=True,
                          withinHighlighted=True,
                          highlightedOnly=False):
    """Return the time range from Maya's time slider.

    Arguments:
        highlighted (bool): When True if will return a selected frame range
            (if there's any selection of more than one frame!) otherwise it
            will return min and max playback time.
        withinHighlighted (bool): By default Maya returns the highlighted range
            end as a plus one value. When this is True this will be fixed by
            removing one from the last number.

    Returns:
        list: List of two floats of start and end frame numbers.

    """
    if highlighted is True:
        gPlaybackSlider = mel.eval("global string $gPlayBackSlider; "
                                   "$gPlayBackSlider = $gPlayBackSlider;")
        if cmds.timeControl(gPlaybackSlider, query=True, rangeVisible=True):
            highlightedRange = cmds.timeControl(gPlaybackSlider,
                                                query=True,
                                                rangeArray=True)
            if withinHighlighted:
                highlightedRange[-1] -= 1
            return highlightedRange
    if not highlightedOnly:
        return [cmds.playbackOptions(query=True, minTime=True),
                cmds.playbackOptions(query=True, maxTime=True)] 
Example #12
Source File: commands.py    From core with MIT License 4 votes vote down vote up
def reset_frame_range():
    """Set frame range to current asset"""
    shot = api.Session["AVALON_ASSET"]
    shot = io.find_one({"name": shot, "type": "asset"})

    try:

        frame_start = shot["data"].get(
            "frameStart",
            # backwards compatibility
            shot["data"].get("edit_in")
        )
        frame_end = shot["data"].get(
            "frameEnd",
            # backwards compatibility
            shot["data"].get("edit_out")
        )
    except KeyError:
        cmds.warning("No edit information found for %s" % shot["name"])
        return

    fps = {15: 'game',
           24: 'film',
           25: 'pal',
           30: 'ntsc',
           48: 'show',
           50: 'palf',
           60: 'ntscf',
           23.98: '23.976fps',
           23.976: '23.976fps',
           29.97: '29.97fps',
           47.952: '47.952fps',
           47.95: '47.952fps',
           59.94: '59.94fps',
           44100: '44100fps',
           48000: '48000fps'
           }.get(float(api.Session.get("AVALON_FPS", 25)), "pal")

    cmds.currentUnit(time=fps)

    cmds.playbackOptions(minTime=frame_start)
    cmds.playbackOptions(maxTime=frame_end)
    cmds.playbackOptions(animationStartTime=frame_start)
    cmds.playbackOptions(animationEndTime=frame_end)
    cmds.playbackOptions(minTime=frame_start)
    cmds.playbackOptions(maxTime=frame_end)
    cmds.currentTime(frame_start) 
Example #13
Source File: capture.py    From pyblish-bumpybox with GNU Lesser General Public License v3.0 4 votes vote down vote up
def apply_scene(**options):
    """Apply options from scene

    Example:
        >>> apply_scene({"start_frame": 1009})

    Arguments:
        options (dict): Scene options

    """

    if "start_frame" in options:
        cmds.playbackOptions(minTime=options["start_frame"])

    if "end_frame" in options:
        cmds.playbackOptions(maxTime=options["end_frame"])

    if "width" in options:
        cmds.setAttr("defaultResolution.width", options["width"])

    if "height" in options:
        cmds.setAttr("defaultResolution.height", options["height"])

    if "compression" in options:
        cmds.optionVar(
            stringValue=["playblastCompression", options["compression"]])

    if "filename" in options:
        cmds.optionVar(
            stringValue=["playblastFile", options["filename"]])

    if "format" in options:
        cmds.optionVar(
            stringValue=["playblastFormat", options["format"]])

    if "off_screen" in options:
        cmds.optionVar(
            intValue=["playblastFormat", options["off_screen"]])

    if "show_ornaments" in options:
        cmds.optionVar(
            intValue=["show_ornaments", options["show_ornaments"]])

    if "quality" in options:
        cmds.optionVar(
            floatValue=["playblastQuality", options["quality"]]) 
Example #14
Source File: capture.py    From maya-capture with MIT License 4 votes vote down vote up
def apply_scene(**options):
    """Apply options from scene

    Example:
        >>> apply_scene({"start_frame": 1009})

    Arguments:
        options (dict): Scene options

    """

    if "start_frame" in options:
        cmds.playbackOptions(minTime=options["start_frame"])

    if "end_frame" in options:
        cmds.playbackOptions(maxTime=options["end_frame"])

    if "width" in options:
        cmds.setAttr("defaultResolution.width", options["width"])

    if "height" in options:
        cmds.setAttr("defaultResolution.height", options["height"])

    if "compression" in options:
        cmds.optionVar(
            stringValue=["playblastCompression", options["compression"]])

    if "filename" in options:
        cmds.optionVar(
            stringValue=["playblastFile", options["filename"]])

    if "format" in options:
        cmds.optionVar(
            stringValue=["playblastFormat", options["format"]])

    if "off_screen" in options:
        cmds.optionVar(
            intValue=["playblastFormat", options["off_screen"]])

    if "show_ornaments" in options:
        cmds.optionVar(
            intValue=["show_ornaments", options["show_ornaments"]])

    if "quality" in options:
        cmds.optionVar(
            floatValue=["playblastQuality", options["quality"]]) 
Example #15
Source File: uExport.py    From uExport with zlib License 4 votes vote down vote up
def setExportFlags(self, uNode):

        # set export properties from the fbxExportPropertiesDict of the uNode
        fbxDict = uNode.fbxExportProperties
        if fbxDict['triangulation'] == True:
            mel.eval("FBXExportTriangulate -v true")
        else:
            mel.eval("FBXExportTriangulate -v false")

        # Mesh
        mel.eval("FBXExportSmoothingGroups -v true")
        mel.eval("FBXExportHardEdges -v false")
        mel.eval("FBXExportTangents -v true")
        mel.eval("FBXExportInstances -v false")
        mel.eval("FBXExportInAscii -v true")
        mel.eval("FBXExportSmoothMesh -v false")

        # Animation
        mel.eval("FBXExportBakeResampleAnimation -v true")
        mel.eval("FBXExportBakeComplexAnimation -v true")
        mel.eval("FBXExportBakeComplexStart -v "+str(cmds.playbackOptions(minTime=1, q=1)))
        mel.eval("FBXExportBakeComplexEnd -v "+str(cmds.playbackOptions(maxTime=1, q=1)))
        mel.eval("FBXExportReferencedAssetsContent -v true")
        mel.eval("FBXExportBakeComplexStep -v 1")
        mel.eval("FBXExportUseSceneName -v false")
        mel.eval("FBXExportQuaternion -v quaternion")
        mel.eval("FBXExportShapes -v true")
        mel.eval("FBXExportSkins -v true")

        if fbxDict['animInterpolation'] == 'euler':
            mel.eval("FBXExportQuaternion -v euler")
        elif fbxDict['animInterpolation'] == 'resample':
            mel.eval("FBXExportQuaternion -v resample")

        if fbxDict['upAxis'].lower() == 'y':
            print 'FBX EXPORT OVERRIDE: setting y up axis'
            mel.eval("FBXExportUpAxis y")
        elif fbxDict['upAxis'].lower() == 'z':
            print 'FBX EXPORT OVERRIDE: setting Z up axis'
            mel.eval("FBXExportUpAxis z")

        #garbage we don't want
        # Constraints
        mel.eval("FBXExportConstraints -v false")
        # Cameras
        mel.eval("FBXExportCameras -v false")
        # Lights
        mel.eval("FBXExportLights -v false")
        # Embed Media
        mel.eval("FBXExportEmbeddedTextures -v false")
        # Connections
        mel.eval("FBXExportInputConnections -v false")