Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Objective:
This Article describes the methodology of creating a CAA V5 object that can be
accessed from scripting languages. The step by step procedure of creating a
CAA V5 object( in Visual Studio 2005 ) and accessing the same from VBA
(CATIA) is also presented.
Description:
· For calling any CAA V5 object from simple scripting language we need to
use automation interfaces. Automation Interfaces are special interfaces that allow
CAA V5 programming from simple scripting languages.
The CAA V5 IDL (Interface Definition Language) is the language used to write
automation interfaces.
The CAA V5 IDL (Interface Definition Language) is dedicated to create
programming language independent interfaces that we can use from both a
compiled languages such as C++, and scripting languages such as Visual Basic
and JScript with Windows, and Basic Script with UNIX.
IDL provides C-language like declarations that associate an identifier with a type.
The IDL compiler (MIDL) builds the run time type library from IDL source files and
stores it in a shared library(Type Library or .tplib).
Scripting languages uses these type libraries (.tplib) to access the type
information about the functions. Actual function implementation is available in a
DLL.
The type library is a compiled version of a set of IDL files. It contains the
description of all the interfaces, all the method prototypes, properties, and all the
parameters they require along with their types.
The base interface for exposed interfaces that are used in scripting languages is
IDispatch interface. IDispatch interface derives from IUnknown interface.
Compared to C++, scripting languages have parameter type support restrictions.
The compatible parameters of the method signatures are available in the CAA
Encyclopedia at the following link.
CAADoc\Doc\online\CAASysTechArticles\CAASysAutomationItf.htm
Schematic Diagram showing how a VBA application access CAA Component.
2. Open VBA Editor by following: Tools> Macro > Visual Basic Editor.
3. Add the Type Library (.tplib) that we created.
Go to Tools>References and add the library by using Browse button.
1. Open a new Module and add the following lines of code after CATMain()
Example code:
Dim CATIATUTORObj As DrawingFactory
Set CATIATUTORObj = GetObject("", "CATIA.Application")
Call CATIATUTORObj.MyFunction();