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.
· 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.
CAADoc\Doc\online\CAASysTechArticles\CAASysAutomationItf.htm
1. File > New CAA V5 Workspace
Select the Workspace directory and Tool Level.
2. In New CAA V5 Workspace dialog , select “New Generic frameworks”.
3. In the New Framework dialog select ‘Framework type” as Interface and select “IDL Support” option.
4. Create an Interface
Go to File>CAA V5 Item > Interface.
In the Insert Interface dialog, Provide the Interface name and Select language as “ Automation IDL”, Select Header repository as “PublicInterfaces”.
This module will generate .idl file.
If framework is not visible in the solution explorer then close the workspace, and delete the ToolsData Folder in the workspace and open the workspace in the VC again. And build the workspace using mkmk.
After the build an error will be generated saying that “unresolved type declaration : AnyObject [ Interface ‘Test’ ]”
Open the .MK file in the TypeLib.m module and delete : JS0GROUP \JS0FM JS0GROUP from the WIZARD_LINK_MODULES.
Open the .tplib file from the same module and add the following macro in the Prerequisite type libs after #pragma REPREQ InfTypeLib
Build the work space using mkmk.
A Successful built will produce a TypeLibrary that corresponds to the IDL and a DLL that corresponds to Interface.
1. File>Add CAA V5 project > New Framework.
Select Framework type as “Implementation” and complete the framework creation.
2. Insert a new module in the above Framework
File> Add CAA V5 project—New Module.
3. In New Module dialog select Shared Object option under the Module Information options.
4. Add new Item to the created Module.
File>Add CAA V5 Item>Component.
6. In the Insert Component Dialog provide the following information.
For Derived from option provide “ CATBaseObject “.
In the TIE Mode option ADD the created Interface.
In the Header Repository select “ Public Interfaces”.
Build the Workspace, this generates a DLL (Shared Library) that corresponds to Implementation Module.
Tools> Macro > Visual Basic Editor.
Go to Tools>References and add the library by using Browse button.
//Declare a Variable of type VB Object name, this VB object name is available in the IDL file that we created in Step 1.
1. Dim (Variable Name) As (VB Object Name)
// Set the Variable to the CATIA Application.
2. Set (Variable Name) = GetObject(“”, “CATIA.Application”)
// Call the Method or Function in the interface
3. Call (Variable Name) . (Method Name).
Example code:
Dim CATIATUTORObj As DrawingFactory
Set CATIATUTORObj = GetObject(“”, “CATIA.Application”)
Call CATIATUTORObj.MyFunction();