Save Drawing As Image

Save Drawing As Image
 1# This example shows how to save a drawing as an image
 2
 3# create an IImageFormatParams object, then set the properties
 4ImageFormat = impact.creator.image_format_params()
 5ImageFormat.width = 500  # pixels
 6ImageFormat.height = 500  # pixels
 7ImageFormat.resolution = 72
 8ImageFormat.compression_factor = 50
 9ImageFormat.colour_depth = ipImageColourFormat.ic24Bit
10ImageFormat.compression = ipCompressionFormat.cfDefault
11
12# create an ISaveImageParams object and define the properties
13# (the border size is in your current distance impact.units)
14ImageParams = impact.creator.save_image_params()
15ImageParams.image_format_params = ImageFormat
16ImageParams.file_format = ipFileFormat.ffBitmap
17ImageParams.file_path = r"d:\\Images\\Picture.bmp"
18ImageParams.left_border_size = 20
19ImageParams.right_border_size = 20
20ImageParams.top_border_size = 20
21ImageParams.bottom_border_size = 20
22
23# Create the image file
24if impact.active_drawing.save_drawing_as_image(ImageParams):
25    impact.gui.output_toolbox.add("Image Saved successfully")
26else:
27    impact.gui.output_toolbox.add("Image Save failed")