1/10/16

MAYA / VRAY / MEL _ viewport snapshot in Vray VFB

// Vray VFB viewport snapshot
// create it in maya's renderview then load it in Vray VFB
global proc VrayVFBsnapshot () 
{
 // create snapashot from current viewport camera 
 RenderViewWindow; // open renderview
 string $panel = `getPanel -wf`;
 string $camera = `modelEditor -q -camera $panel`;
 renderWindowRenderCamera snapshot renderView $camera; // create snapshot

 // get path to TMP image
 string $workspaceDir = `workspace -q -fullName`;
 string $imageDir = `workspace -q -fileRuleEntry "images"`;
 string $imagePath =  $workspaceDir  + "/" + $imageDir +  "/" + "TMP_snapshot";
 print $imagePath;
 sysFile -delete ($imagePath+".jpg"); // delete previous snapshot -- Windows
 setAttr "defaultRenderGlobals.imageFormat" 8; // set maya software to .jpg to save it as a jpg
 renderWindowSaveImageCallback "renderView" $imagePath ""; // save snapashot to .jpg file

 // open image in vray vfb
 vrayShowVFB; // open Vray VFB
 vray vfbControl -loadimage ($imagePath+".jpg");
}

No comments:

Post a Comment