當前位置: 首頁>>代碼示例>>Python>>正文


Python cmds.playblast方法代碼示例

本文整理匯總了Python中maya.cmds.playblast方法的典型用法代碼示例。如果您正苦於以下問題:Python cmds.playblast方法的具體用法?Python cmds.playblast怎麽用?Python cmds.playblast使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在maya.cmds的用法示例。


在下文中一共展示了cmds.playblast方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: playblast_snapshot

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import playblast [as 別名]
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) 
開發者ID:liorbenhorin,項目名稱:pipeline,代碼行數:19,代碼來源:maya_warpper.py

示例2: runPB

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import playblast [as 別名]
def runPB(quality, sequence, autoReview):
  #Get the file unix path of the maya file
  filePath = cmds.file(q=True, sceneName=True)
  #Parse the unix path and convert it into a dpa fspattern

  if quality < 50:
    print "Lower than 50 percent quality may result in very poor imaging..."
    cmds.deleteUI("PBQuality")
    return

  print "Percentage chosen: " + str(quality)
  print "From Sequence: " + str(sequence)
  print "AutoSubmit: " + str(autoReview)

  #Attempts to create a playblast of the current maya scene
  success = playblaster(quality, sequence, autoReview)

  if success:
    print "Successfully generated playblast :)"
  else:
    print "Failed to generate playblast :(" 
開發者ID:Clemson-DPA,項目名稱:dpa-pipe,代碼行數:23,代碼來源:playblast.py

示例3: saveScreenshot

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import playblast [as 別名]
def saveScreenshot(self, name, directory=DIRECTORY):
        path = os.path.join(directory, '%s.jpg' % name)

        # We'll fit the view to the objects in our scene or our selection
        cmds.viewFit()

        # We'll change our render format to jpg
        cmds.setAttr("defaultRenderGlobals.imageFormat", 8) # This is the value for jpeg

        # Finally we'll save out our image using the playblast module
        # There are a lot of arguments here so it's good to use the documentation to know what's going on
        cmds.playblast(completeFilename=path, forceOverwrite=True, format='image', width=200, height=200,
                       showOrnaments=False, startTime=1, endTime=1, viewer=False)

        # Return the path of the file we saved
        return path


# This will be our first Qt UI!
# We'll be creating a dialog, so lets start by inheriting from Qt's QDialog 
開發者ID:dgovil,項目名稱:PythonForMayaSamples,代碼行數:22,代碼來源:controllerLibrary.py

示例4: playblast_dialog

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import playblast [as 別名]
def playblast_dialog():
  # Creates a dialog prompt to determine if the user wishes to create a playblast
  #response = cmds.confirmDialog( title='Playblast', message='Are you SURE you want to create a new playblast?', button=['Yes','No'], defaultButton='No', cancelButton='No', dismissString='No' )
  #if response == 'Yes':
  floatUI() 
開發者ID:Clemson-DPA,項目名稱:dpa-pipe,代碼行數:7,代碼來源:playblast.py

示例5: snapshot

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import playblast [as 別名]
def snapshot(path = None, width = 96, height = 96):
    current_image_format = cmds.getAttr("defaultRenderGlobals.imageFormat")
    cmds.setAttr("defaultRenderGlobals.imageFormat", 32) # *.png
    #path = "/Users/liorbenhorin/Library/Preferences/Autodesk/maya/2015-x64/scripts/pipeline/thumb.png"
    cmds.playblast(cf = path, fmt="image", frame = cmds.currentTime( query=True ), orn=False, wh = [width,height], p=100, v=False)
    cmds.setAttr("defaultRenderGlobals.imageFormat", current_image_format)
    
    if os.path.isfile(path):
        return path
    else:
        return False 
開發者ID:liorbenhorin,項目名稱:pipeline,代碼行數:13,代碼來源:maya_warpper.py

示例6: playblast

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import playblast [as 別名]
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()) 
開發者ID:liorbenhorin,項目名稱:pipeline,代碼行數:14,代碼來源:maya_warpper.py

