Exemplo n.º 1
0
def quickpreview():
    '''Create a quick preview'''
    preview_name = path.join(rt.getDir(rt.Name("preview")), "quickpreview.avi")
    view_size = rt.getViewSize()
    anim_bmp = rt.bitmap(view_size.x, view_size.y, filename=preview_name)
    for t in range(int(rt.animationRange.start), int(rt.animationRange.end)):
        rt.sliderTime = t
        dib = rt.gw.getViewportDib()
        rt.copy(dib, anim_bmp)
        rt.save(anim_bmp)
    rt.close(anim_bmp)
    rt.gc()
    rt.ramplayer(preview_name, "")
Exemplo n.º 2
0
	def launchRender(self,setting,size=1,ipr=False):
		#Render Settings Before
		self.storedSettings = rtt.initPref()
		# Ui states :
		self.collectStates()
		# Set render Settings Before Render		print setting
		if cmds.renderSceneDialog.isOpen():
			cmds.renderSceneDialog.close()

		rtt.changeRenderSettings(self.setSettings,setting,ipr)
		cmds.renderWidth = size * self.storedSettings['outWidth']
		cmds.renderHeight = size * self.storedSettings['outHeight']
		#DisableSave
		cmds.rendSaveFile = False

		#Region Control
		rtt.keepRegionVfb(cmds.renderWidth,cmds.renderHeight)

		#Update rendersettings dialog ?
		cmds.renderSceneDialog.commit()
		cmds.renderSceneDialog.update()
		#

		MaxPlus.RenderExecute.QuickRender()
		#Save Bitmap current Render
		bm = cmds.GetLastRenderedImage()
		bm.filename =rtt.previewName(rtt.initPreviewDir())
		cmds.save(bm)
		cmds.close(bm)
		
		#Restore parameters
		rtt.retoreParam(storeConfig,cmds.renderers.current)
		#rtt.changeRenderSettings(self.setSettings,'default')
		cmds.renderWidth = self.storedSettings['outWidth']
		cmds.renderHeight = self.storedSettings['outHeight']
		#EnableSave
		cmds.rendSaveFile = False
		cmds.renderSceneDialog.commit()
		cmds.renderSceneDialog.update()
Exemplo n.º 3
0
    def createThumbnail(self,
                        useCursorPosition=False,
                        dbPath=None,
                        versionInt=None):
        """
        Creates the thumbnail file.
        :param databaseDir: (String) If defined, this folder will be used to store the created database.
        :param version: (integer) if defined this version number will be used instead currently open scene version.
        :return: (String) Relative path of the thumbnail file
        """
        projectPath = self.projectDir
        if useCursorPosition:
            versionInt = self.currentVersionIndex
            dbPath = self.currentDatabasePath
        else:
            if not dbPath or not versionInt:
                logger.warning((
                    "Both dbPath and version must be defined if useCursorPosition=False"
                ))

        versionStr = "v%s" % (str(versionInt).zfill(3))
        dbDir, shotNameWithExt = os.path.split(dbPath)
        shotName = os.path.splitext(shotNameWithExt)[0]

        thumbPath = "{0}_{1}_thumb.jpg".format(os.path.join(dbDir, shotName),
                                               versionStr)
        relThumbPath = os.path.relpath(thumbPath, projectPath)

        ## Software specific section
        # rt = pymxs.runtime
        oWidth = 221
        oHeight = 124

        grab = rt.gw.getViewportDib()

        ratio = float(grab.width) / float(grab.height)

        if ratio <= 1.782:
            new_width = oHeight * ratio
            new_height = oHeight
        else:
            new_width = oWidth
            new_height = oWidth / ratio

        resizeFrame = rt.bitmap(new_width, new_height, color=rt.color(0, 0, 0))
        rt.copy(grab, resizeFrame)
        thumbFrame = rt.bitmap(oWidth, oHeight, color=rt.color(0, 0, 0))
        xOffset = (oWidth - resizeFrame.width) / 2
        yOffset = (oHeight - resizeFrame.height) / 2

        rt.pasteBitmap(resizeFrame, thumbFrame, rt.point2(0, 0),
                       rt.point2(xOffset, yOffset))

        # rt.display(thumbFrame)

        thumbFrame.filename = thumbPath
        rt.save(thumbFrame)
        rt.close(thumbFrame)

        # img = rt.gw.getViewportDib()
        # img.fileName = thumbPath
        # rt.save(img)
        # rt.close(img)

        return relThumbPath
