I strive to remain consistent on my CATIA macro format. I try to keep the same format and order on every single CATIA macro program I create. It’s very useful to keep your code clean and tidy, especially if other programmers are going to work on it later. Remember, keep the code as simple as possible. Always try to use as few lines of code as possible (which you’ll be glad you did when you have to troubleshoot one of your CATIA macros). You can reduce the number of lines of code using a colon (:). The macro format I use looks something like this:

‘my name
‘date last revised
‘who the macro was created for
‘description of what the macro does
‘—————–separator—————-
Main code begins here, usually with Sub CATMain
‘define variables, constants, etc.
‘error handling
‘check if part or product is in design mode or not
‘update part, drawing, etc.
‘double check to make sure all loops are closed
End Sub

Continue reading more articles about CATIA VBA.