示例7: getPlayblastOptions

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import playblast [as 別名]
def getPlayblastOptions():
    options = {}
    options["format"] = cmds.playblast(q=True,fmt=True)
    options["compression"] = cmds.playblast(q=True,c=True)
    return options 
開發者ID:liorbenhorin,項目名稱:pipeline,代碼行數:7,代碼來源:maya_warpper.py

示例8: maintained_time

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import playblast [as 別名]
def maintained_time():
    """Maintain current time during context

    Example:
        >>> with maintained_time():
        ...    cmds.playblast()
        >>> # Time restored

    """

    ct = cmds.currentTime(query=True)
    try:
        yield
    finally:
        cmds.currentTime(ct, edit=True) 
開發者ID:pyblish,項目名稱:pyblish-maya,代碼行數:17,代碼來源:lib.py

示例9: get_active_editor

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import playblast [as 別名]
def get_active_editor():
    """Return the active editor panel to playblast with"""
    # fixes `cmds.playblast` undo bug
    cmds.currentTime(cmds.currentTime(query=True))
    panel = cmds.playblast(activeEditor=True)
    return panel.split("|")[-1] 
開發者ID:Colorbleed,項目名稱:maya-capture-gui,代碼行數:8,代碼來源:lib.py

示例10: _fix_playblast_output_path

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import playblast [as 別名]
def _fix_playblast_output_path(filepath):
    """Workaround a bug in maya.cmds.playblast to return correct filepath.

    When the `viewer` argument is set to False and maya.cmds.playblast does not
    automatically open the playblasted file the returned filepath does not have
    the file's extension added correctly.

    To workaround this we just glob.glob() for any file extensions and assume
    the latest modified file is the correct file and return it.

    """
    # Catch cancelled playblast
    if filepath is None:
        log.warning("Playblast did not result in output path. "
                    "Playblast is probably interrupted.")
        return

    # Fix: playblast not returning correct filename (with extension)
    # Lets assume the most recently modified file is the correct one.
    if not os.path.exists(filepath):
        directory = os.path.dirname(filepath)
        filename = os.path.basename(filepath)
        # check if the filepath is has frame based filename
        # example : capture.####.png
        parts = filename.split(".")
        if len(parts) == 3:
            query = os.path.join(directory, "{}.*.{}".format(parts[0],
                                                             parts[-1]))
            files = glob.glob(query)
        else:
            files = glob.glob("{}.*".format(filepath))

        if not files:
            raise RuntimeError("Couldn't find playblast from: "
                               "{0}".format(filepath))
        filepath = max(files, key=os.path.getmtime)

    return filepath 
開發者ID:Colorbleed,項目名稱:maya-capture-gui,代碼行數:40,代碼來源:lib.py

示例11: capture_scene

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import playblast [as 別名]
def capture_scene(options):
    """Capture using scene settings.

    Uses the view settings from "panel".

    This ensures playblast is done as quicktime H.264 100% quality.
    It forces showOrnaments to be off and does not render off screen.

    :param options: a collection of output options
    :type options: dict

    :returns: Full path to playblast file.
    :rtype: str 

    """

    filename = options.get("filename", "%TEMP%")
    log.info("Capturing to: {0}".format(filename))

    options = options.copy()

    # Force viewer to False in call to capture because we have our own
    # viewer opening call to allow a signal to trigger between playblast
    # and viewer
    options['viewer'] = False

    # Remove panel key since it's internal value to capture_gui
    options.pop("panel", None)

    path = capture.capture(**options)
    path = _fix_playblast_output_path(path)

    return path 
開發者ID:Colorbleed,項目名稱:maya-capture-gui,代碼行數:35,代碼來源:lib.py

