I tried to find some sample code for using the Document.ExportImage method in Autodesk Revit 2011 but couldn't find any. So I wrote my own sample code and posted it on the RevitPythonShell wiki as a featured script. I'd like to share it here too:
''' exportImage.py Export the currently visible view as a PNG image to a location specified by the user. ''' import clr clr.AddReference('RevitAPI') from Autodesk.Revit.DB import * doc = __revit__.ActiveUIDocument.Document # collect file location from user clr.AddReference('System.Windows.Forms') from System.Windows.Forms import DialogResult, SaveFileDialog dialog = SaveFileDialog() dialog.Title = 'Export current view as PNG' dialog.Filter = 'PNG files (*.PNG)|*.PNG' if dialog.ShowDialog() == DialogResult.OK: # set up the export options options = ImageExportOptions() options.ExportRange = ExportRange.VisibleRegionOfCurrentView options.FilePath = dialog.FileName options.HLRandWFViewsFileType = ImageFileType.PNG options.ImageResolution = ImageResolution.DPI_72 options.ZoomType = ZoomFitType.Zoom options.ShadowViewsFileType = ImageFileType.PNG doc.ExportImage(options) __window__.Close()
The above code does some stuff necessary for any canned command in RPS: It adds references to the RevitAPI and imports the Autodesk.Revit.DB types. I also open a SaveFileDialog using code found here: http://www.ironpython.info/index.php/SaveFileDialog.