狮猿社Max狮猿社CATIA

CATIA caa 使用脚本语言调用CAA V5对象

2020-02-17  本文已影响0人  锦囊喵

原文链接
原文链接

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.

CAADoc\Doc\online\CAASysTechArticles\CAASysAutomationItf.htm

Steps for creating a sample CAA Application that can be accessed from VBscrpit (of CATIA.)

Step 1: Create a New Framework for IDL Interface creation in CAA-RADE

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.

Resolve the Common build error:

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

pragma REPREQ InfTypeLib in the // Prerequisite type libs

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.

Step 2 : Create a New Framework for Implementation.

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.

Steps for using CAA Object in the CATIA VBA Script.

  1. Start the CATIA Session and open the required file.

  2. Open VBA Editor by following

Tools> Macro > Visual Basic Editor.

  1. 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()

//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();

上一篇下一篇

猜你喜欢

热点阅读