Play Tetris in CATIA V5 drawing


CATIA V5 as a gaming platform? Well, nothing is impossible. Thanks to the powerful VBA language, you can create simple games even in CATIA V5. But which game to choose? Good old Tetris is probably the best choice. Simple and addictive game is an excellent candidate to test CATIA as a game engine. And CATIA, as usual, did a great job.


Read More

Get point on a curve in CATIA V5 VBA


To create a point on a curve in CATIA V5 is a pretty simple task. Things get complicated if we need to repeat it in VBA. Although most of the information you need you can find also in CATIA V5 documentation, the lack of examples is a real problem. I would like to try to fill this gap and show you some of the functions you can use when you work with CATIA curves. And because I like when things are moving, we create an animation :).


Read More

Clock animation in a drawing with VBA


If you want to create an animation in CATIA, most of the time you use a DMU Kinematics workbench. However, simple animations can be performed without any dedicated CATIA module, just with a plain VBA code. Moreover, you can use VBA across workbenches and Drafting workbench is not an exception. I am going to show you, how you can create a simple animation in a CATIA V5 drawing.


Read More

Circular text in CATIA V5 drawings


Circular text in a drawing cannot be done easily using standard CATIA V5 commands. You can maybe put a letter into the required position, use a Rotate command to copy it along a circle and then edit letter text one by one. Or you can utilize the power of VBA.

A code below creates a circular text in a matter of milliseconds. All you have to do is to set some initial properties and let your computer do his job.


Read More

Lock/Unlock drawing views in VBA


Locking and unlocking of drawing views is a common task in CATIA V5. To save a time you can automate this operation with VBA macro. Following procedure checks the lock status of the first view in a CATIA V5 drawing and then sets all views to the opposite.


Read More

Export a product structure to Excel in VBA


To loop through the content of an assembly you can use programming technique called recursion. Recursion is a powerful concept where a procedure calls itself. Although it is not the most effective way how to write a code, there are cases when advantages of this technique overweight its drawbacks like higher memory usage or lower efficiency. Also, it is very important to design your recursive procedure to terminate the recursion properly otherwise you end up stuck in an infinite loop and Out of stack space error.


Read More

Export a CATIA table to Excel with VBA


This simple script copies the content of CATIA table into an Excel worksheet. Before launching it, please ensure that:

  • Active document is a CATIA drawing.
  • Active view contains a CATIA table.
  • If there are more tables in the active view only first one is going to be exported.


Read More

Sorting of objects by their properties in VBA


Sorting in VBA is a quite tricky task because VBA itself has no support for sorting values. You have to use an algorithm like QuickSort. But what if you want to sort objects? It is even worse and harder, algorithms become more complex and less clear. Luckily, you can again make use of mscorlib.dll library and with the help of ArrayList and IComparer interface, you can implement your own object sorting method.


Read More

Sort values in VBA without an algorithm


Sorting of values is a quite common programming task. VBA has no native sorting method. You can use algorithms like QuickSort to sort the array in place. However, there is another, maybe easier way how to sort your data without using algorithms.


Read More

SelectionSets object in CATIA VBA


Selection sets are nice CATIA feature to group and store selected elements of any type. They are pretty well described in V5Automation reference. The purpose of the methods of a SelectionSets object like CreateSelectionSet, DeleteSelectionSet or RenameSelectionSet is quite obvious, other methods like AddCSOIntoSelectionSet or PutSelectionSetIntoCSO are a bit less obvious, but at the first glance, we have enough to start with. However, there is no real-world example or use case which could help us at the beginning.


Read More