What to do when you get stuck

You’re trying to write your first CATIA macro and you’ve answered all the questions you needed to ask before you began but now you’re simply stuck and don’t know what to do next. Or maybe you’ve already written some code but it’s just not working the way you intended it to.

How in the world are we supposed to go on from this point? If you’re new to CATIA programming you’re likely going to be dead in the water at this point until you get some help. I’ve had many questions come in lately from beginner CATIA programmers who are stuck and don’t know where to go for help. That’s where I come in!

Before giving up, there are a few steps I recommend you take to try and figure the solution out for yourself. I strongly believe you learn more through struggling, overcoming obstacles, and doing it yourself. Here is my list of five things you should do if you consider yourself stuck writing a CATIA macro:

 

1. Use the CATIA Macro Recorder

The first step I recommend you to try if you’re stuck writing a CATIA macro is to use the macro recorder to record your actions of doing the process manually just to get an idea of what the code might look like. Start the macro recorder, perform the action, then look at the recorded code to get an idea of what the code looks like, then modify the program so it will work on other parts all the time. Remember, recorded macros do not contain any comments or explanations of what is happening in the code and input parameters are never recorded. There are no loops either.

I generally only use the macro recorder as a guide because it usually records a lot of extra lines of code that aren’t needed. This is based on the order of steps that you do as you record the macro. These unnecessary lines can be removed One way for you to learn what is needed is to comment out a line of code (by inserting an apostrophe at the beginning of the line) and then running the macro to see if it still works properly.

2. CATIA Documentation (Built-in features)catia object browser

 

CATIA has two built in features that can potentially help you solve your problems. The first is the CATIA object browser and is a great tool to use when you’re stuck and don’t know what to do next. While in the CATScript editor go to View>Object Browser (or simply hit F2) and  use the search bar.

 

The other feature is the CATIA Visual Basic Help Documentation (also known as CATIA Automation Documentation) that can be accessed using either the online help (if the complete CATIA Documentation is installed) or by opening the file:

<Catia_install_folder>\intel_a\code\biV5Automation.chm.

 catia automation documentation help

3. Look at Other Code Examples

A great way to learn is to see how other programmers solved similar problems. I’ve made a number of my CATIA macros available as a free download here. I often send sample macros in my email newsletter as well. Also, be sure to read all  of my free articles as well as many of them have custom code with thorough explanations of how they work.  Forums such as Eng Tips are also a create place to see CATIA macro examples.

 

4. Step Away From the Problem

This is actually my favorite tip here. There have been countless times where I’ve been banging my head against a wall, not able to figure out a problem. So, I would simply get up from my computer and walk away, maybe for a few hours or days, and not think about the problem at all. Then when I sit down in front of the screen again refreshed the answer hits me almost immediately. Seriously, this happens almost every time! It’s that whole not being able to see the forest through the trees type of thing. So take a break!

 

5. Use the Internet to Ask Questions

Google is your friend! If you don’t find a suitable answer on your first search try a new one with different words. Personally, there’s nothing that annoys me more than when someone asks me a question and I simply Google it and I find the solution right away. Don’t be lazy! Other people do not want to do your work for you.

If you’re still stuck and clueless about what to do next you can ask for help from another programmer or automation expert. Posting in the recommend forums listed on my Resources page is a great way to get feedback from multiple power users.

If all else fails you can contact me through email and I will attempt to get you going in the right direction (as my time and knowledge permits, please be patient). I hope you enjoyed reading about some of my CATIA macro troubleshooting techniques.