You can obtain the active viewport's graphics window image as a bitmap. The size of the bitmap is the same as the size of the viewport. Use the Viewport.GetDIB() method.
The following example demonstrates how to get the active viewport, return its graphics window as a bitmap, then save the bitmap to a specified file and path.
import MaxPlus #Get the active viewport view = MaxPlus.ViewportManager.GetActiveViewport() #Create a bitmap bm = MaxPlus.Factory.CreateBitmap() #Allocate some storage storage = MaxPlus.Factory.CreateStorage(7) #Get the bitmap info info = storage.GetBitmapInfo() #Set its storage bm.SetStorage(storage) #Delete the storage that was created bm.DeleteStorage() #Call Viewport.GetDIB() to return the active viewport's graphics window res = view.GetDIB(info,bm) if res: #Display the bitmap bm.Display() #Set the output file name and path for the bitmap info.SetName(MaxPlus.PathManager.GetRenderOutputDir() + r'\VPRender.tga') #Prepare the bitmap for writing to the output file bm.OpenOutput(info) #Write the bitmap to the output file bm.Write(info) bm.Close(info)
First, call ViewportManager.GetActiveViewport() to obtain the active viewport. For more information about rendering and the viewport, see Rendering.
Then, create the bitmap and allocate its storage. For more information regarding creating and saving bitmaps, see Creating a bitmap.
Call Viewport.GetDIB() to obtain the active viewport's graphics window as a bitmap.
You can then call Bitmap.Display() to display the bitmap, as well as Bitmap.OpenOutput(), Bitmap.Write() and Bitmap.Close() to write the bitmap to an output file. Call BitmapInfo.SetName() to set the output file name.