CATIA macro and Excel
“Your connections to all the things around you literally define who you are” Aron D. O’Connell
Excel and CATIA are one of the most used programs in the world, so a combination of these two pushes boundaries even more. CATIA software engineers made a lot of connections with the excel possible. Some examples of these implementations are Part parameterization (excel table is used to store info about part variants), Export stock lists in Excel table, control design, etc.
Absolutely when we talk about CATIA macros and automation, Excel is also very important. Previously we mentioned stock lists. The only logical way to get data from model and store in Excel file in order to fill those stock lists is to use CATIA macro.
Having this in mind we decided to write this post and help you overcome unknown about this subject.
There are a lot of questions about this subject, such as http://www.coe.org/p/fo/et/thread=27860
In addition, we think that you will be able to overcome the problems described in this forum posts, after reading this post.
Examples of CATIA macro and Excel connection
Furthermore there a lot of options when we talk about communication between CATIA macro and Excel. So we will try to show you the most common.
Before that, we need to start an Excel application and set some basic things.
Now we can go furthermore and do some action too. So one of the most common actions is to write in an Excel cell. It’s one very simple line however in general, it will certainly do everything, depending on how you use it. You can put in any kind of loop in addition to get a lot. Of course you just need to specify in which cell you want to write.
Indeed a loop is basic stuff in any kind of code. Let’s make a simple combination of the previous line and for loop to write numbers from 1 to 10.
Also, we can write in both directions using two for loops.
Those were options for writing into an Excel cell. You can also retrieve info from cells. We used a MsgBox command to do it. Of course, you can pass this info anywhere you want.
Almost all infos from CATIA are stored in some sort of table. Here are just basic info about cell width and color, of course, there are a lot of options to set about the cell.
Finally, we will use all of these information mentioned before in order to create a little bit more advanced macro. There a lot of questions about exporting points coordinates from CATIA to Excel. So there are a few steps. Firstly, we need from user to select points. After that use for loop to control data extraction from selection and also to export all info we need in Excel table.
Also if you want to read more about multiple selections please visit this CATIA macro selection
Here is the full code of this macro. Using these simple methods we showed that it can absolutely achieve a lot in automation.