Exemplo n.º 4
0
    def _createThumbnail(self, assetName, selectionOnly=True, viewFit=True):
        # ssResolution = 1000

        thumbPath = os.path.join(self.directory, assetName,
                                 "%s_thumb.jpg" % assetName)
        SSpath = os.path.join(self.directory, assetName,
                              "%s_s.jpg" % assetName)
        WFpath = os.path.join(self.directory, assetName,
                              "%s_w.jpg" % assetName)

        if selectionOnly:
            rt.IsolateSelection.EnterIsolateSelectionMode()
            rt.redrawViews()

        # selection = rt.execute("selection as array")
        selection = self._getSelection(asMaxArray=True)
        rt.clearSelection()

        originalState = rt.viewport.GetRenderLevel()
        oWidth = 1600
        oHeight = 1600

        rt.viewport.SetRenderLevel(rt.Name("smoothhighlights"))
        rt.redrawViews()
        grabShaded = rt.gw.getViewportDib()
        rt.viewport.SetRenderLevel(rt.Name("wireframe"))
        rt.redrawViews()
        grabWire = rt.gw.getViewportDib()
        # rt.redrawViews()

        ratio = float(grabShaded.width) / float(grabShaded.height)

        if ratio < 1.0:
            new_width = oHeight * ratio
            new_height = oHeight
        elif ratio > 1.0:
            new_width = oWidth
            new_height = oWidth / ratio
        else:
            new_width = oWidth
            new_height = oWidth

        resizeFrameShaded = rt.bitmap(new_width,
                                      new_height,
                                      color=rt.color(0, 0, 0))
        rt.copy(grabShaded, resizeFrameShaded)

        resizeFrameWire = rt.bitmap(new_width,
                                    new_height,
                                    color=rt.color(0, 0, 0))
        rt.copy(grabWire, resizeFrameWire)

        ssFrame = rt.bitmap(oWidth, oHeight, color=rt.color(0, 0, 0))
        wfFrame = rt.bitmap(oWidth, oHeight, color=rt.color(0, 0, 0))

        xOffset = (oWidth - resizeFrameShaded.width) / 2
        yOffset = (oHeight - resizeFrameShaded.height) / 2

        rt.pasteBitmap(resizeFrameShaded, ssFrame, rt.point2(0, 0),
                       rt.point2(xOffset, yOffset))
        rt.pasteBitmap(resizeFrameWire, wfFrame, rt.point2(0, 0),
                       rt.point2(xOffset, yOffset))

        # rt.display(ssFrame)
        # rt.display(wfFrame)

        thumbFrame = rt.bitmap(200, 200, color=rt.color(0, 0, 0))
        rt.copy(ssFrame, thumbFrame)

        rt.display(thumbFrame)

        thumbFrame.filename = thumbPath
        rt.save(thumbFrame)
        rt.close(thumbFrame)

        ssFrame.filename = SSpath
        rt.save(ssFrame)
        rt.close(ssFrame)

        wfFrame.filename = WFpath
        rt.save(wfFrame)
        rt.close(wfFrame)

        # switch to original view
        rt.viewport.SetRenderLevel(originalState)

        rt.IsolateSelection.ExitIsolateSelectionMode()
        rt.redrawViews()

        return thumbPath, SSpath, WFpath