示例12: browse

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import playblast [as 別名]
def browse(path=None):
    """Open a pop-up browser for the user"""

    # Acquire path from user input if none defined
    if path is None:

        scene_path = cmds.file(query=True, sceneName=True)

        # use scene file name as default name
        default_filename = os.path.splitext(os.path.basename(scene_path))[0]
        if not default_filename:
            # Scene wasn't saved yet so found no valid name for playblast.
            default_filename = "playblast"

        # Default to images rule
        default_root = os.path.normpath(get_project_rule("images"))
        default_path = os.path.join(default_root, default_filename)
        path = cmds.fileDialog2(fileMode=0,
                                dialogStyle=2,
                                startingDirectory=default_path)

    if not path:
        return

    if isinstance(path, (tuple, list)):
        path = path[0]

    if path.endswith(".*"):
        path = path[:-2]

    # Bug-Fix/Workaround:
    # Fix for playblasts that result in nesting of the
    # extension (eg. '.mov.mov.mov') which happens if the format
    # is defined in the filename used for saving.
    extension = os.path.splitext(path)[-1]
    if extension:
        path = path[:-len(extension)]

    return path 
開發者ID:Colorbleed,項目名稱:maya-capture-gui,代碼行數:41,代碼來源:lib.py

示例13: default_output

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import playblast [as 別名]
def default_output():
    """Return filename based on current scene name.
    
    :returns: A relative filename
    :rtype: str
    """

    scene = get_current_scenename() or "playblast"

    # get current datetime
    timestamp = datetime.datetime.today()
    str_timestamp = timestamp.strftime("%Y-%m-%d_%H-%M-%S")
    filename = "{}_{}".format(scene, str_timestamp)

    return filename 
開發者ID:Colorbleed,項目名稱:maya-capture-gui,代碼行數:17,代碼來源:lib.py

示例14: list_compressions

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import playblast [as 別名]
def list_compressions(format='avi'):
    # Workaround for Maya playblast bug where undo would
    # move the currentTime to frame one.
    cmds.currentTime(cmds.currentTime(query=True))

    cmd = 'playblast -format "{0}" -query -compression'.format(format)
    return mel.eval(cmd) 
開發者ID:Colorbleed,項目名稱:maya-capture-gui,代碼行數:9,代碼來源:lib.py

示例15: snap

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import playblast [as 別名]
def snap(*args, **kwargs):
    """Single frame playblast in an independent panel.

    The arguments of `capture` are all valid here as well, except for
    `start_frame` and `end_frame`.

    Arguments:
        frame (float, optional): The frame to snap. If not provided current
            frame is used.
        clipboard (bool, optional): Whether to add the output image to the
            global clipboard. This allows to easily paste the snapped image
            into another application, eg. into Photoshop.

    Keywords:
        See `capture`.

    """

    # capture single frame
    frame = kwargs.pop('frame', cmds.currentTime(q=1))
    kwargs['start_frame'] = frame
    kwargs['end_frame'] = frame
    kwargs['frame'] = frame

    if not isinstance(frame, (int, float)):
        raise TypeError("frame must be a single frame (integer or float). "
                        "Use `capture()` for sequences.")

    # override capture defaults
    format = kwargs.pop('format', "image")
    compression = kwargs.pop('compression', "png")
    viewer = kwargs.pop('viewer', False)
    raw_frame_numbers = kwargs.pop('raw_frame_numbers', True)
    kwargs['compression'] = compression
    kwargs['format'] = format
    kwargs['viewer'] = viewer
    kwargs['raw_frame_numbers'] = raw_frame_numbers

    # pop snap only keyword arguments
    clipboard = kwargs.pop('clipboard', False)

    # perform capture
    output = capture(*args, **kwargs)

    def replace(m):
        """Substitute # with frame number"""
        return str(int(frame)).zfill(len(m.group()))

    output = re.sub("#+", replace, output)

    # add image to clipboard
    if clipboard:
        _image_to_clipboard(output)

    return output 
開發者ID:bumpybox,項目名稱:pyblish-bumpybox,代碼行數:57,代碼來源:capture.py


注:本文中的maya.cmds.playblast方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。