Exemplo n.º 1
0
 def uvSnapshot(self, name, xr, yr, aa, *args, **kwargs):
     ''' takes a snapshot image from the UV Editor in TGA format '''
     pm.uvSnapshot(name=name,
                   xr=xr,
                   yr=yr,
                   overwrite=True,
                   aa=aa,
                   fileFormat='tga')
Exemplo n.º 2
0
    def snap_shot(self, *args):
        snappath = path(self.path.getText())
        col = [i * 255 for i in self.col.getRgbValue()]

        pm.uvSnapshot(name=snappath, ff=snappath.ext[1:],
                      aa=self.aa.getValue(), r=col[0], g=col[1], b=col[2], o=True,
                      xr=self.opts.width.getValue(), yr=self.opts.height.getValue())

        if self.of.getValue():
            os.startfile(snappath)
Exemplo n.º 3
0
 def uvSnapshot(self, name, xr, yr, aa, *args, **kwargs):
     ''' takes a snapshot image from the UV Editor in TGA format '''
     try:
         pm.uvSnapshot(name=name,
                       xr=xr,
                       yr=yr,
                       overwrite=True,
                       aa=aa,
                       fileFormat='tga')
     except:
         lcUtility.Utility.lc_print_exception(
             'Could not take UV snapshot, do you have geo selected?')
Exemplo n.º 4
0
def snapshot_uvs(res, *args):
    fformat = 'png'
    sel = pm.ls(selection=True)[0]
    scene_path = pm.system.sceneName().dirname()
    file_out = str(scene_path) + "/" + str(sel) + "." + str(fformat)
    pm.uvSnapshot(n=file_out,
                  xr=res,
                  yr=res,
                  r=0,
                  g=0,
                  b=0,
                  ff=fformat,
                  o=True)
    pm.warning('Here is where your UVs went: ' +
               str(pm.mel.toNativePath(file_out)))
Exemplo n.º 5
0
    def previewSaver(self, name, assetDirectory):
        """
        Saves the preview files under the Asset Directory
        Args:
            name: (Unicode) Name of the Asset
            assetDirectory: (Unicode) Directory of Asset

        Returns:
            (Tuple) Thumbnail path, Screenshot path, Wireframe path

        """
        logger.info("Saving Preview Images")
        selection = pm.ls(sl=True)

        validShapes = pm.listRelatives(selection,
                                       ad=True,
                                       type=["mesh", "nurbsSurface"])
        thumbPath = os.path.join(assetDirectory, '%s_thumb.jpg' % name)
        SSpath = os.path.join(assetDirectory, '%s_s.jpg' % name)
        WFpath = os.path.join(assetDirectory, '%s_w.jpg' % name)

        # make sure the viewport display is suitable
        panel = pm.getPanel(wf=True)

        if pm.getPanel(to=panel) != "modelPanel":
            logger.warning(
                "The focus is not on a model panel, using the perspective view"
            )
            panel = pm.getPanel(wl="Persp View")
            # Somehot wl dont return a regular string, convert it to a regular string
            t = ""
            for z in panel:
                t += z
            panel = t

        pm.modelEditor(panel, e=1, allObjects=1)
        pm.modelEditor(panel, e=1, da="smoothShaded")
        pm.modelEditor(panel, e=1, displayTextures=1)
        pm.modelEditor(panel, e=1, wireframeOnShaded=0)
        pm.viewFit()

        pm.isolateSelect(panel, state=1)
        pm.isolateSelect(panel, addSelected=True)
        # temporarily deselect
        pm.select(d=True)
        pm.setAttr("defaultRenderGlobals.imageFormat",
                   8)  # This is the value for jpeg

        frame = pm.currentTime(query=True)
        # thumb
        pm.playblast(completeFilename=thumbPath,
                     forceOverwrite=True,
                     format='image',
                     width=200,
                     height=200,
                     showOrnaments=False,
                     frame=[frame],
                     viewer=False)

        # screenshot
        pm.playblast(completeFilename=SSpath,
                     forceOverwrite=True,
                     format='image',
                     width=1600,
                     height=1600,
                     showOrnaments=False,
                     frame=[frame],
                     viewer=False)

        # Wireframe
        pm.modelEditor(panel, e=1, displayTextures=0)
        pm.modelEditor(panel, e=1, wireframeOnShaded=1)
        pm.playblast(completeFilename=WFpath,
                     forceOverwrite=True,
                     format='image',
                     width=1600,
                     height=1600,
                     showOrnaments=False,
                     frame=[frame],
                     viewer=False)

        pm.select(selection)
        # UV Snapshot -- It needs
        logger.info("Saving UV Snapshots")
        for i in range(0, len(validShapes)):
            print "validShape", validShapes[i]
            # transformNode = validShapes[i].getParent()
            objName = validShapes[i].name()
            UVpath = os.path.join(assetDirectory, '%s_uv.jpg' % objName)
            pm.select(validShapes[i])
            try:
                pm.uvSnapshot(o=True, ff="jpg", n=UVpath, xr=1600, yr=1600)
            except:
                logger.warning("UV snapshot is missed for %s" % validShapes[i])

        pm.isolateSelect(panel, state=0)
        pm.isolateSelect(panel, removeSelected=True)

        # TODO // store the scene defaults (camera position, imageFormat, etc.

        return thumbPath, SSpath, WFpath
Exemplo n.º 6
0
 def uvSnapshot(self, name, xr, yr, aa, *args, **kwargs):
   ''' takes a snapshot image from the UV Editor in TGA format '''
   pm.uvSnapshot(name=name,xr=xr,yr=yr,overwrite=True,aa=aa,fileFormat='tga')