You’re probably ready to begin creating your first custom CATIA macro. This means you’ve read through my free articles or went through the step-by-step tutorials in my book and now want to create something yourself from scratch. While it’s easy to follow along with examples, it’s  much more difficult when starting from nothing and you’re left staring at a blank screen.This is the stage in the process where I get the most emails and is the inspiration for this article. I am going to cover two main topics:

Part 1. How to get started writing your first CATIA macro from scratch

Part 2. What to do when you get stuck

Let’s talk first about getting started. Reading through my book and examples is great but when many new learners go to write their first macro they don’t know where to begin. They sit staring at their computer screen, frozen and confused. Here is the process I use when beginning any new macro, whether I’m making it for myself or someone else:

Come Up With a Plan by Asking Yourself These Important Questions

1. What would be the ideal macro solution be? This is always the first question I ask myself or my client when dealing with a complicated issue. Now, the ideal solution may in fact be impossible to obtain but at least we now have a clear, established goal to aspire towards.

2. What CATIA programming language you are most comfortable coding in: .catvbs, .CATScript, or .catvba? There are advantages and disadvantages to each macro language and it really comes down to what is the design intent.

3. What step by step process should the macro follow? Next, I want to get an overall idea of how the macro should work. It also helps to think about the steps the macro will need to perform. I often write out a flowchart, decision tree, or quickly sketch a process map. The decision tree pictured is for my Delete Deactivated Features CATScript that can be found on the downloads page.custom catia macro decision tree

Just like any other general engineering challenge, I like to take seemingly large problems and try to break them down into smaller, easier to solve components then put them all together again in the end for the final solution. I break the big problem down into smaller problems by asking more detailed questions, like:

4. Will this macro be used only on individual parts, or products? What will the active document be?

Example: If you’re dealing with a single part you will more than likely begin with:

 

There are instances, such as when you are taking a screen capture, where it doesn’t matter what the active document is.

5. What steps or inputs will the user need to do?  What information will the macro need to run? Most macros should be as easy as possible for the end user with minimal inputs – otherwise what is the point of automating the process if it takes a long time to set up?

Example: if a macro is going to translate a bunch of points, will the points be selected by a user before the macro is run, will the user manually select the points while the program is running, or will the macro use a search function to select them by name with no direct user interaction?

These are the type of things you need to think about before diving into the programming. Next, I’ll address what to do if you’ve answered all of the questions above but still don’t know the exact code.

Still stuck or confused? Continue to Part 2 where I explain what to do when you get stuck.