Wednesday, November 16, 2011

How does VB.net code interact with CATIA?

In order to understand how VB.net code talks to CATIA we need to answer two other questions:


First, what does dll stand for? In the world of computer software DLL stands for Dynamic Linked Libraries. These are compiled files that contain all of the functions that make CATIA V5 (or other software) perform an action. For example, when you select the “point” function in CATIA, the program calls a function inside one of the dll files that performs the action of creating a point in the V5 database. These files are both compiled and encrypted or “mangled”. This is a mechanism by which software companies can ensure that others cannot access the functions inside the dll’s. Therefore you cannot directly call the dll’s from outside applications. To allow outside applications to call these functions, extra programming needs to be done. This extra programming allows certain functions (not all of them) from the dll’s to be “exposed” to Windows and the COM object model – this is done via tlb files.


This brings us to our second question, what does tlb stand for? TLB stands for Type Library Files which are necessary for “exposing” functions to Windows. They act as maps which point to the mangled functions inside of the dll files that make CATIA V5 work. For example, DS may expose a function called Point(X,Y,Z) which takes 3 arguments (the x, y, and z values of the point). This function is defined and compiled in the type library, but it actually only points to the specific spot in one of the dll’s where the function exists to create a point. This means that for each major Release of V5, the type libraries must exactly match the dlls – therefore you need to make sure that you are using the correct versions of the type libraries when you do any automation. Any external programming IDE needs to have access to these type libraries in order.


Visual Studio, Visual Basic Express, or other applications MUST reference type library files that make the application “aware” of all of the CATIA functions that have been exposed. There are currently over 40 of these type libraries for CATIA – they are broken up by discipline (i.e. surface design, part design, etc.).  Only the type library for the discipline that you are going to use should be referenced. If you only need to automate surface design, then only “reference” the surface design type library in your programming project.


Also, please keep in mind that the type libraries are changed with each release of CATIA V5, so the correct type libraries MUST be used with the correct version of CATIA (ie, R19, R20, etc.). Not all CATIA V5 functions have been exposed in the type libraries.

Learn how to write CATIA Macros. 

1 comment:

  1. I am having trouble getting the correct tlb's to work for my version of CATIA. if my computer has say R23 installed, how do I force my code to use R21 TLB's? and once I've done that, is there a way to make sure I can pull the TLB's dynamically on startup?

    ReplyDelete

I'd love to hear from you!