Screen Shot Macro


How to take a screen shot picture using a CATScript macro


After learning how to setup your macros you can begin to write useful code. One helpful code to create that is easy to make but looks impressive to others is to take a screen shot of whatever is shown on your CATIA window and export it to an image format using a CATScript macro. I’ll highlight each line of code and explain what it does, step-by-step.

catscript picture 2 300x217 Screen Shot Macro


Our CATScript begins with:


Sub CatMAIN()


Next, we set the active window as the active viewer.

Dim ObjViewer3D As Viewer3D 
Set objViewer3D = CATIA.ActiveWindow.ActiveViewer


Now we need to access one of the “Camera” objects from the current document. A camera object in CATIA is a static version of the window viewer object.

Dim objCamera3D As Camera3D 
Set objCamera3D = CATIA.ActiveDocument.Cameras.Item(1) 

Let’s create an Input box to name the screen capture image file. Then we’ll need and If Then statement to abort the operation if no name is entered.
Dim partname As String 
partName = Inputbox (“Please name the image.”) 

picture catscript 300x137 Screen Shot Macro




If partName=”" Then 

MsgBox “No name entered”, vbExclamation, “Cancel Pressed” 



We need to specify a location to save the image file. Here I’ve chosen “C:\Macro Files\”


‘file location to save image 
Dim fileloc As String 
fileloc = “C:\Macro Files\”

I want my image to be exported as a .png file so I will create a variable specifying the extension name of the image.
Dim exten As String 
exten = “.png”


My image file will be saved as the input box name plus the file extension and will be saved in the folder I specified earlier.

Dim strName as string 
strname = fileloc & partName & exten


Set the 3Dviewer viewpoint to the camera viewpoint.


objViewer3D.Viewpoint3D = objCamera3D.Viewpoint3D


Clear the selection for picture.



I will also increase CATIA to full screen mode in order to obtain maximum resolution.
objViewer3D.FullScreen = True 



Finally, using the viewer we can now export the 3D window into a picture format (BMP, TIFF, CGM, EMF, or TIFFGreyScale).
objviewer3D.Capturetofile 4,strname


We need to close our If Then statement from before and end the program as usual.

End If

End Sub

Embedded below is a Catia video tutorial of the end result. If you’re following along you should get the same result.

Now you know how to take a screen shot in CATIA using a CATScript macro. To make your picture even better you can automate other processes such as: turning the compass off, hiding the specification tree, turning the background to white, automatically reframe, zoom in or out, and more. You can even export your image capture directly to Power Point. This is helpful for car design in Catia. Purchase VB Scripting for CATIA V5 to get the complete example code and learn how to do all of these processes.

1 Screen Shot Macro

Share and Enjoy

  • wp socializer sprite mask 16px Screen Shot Macro
  • wp socializer sprite mask 16px Screen Shot Macro
  • wp socializer sprite mask 16px Screen Shot Macro
  • wp socializer sprite mask 16px Screen Shot Macro
  • wp socializer sprite mask 16px Screen Shot Macro
  • wp socializer sprite mask 16px Screen Shot Macro
  • wp socializer sprite mask 16px Screen Shot Macro
  • wp socializer sprite mask 16px Screen Shot Macro

11 Responses to “Screen Shot Macro”

  1. Mark says:

    I would like to use the exact steps of this macro but with the export tool.
    What i had in mind are the following:
    -read the file name
    -read the number of sheets (excluding detail sheet)
    -”save as” each page with name_(number of page).jpg in a folder of my choosing
    Any hints would be appreciated. Thanks.

    • admin says:

      Hi Mark. What do you mean by export tool and number of sheets? Like with a drawing file? Reading the file name and saving as are easy enough and there are examples of how to do that within this website.


      • Mark says:

        I wasnt able to find the exact examples but this is what i meant:
        - when you “Save as” in the Drafting module as a Jpg file it saves the current selected sheet as a picture.
        - what i want to do is to find a macro that takes all the sheets from a drafting file and saves them with the same name and a certain identification _1 _2 _etc.

  2. Aleksandar says:


    This CATScript macros works but it can make a screen shot only from one point of view and the background is not white. How can I set up the point of view or to make screen shots using the actual view?

    Thank you

    • Emmett says:

      Hi Aleksandar,

      The complete code for the screen capture macro is included in my book and macro pack download. To change the background to white:

      Dim DBLBackArray(2)
      Dim dblWhiteArray(2)

      To reframe:

      Iso view:

  3. Rajesh says:

    good one really explained well… But i have doubt and i always struggle for this .. as an user i want ot take particular section of screen as image how can i modify above macro and i want to take it in drafting so viewpoint2D will be applicalbel but how can i input screen xy for both diagonal point of zoom window

  4. CH says:

    Hi Emmett,

    i copy&paste exactly the same code from your macro pack but couldn’t save the image file.

    Is there a particular “save” code?

    ‘file location to save image
    Dim fileloc As String
    fileloc = “C:\Users\CH\Desktop”

    Dim exten As String
    exten = “.png”

    Dim strName as string
    strName = fileloc & partName & exten


    • Emmett says:

      Hi CH, the “save” code where you tell it where and what type of file to save as is:

      objViewer3D.CapturetoFile 4, strname

      Let me know if that works for ya.


      • CH says:

        Hi Emmett,

        Thanks for the reply and advise.

        The code seems like executed, but i couldn’t find the saved image in the specified folder or anything….

        Am i missing anything?

        Please advise. TQVM

        • CH says:

          Dear Emmett,

          Please ignore my previous reply.

          Its’ work after i add a “\” at the end of the file location.



  5. Samba says:

    as a part of my work i need to save the drawing sheets as a tiff files. the name of the tiff file should be ZZZZZ_S0x (Z=part number & x= sheet numbers).
    Some times i need to save 100 drawing sheets.
    is there any macro in VBscrips to ful fill and make ease of my Work?
    If anybody please help me.

Leave a Reply