iLogic Screenshot tool

Ever wanted to take screen-shots from Inventor at a pre-set resolution and ideally with a white background?

You can “Export” an image file from Inventor, but it’s several clicks and you have to specify the resolution by typing it out in full if you want something specific like 1280×1024.

The following code can be added as an external  iLogic rule and then run in any Inventor environment.

Note that we found a limitation regarding the background colour:  If you run Inventor with an image as your background, then regardless of the colour you pick, your resulting image will contain your background image.  Changing the background image to a gradient or solid colour will fix this.

Maybe the next revision of the code will fix that, but for now, this is quick and very simple!

‘Create the pre-set list of output resolutions 
availableRes = New String() {“640 x 480”, “1024
x 768”, “1280
x 1024”, “1920
x 1080”}
‘Get the required resolution from an InputListBox.
selectedRes = InputListBox(“Select Resolution”,availableRes, “”, “Export
JPG”, “Available
‘Set the required background colour
using the RGB values below. 
‘Note that this will not work if you
have a image image as your background!
Dim topColor As Color = ThisApplication.TransientObjects.CreateColor(255, 255, 255)‘255,255,255 = white.
Select Case selectedRes
Case = “640 x 480”
width = 640
height = 480
Case = “1024 x 768”
width = 1024
height = 768
Case = “1280 x 1024”
width = 1280
height = 1024
Case = “1920 x 1080”
width = 1920
height = 1080
End Select
imageName = ThisDoc.PathAndFileName(False)
Dim cam As Camera
cam = ThisApplication.ActiveView.Camera
Dim Time As DateTime = DateTime.Now
‘Reformat the time to remove the :
symbol because it not allowed for file names.
Dim Format As String = “”
currentTime = Time.ToString(Format) ‘Replaces : with . from time format.
‘Add current filename, resolution, and current time to make the image filename.
imageName = imageName & ” ” & selectedRes & ” ” & currentTime
cam.SaveAsBitmap((imageName & “.jpg”), width, height, topColor)

Leave a reply