SaveToFile

SaveToFile
 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 local variables for the required width and height of the image
25    image_width = 640
26    image_height = 480
27
28    # View the extents of the active window
29    aw.view_extents()
30
31    # Save the images
32    aw.save_to_file("d:\\1.bmp", ipFileFormat.ffBitmap, image_width, image_height)
33    aw.save_to_file("d:\\1.emf", ipFileFormat.ffMetafile, image_width, image_height)
34    aw.save_to_file("d:\\1.png", ipFileFormat.ffPNG, image_width, image_height)
35    aw.save_to_file("d:\\1.jpg", ipFileFormat.ffJPG, image_width, image_height)
36