To make your CATScript macro run faster turn off the refresh display while the macro is running then turn it back on once it is complete, like so:

Sub CATMain()
CATIA.RefreshDisplay = False
‘enter code here
CATIA.RefreshDisplay = True
End Sub

You may also want to hide any file alerts (such as a dialog box that pops up notifying the user that the file they need to save is read only). Turn them on and off like this:

CATIA.DisplayFileAlerts = False
CATIA.DisplayFileAlerts = True

You can also change the size of the window to force CATIA to refresh or repaint. In this example, we will change the width of the window by two (may not be detectable to the eye) and reset it back to the original width (which is expressed in pixels):

Sub CATMain()
CATIA.RefreshDisplay = True
iWidth = CATIA.ActiveWindow.Width
CATIA.ActiveWindow.Width = iWidth – 2
CATIA.ActiveWindow.Width = iWidth
End Sub

Tips to make your CATIA macros run faster:

  1. Run in batch mode
  2. Turn display refresh off
  3. Turn file alerts off
  4. use colon to condense lines of code


Learn more about CATIA VBA and automation.