Automating Repetitive Tasks Using Macros

If you perform a task repeatedly, you can take advantage of a macro to automate it. A macro is a series of functions, written in a scripting language, that you group in a single command to perform the requested task automatically.

You can, for example, use a macro to automate:

  • the creation of a series of holes in a part
  • the extraction of bills of materials from an assembly
  • the addition of a standard title block to a series of drawings
  • the printing of a series of documents.

You can create macros either by recording an interaction sequence or by editing a file (written in a scripting language) to insert the functions you wish. You can also modify an existing macro, either recorded or created from scratch, to best fit your needs. Once the macro is created, you can run it by selecting Tools->Macro->Macros..., selecting the macro, and clicking Run.

Macros can be stored in the current document or in a file in an external library. If a macro is created while a document is current, either by means of recording an interaction sequence or editing a file, and is stored in an external file, a link is kept in the current document to the file containing the macro.

 

Script Development Tools and Languages

  You can use the following scripting tools and languages, depending on the platform you are running on.
 

On Windows

  • CATScript: these macros are written in Basic Script, stored in CATScript-type documents, and can be run on both Windows and UNIX
  • Visual Basic Script (VB Script), at minimum level 5.0 , which is part of the operating system: macros written in Visual Basic can be run on both Windows and UNIX. 
    The use of VB Script is recommended for developing Windows/UNIX-compatible macros. Although CATScript macros written in previous releases continue to work, we recommend that you prefer VB Script to CATScript
  • Visual Basic for Applications (VBA) Version 6.0: this product is installed with Version 5: macros written using VBA can only be run on Windows. Among the advantages of using VBA, note that:
    • IntelliSense editing facilitates editing
    • VBA contains a debugger
    • you can develop graphic user interfaces using VBA (this is not possible with CATScript or VB Script macros).

On UNIX

Visual Basic Script 3.0 for UNIX (from Mainsoft) (shared libraries are installed when installing Version 5).