Saving a graphic entity

Saving a graphic entity
 1# This example saves an image of the active window of the
 2# active drawing to file using various file formats
 3
 4# Create a local variable for the output toolbox
 5ot = impact.gui.output_toolbox
 6
 7# Clear the output toolbox
 8ot.clear()
 9
10# Create a local variable for the active drawing
11ad = impact.active_drawing
12
13# Check there is an active drawing
14if ad.isNone():
15
16    # Add an error message to the output toolbox
17    ot.add("unable to continue: no active drawing")
18
19else:
20
21    # Create a local variable for the active window of the active drawing
22    aw = ad.active_window
23
24    # create an IImageFormatParams object
25    options = impact.creator.image_format_params()
26
27    # define the image format options
28    options.width = 640
29    options.height = 480
30    options.resolution = 72
31    options.compression_factor = 50
32    options.colour_depth = ipImageColourFormat.ic24Bit
33    options.compression = ipCompressionFormat.cfDefault
34
35    # View the extents of the active window
36    aw.view_extents()
37
38    # Save the images
39    aw.save_to_file2(r"d:\\Images\\Picture.bmp", ipFileFormat.ffBitmap, options)