Notifications
Clear all
[Closed] Extended make preview/grab viewport
Oct 07, 2010 9:29 pm
Hi
Im looking for a script, or help to making one, which makes the process of quick viewport previews more automated. So basically an extension of make preview/grab viewport feature.
- would like to be able to select a path and filename ( without restricted codecs etc… )
- when path and filename selected once it should be possible to just overwrite the same file over and over again
Is it possible to modify the already existing make preview/grab viewport feature to do this? I cannot find the maxscript interface for make preview/grab viewport, so even that would help a lot
br
Chr
1 Reply
Oct 07, 2010 9:29 pm
search for “getviewportdib in maxscript help file.
this code is there:
hope it can get you started.
[left]MacroScript GrabViewport category:"Tools" tooltip:"Grab Viewport"
[/left]
[left](
[/left]
[left]---------------------------------------------------------------------
[/left]
[left]--GRABVIEWPORT MACROSCRIPT
[/left]
[left]--Created:3/23/99
[/left]
[left]--Edited:4/28/99
[/left]
[left]--by Borislav Petrov
[/left]
[left]---------------------------------------------------------------------
[/left]
[left]--Snapshot Active Viewport to Bitmap
[/left]
[left]--Filename in format:
[/left]
[left]--VPGRAB_MaxFileName_ViewportName_CurentFrame.ImageFormatExtension
[/left]
[left]---------------------------------------------------------------------
[/left]
[left]--
[/left]
[left]--Init Variables
[/left]
[left]local grab_bmp --bitmap to put the snapshot into
[/left]
[left]local bmp_name --name of the bitmap to save
[/left]
[left]local get_viewport_name --viewport name
[/left]
[left]local gac,gct,mfn --variables to hold ActiveCamera, CurrentTime, MaxFileName
[/left]
[left]--
[/left]
[left]--Start Macro
[/left]
[left]grab_bmp = gw.getViewportDib() --get the viewport bitmap into variable
[/left]
[left]get_viewport_name = viewport.GetType() --get viewport name
[/left]
[left]gvn = get_viewport_name as string --convert viewport name to string
[/left]
[left]gvn = substring gvn 6 (gvn.count-5) --cut the string
[/left]
[left]if gvn == "camera"then--if the remaining string is "camera"
[/left]
[left](
[/left]
[left]gac = getActiveCamera() --get the camera
[/left]
[left]gvn = gac.name --get the name of the camera
[/left]
[left])
[/left]
[left]mfn = MaxFileName --get max file name
[/left]
[left]if mfn == ""then--if there is no name
[/left]
[left]mfn = "Untitled"--use "Untitled"
[/left]
[left]else
[/left]
[left]mfn = getFileNameFile mfn --use the file name without .MAX extension
[/left]
[left]gct = SliderTime as string --get current frame time
[/left]
[left]--
[/left]
[left]bmp_name = "VPGRAB_"+ mfn +"_" +gvn + "_" + gct --build the output file name
[/left]
[left]--
[/left]
[left]--Display file save dialog
[/left]
[left]bmp_name = getSaveFileName caption:"Save Viewport to:" filename:bmp_name \
[/left]
[left]types:"BMP(*.bmp)|*.bmp|TIFF(*.tif)|*.tif|JPG(*.jpg)|*.jpg|TGA(*.tga)|*.tga|"
[/left]
[left]--
[/left]
[left]if bmp_name != undefined then--if user has confirmed / entered a valid name
[/left]
[left](
[/left]
[left]grab_bmp.filename = bmp_name --set output name to the one entered in the save file dialog
[/left]
[left]save grab_bmp --save the bitmap
[/left]
[left]display grab_bmp --display the bitmap in a VFB
[/left]
[left])
[/left]
[left]--
[/left]
[left])--end of script
[/left]