Custom Image Save Shortcut

A customer recently asked if a more custom save image could be created. He always wants to use the “Default Print Colors”, and always wants to save out a certain image type and size. His main concern was always having to toggle on the “default print colors”, (as they are turned off after the image is saved), and the 6 mouse clicks/operations to save an image (File (1), Export(2), Image (3), specify filename (4), Default Print colors (5), and Ok (6)).

One option is to use the right Click (Right Click to Viewport — > default print colors), the Right Click again to Save image to file, then specify file name, and Ok. These are perfectly okay when saving a few images, but having to save 20 or 30 images, and you would want to look for a shortcut way to do this.

With EnSight’s scripting, and two lines of python, this can be made into a nice short macro, which would do the above steps in a single keystroke.

Here is the python macro (you can directly assign this to any of your favorite keyboard short cuts):

# Example Python to Create new Output image
import datetime
Basename = "EnSight_Image_"

# Use datetime to generate a filename with unique name
now = datetime.datetime.now()
unique_part = now.strftime("%Y-%m-%d_%H-%M-%S")
new_filename = str(Basename) + str(unique_part)

# Save the image
ensight.file.image_format("png")
ensight.anim_recorders.render_offscreen("ON")
ensight.file.image_numpasses(4)
ensight.file.image_stereo("current")
ensight.file.image_screen_tiling(1,1)
ensight.file.image_file(new_filename)
ensight.file.image_convert("ON")
ensight.file.image_window_size("HD1080p")
ensight.file.save_image()
ensight.file.image_convert("OFF")

 

Here, the three lines of python obtain the current time, and append that to the name “EnSight_Image_” in order to create a unique filename to be saved. The remaining lines in the file are direct EnSight journal commands converted to Python. Note here the use of the “image_convert” lines which do the operation of the default print colors.

So, with only three lines of python, you now can take the journal commands from a file save and make them into a quick shortcut to save an image out.