def renderFrame(self): """ Gather all information from UI to render current frame """ # get width and height modelPanel = lib.getActiveModelPanel() width = cmds.modelEditor(modelPanel, w=True, q=True) height = cmds.modelEditor(modelPanel, h=True, q=True) if self.frameCapCustomChBox.isChecked(): width = self.frameCapWSpin.value() height = self.frameCapHSpin.value() # get render size (supersampling or not) renderSize = 1 if self.supersampleImgChBox.isChecked(): renderSize = 2 # get save directory fileFilter = "*" + self.frameCapFormatCoBox.currentText() saveDir = cmds.fileDialog2(fileFilter=fileFilter, fileMode=0, cap="Save image in:", dialogStyle=2) if not saveDir: cmds.error("Filename not specified") saveDir = saveDir[0] # get image format imgFormat = self.frameCapFormatCoBox.currentText() # get renderer override = mnpr_info.prototype if not self.viewport2RenderChBox.isChecked(): override = "" # render frame using npr system mnpr_system.renderFrame(saveDir, width, height, renderSize, imgFormat, override)
def saveScreenshot(self, name, directory): """ Saves screenshot out to disk Args: name: Name of the screenshot directory: Directory to save into """ # get camera, current position and focus object cameraName = cmds.lookThru(q=True) prevPosition = cmds.getAttr("{0}.translate".format(cameraName)) objName = cmds.ls(sl=True, l=True) if objName: objName = objName[0] else: cmds.error("No object has been selected") # frame camera to object cmds.viewFit() # 'f' on keyboard distance = lib.distanceBetween(cameraName, objName) frameDistance = distance * 0.5 cmds.dolly(cameraName, d=-frameDistance) # take screenshot screenshotDir = mnpr_system.renderFrame(os.path.join(directory, name), 100, 100, 1, ".jpg") # bring camera back to normal lib.setAttr(cameraName, "translate", prevPosition) return screenshotDir
def saveScreenshot(self, name, directory): """ Saves screenshot out to disk Args: name: Name of the screenshot directory: Directory to save into """ return mnpr_system.renderFrame(os.path.join(directory, name), 100, 100, 1, ".jpg")