In a post Clock animation in CATIA V5 drawing with VBA, I have already shown you, how to create a simple animation in a drawing. However, you are not limited only to a Drafting workbench, but with the help of VBA, you can force also your products to move. Let's create a clock animation in CATIA V5 product, but this time also with millisecond hand.
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.
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 :).
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.
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.
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.
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.
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.
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.
One of the most annoying CATIA features, especially when you work with large assemblies is reordering of specification tree in Products. Even as a programmer there is almost nothing you can do about it, because there is no direct way of reordering components in specification tree. Such a function has not been exposed to CATIA API yet. There are a few tools available on the internet and maybe you already use some of them. You may have even thought how the hell they work. So stop wondering, today I am going to show you how they (might) works :).