CATIACAA二次开发详细教程
CATIA二次开发CAA培训课件

类型选择
第一章 CAA二次开发一般步骤
1.程序的建立
1.1 工程的建立
确定Workspace 的创建。
第一章 CAA二次开发一般步骤
1.程序的建立
1.1 工程的建立
确定后VC文件视图如 下:
此时生成了一个带有一个Framework 的Workspace。CAA的开发提供了两 种模式:批处理模式(Batch Mode) 和交互模式(Interactive Mode)。 我们开发主要用到的是交互模式。在 此模式下,可以创建两种交互界面: Workshop(Workbench)和Addin。 前者是创建一个新的模块,在这个模 块中除了标准的命令,其余均由用户 开发。后者指在已经存在的 Workbench中插入新的工具条和命令。
第一个参数是按钮的名字,第二、三个代表按钮执行的命令所在 的module和命令的名字,参数四缺省。
第一章 CAA二次开发一般步骤
3.创建Addin
(3)创建工具条和菜单,添加两个函数
CATCmdContainer * MyAddin::CreateToolbars() { NewAccess(CATCmdContainer,pPartBenchTlb,PartBenchTlb);
2.添加Workbench
2.4 定义资源
在文件:MyWkb.CATNIS中,可以定义此 Workbench以及其工具条、菜单的所有名 字(Title),定义格式为: MyWkb.Title="MyWkb title";
第一章 CAA二次开发一般步骤
2.添加Workbench
2.4 定义资源
第一章 CAA二次开发一般步骤
3.创建Addin
CAA插件的开发方法(CATIA二次开发)

插件的开发方法2004-8-24一、创建插件接口1.1 头文件如:#ifndef CAAIAfrGeoCreationWkbAddin_h#define CAAIAfrGeoCreationWkbAddin_h// ApplicationFrame Framework#include <CA TIWorkbenchAddin.h>// Needed to derive from CATIWorkbenchAddin// Local Framework#include "CAAAfrGeoCreationWbench.h" // Needed to export the IID// Global Unique IDentifier defined in .cpp// exported by CAAAfrGeoCreationWbenchextern IID ExportedByCAAAfrGeoCreationWbench IID_CAAIAfrGeoCreationWkbAddin;class ExportedByCAAAfrGeoCreationWbench CAAIAfrGeoCreationWkbAddin : public CATIWorkbenchAddin {// Used in conjunction with CATImplementInterface in the .cpp fileCA TDeclareInterface;public:};#endif1.2 源文件1.2.1 组成1)接口标识符(IID)构造2)接口实现1.2.2 实例如:#include <CAAIAfrGeoCreationWkbAddin.h>// Use uuid_gen -C on UNIX or uuidgen -s on NT to generate the IIDIID IID_CAAIAfrGeoCreationWkbAddin = { /* a4188b88-d4c1-11d3-b7f5-0008c74fe8dd */0xa4188b88,0x11d3,{0xb7, 0xf5, 0x00, 0x08, 0xc7, 0x4f, 0xe8, 0xdd}};// Declares that CAAIAfrGeoCreationWkbAddin is an interface that// OM-derives from CATIWorkbenchAddinCATImplementInterface(CAAIAfrGeoCreationWkbAddin, CATIWorkbenchAddin);1.3 TIE文件1.3.1 内容头文件引用1.3.2 实例如:// Used by mkmk to create TIE_CAAIAfrGeoCreationWkbAddin.h#include <CAAIAfrGeoCreationWkbAddin.h>详见《接口开发》二、插件开发2.1 头文件2.1.1 结构#ifndef <插件类>_H#define <插件类>_H// System framework#include "CATBaseUnknown.h" // Needed to derive from CATBaseUnknown// ApplicationFrame framworkclass CATCmdContainer; // Needed by CreateToolbarsclass <插件类> : public CATBaseUnknown{// Used in conjunction with CATImplementClass in the .cpp fileCATDeclareClass;public:<插件类> (); //构造函数virtual ~<插件类> (); //析构函数// Instantiates the command headers for the commandsvoid CreateCommands(); //定义命令标签// Creates toolbars and arranges the commands insideCA TCmdContainer * CreateToolbars(); //创建菜单和工具条private:};#endif2.1.2 实例#ifndef CAAAfrGeoOperationAdn_H#define CAAAfrGeoOperationAdn_H// System framework#include "CA TBaseUnknown.h" // Needed to derive from CATBaseUnknown// ApplicationFrame framworkclass CATCmdContainer; // Needed by CreateToolbarsclass CAAAfrGeoOperationAdn : public CATBaseUnknown{// Used in conjunction with CATImplementClass in the .cpp fileCA TDeclareClass;public:CAAAfrGeoOperationAdn();virtual ~CAAAfrGeoOperationAdn();// Instantiates the command headers for the commandsvoid CreateCommands();// Creates toolbars and arranges the commands insideCA TCmdContainer * CreateToolbars();private:};#endif2.2 源文件2.2.1 定义命令标签类如:2.2.2 建立“联结(TIE)”对象指定插件插入的交互界面,如:1)界面#Include “TIE_CATIShapeDesignWorkshopAddin.h”;TIE_CATIShapeDesignWorkshopAddin(CAAEMmrCombinedCurveAdn);2)“零件设计(Part Design)”界面#include <TIE_CATIPrtWksAddin.h>TIE_CATIPrtWksAddin(CAAMmrDebugAdn);2.2.3 声明插件类CATImplementClass(CAAMmrDebugAdn, DataExtension, CATBaseUnknown,CAAMmrDebugAddin);2.2.4 更新接口字典文件2.2.4.1 字典文件名<框架>.dico2. 2.4.2 存放目录<>\CNext\Code\Dictionay2. 2.4.3 语句如插入如下结构的语句行:<接口实现类> <TIE接口类> <共享库名>如:CAAMmrCombinedCurveAddin CA TIShapeDesignWorkshopAddin libCAAMmrCombinedCurveAddIn其中:(1)<接口实现类>在CATImplementClass中指定,如CAAMmrCombinedCurveAddin:CATImplementClass ( CAAEMmrCombinedCurveAdn ,DataExtension ,CA TBaseUnknown ,CAAMmrCombinedCurveAddin );(2)<TIE接口类>TIE语句中所定义,如CATIShapeDesignWorkshopAddin:TIE_CATIShapeDesignWorkshopAddin(CAAEMmrCombinedCurveAdn);2.2.5 编制构造函数与析构函数2.2.6 定义命令标签(CreateCommands)和创建菜单/工具条(CreateToolbars)如:// Local Framework#include "CAAAfrGeoOperationAdn.h"// ApplicationFrame Framework#include <CA TCreateWorkshop.h>// Creates the CAAAfrGeoOperationAdnHeader command header class#include "CA TCommandHeader.h"MacDeclareHeader(CAAAfrGeoOperationAdnHeader);// To declare that the class// is a DataExtension of (late type) CAAAfrGeoOperationAddinCATImplementClass(CAAAfrGeoOperationAdn,DataExtension, CA TBaseUnknown,CAAAfrGeoOperationAddin(在接口字典中定义,见下句));// To create the TIE Object (即设置指向本插件的接口)(****)#include <TIE_CAAIAfrGeoCreationWkbAddin.h>TIE_CAAIAfrGeoCreationWkbAddin(CAAAfrGeoOperationAdn);// To declare that CAAAfrGeoOperationAddin implements CAAIAfrGeoCreationWkbAddin, insert// the following line in the interface dictionary: (???????功用)//CAAAfrGeoOperationAddin CAAIAfrGeoCreationWkbAddin libCAAAfrGeoCreationWkbAddin//---------------------------------------------------------------------------CAAAfrGeoOperationAdn::CAAAfrGeoOperationAdn(){}CAAAfrGeoOperationAdn::~CAAAfrGeoOperationAdn(){}void CAAAfrGeoOperationAdn::CreateCommands(){// Instantiation of the header class created by the macro MacDeclareHeader -// commands are always available and are represented by a push buttonnew CAAAfrGeoOperationAdnHeader("CAAAfrUnionHdr" ,"CommandLib","CommandName",(void *)NULL);new CAAAfrGeoOperationAdnHeader("CAAAfrSubstractHdr","CommandLib","CommandName",(void *)NULL);new CAAAfrGeoOperationAdnHeader("CAAAfrFilletHdr" ,"CommandLib","CommandName",(void *)NULL); }CATCmdContainer * CAAAfrGeoOperationAdn::CreateToolbars(){// CAAAfrOperationTlb ToolbarNewAccess(CATCmdContainer,pCAAAfrOperationTlb,CAAAfrOperationTlb);NewAccess(CATCmdStarter,pCAAAfrTUnionStr,CAAAfrTUnionStr);SetAccessCommand(pCAAAfrTUnionStr,"CAAAfrUnionHdr");SetAccessChild(pCAAAfrOperationTlb,pCAAAfrTUnionStr);NewAccess(CATCmdStarter,pCAAAfrTSubstractStr,CAAAfrTSubstractStr);SetAccessNext(pCAAAfrTUnionStr,pCAAAfrTSubstractStr);NewAccess(CATCmdStarter,pCAAAfrTFilletStr,CAAAfrTFilletStr);SetAccessCommand(pCAAAfrTFilletStr,"CAAAfrFilletHdr");SetAccessNext(pCAAAfrTSubstractStr,pCAAAfrTFilletStr);//----------------------// Menu bar (?????)NewAccess(CATCmdContainer,pCAAAfrOperationMbr,CAAAfrOperationMbr);// menu Tools with three new commandNewAccess(CATCmdContainer,pCAAAfrOperationToolsMnu,CA TAfrToolsMnu);SetAccessChild(pCAAAfrOperationMbr,pCAAAfrOperationToolsMnu);NewAccess(CATCmdSeparator,pCAAAfrOperationToolsSep,CAAAfrOperationToolsSep);SetAccessChild(pCAAAfrOperationToolsMnu,pCAAAfrOperationToolsSep);NewAccess(CATCmdStarter,pCAAAfrMUnionStr,CAAAfrMUnionStr);SetAccessCommand(pCAAAfrMUnionStr,"CAAAfrUnionHdr");SetAccessNext(pCAAAfrOperationToolsSep,pCAAAfrMUnionStr);NewAccess(CATCmdStarter,pCAAAfrMSubstractStr,CAAAfrMSubstractStr);SetAccessCommand(pCAAAfrMSubstractStr,"CAAAfrSubstractHdr");SetAccessNext(pCAAAfrMUnionStr,pCAAAfrMSubstractStr);NewAccess(CATCmdStarter,pCAAAfrMFilletStr,pCAAAfrMFilletStr);SetAccessCommand(pCAAAfrMFilletStr,"CAAAfrFilletHdr");SetAccessNext(pCAAAfrMSubstractStr,pCAAAfrMFilletStr);// Set the menu// pCAAAfrOperationTlb: Always the toolbar returned by the method// pCAAAfrOperationMbr: The container which contains all the menu's containersSetAddinMenu(pCAAAfrOperationTlb,pCAAAfrOperationMbr); (?????)// Invisible toolbarAddToolbarView(pCAAAfrOperationTlb,-1,Right);// Pointer of the first toolbar createdreturn pCAAAfrOperationTlb;}。
CATIA CAA关于workbench和adding的二次开发

本文介绍的实例将在MechenicalDesign(机械设计)中插入一个名为“测试工作台”的Workbench,内容非常基础,每个步骤尽可能描述的非常详细,供初学者参考。
具体步骤如下:1. 准备工作参照前面的步骤,创建一个解决方案和一个Framework,并将解决方案与CATIA的系统接口建立连接。
该过程参见《CATIA二次开发CAA培训课件》2. 新建Workbench3.1 选择“文件->Add CAAV5 Item->CATIA Resources->CATIA Pattern”命令:在弹出对话框中选择“Workshop”并点击OK按钮:3.2 在新弹出的对话框中选择对象的类型为Workbench,在Work Object Name栏输入Workbench的名称。
然后点击Associated Workshop输入框后面的“…”按钮,这里选择PRDWorkshop,即为Product空间。
在新创建的Workbench中,会包含Product空间的一些基本标准命令,如插入产品等。
如果选择Part空间,则会包含Part空间的一些基本命令。
设置完成后点击OK,最终状态如下:3.3 点击Next:3.4 该设置界面保持默认即可,点击Next,进入参数设置界面:也保持默认,点击Finish,在最后弹出的信息确认对话框中直接点击OK。
3.5 选择“项目->Select CAA V5 Projects …”:在弹出的窗口中将刚才新建立的TestWb模块载入到开发环境中:将MyTestWbk.m设置成当前启动项目:现在的目录结构如下图所示:Workbench的资源文件保存在下图所示的位置:3. 编译(mkmk)工程点击“生成->mkmk ”,编译新建的Module。
4. 运行CNEXT查看效果点击Tools->Open Runtime Window ,打开命令框。
输入“cnext”打开CATIA。
CATIA-CAA二次开发教程

CATIA CAA V5R19 二次开发详细教程CAA,全称C omponent A pplication A rchitecture,组件应用架构。
CAA架构CATIA本身是按照组件模型建立起来的,用户可以通过开发自己的CAA组件,对DASSAULT SYSTEMES的CATIA V5进行扩展;也可以把用户自己开发的CAA组件结合起来,实现用户自定义应用。
CAA应用的框架结构遵从组件对象模型,有自己的框架结构。
每个应用有至少一个框架(framework),每个框架有至少一个模块(module)。
每个框架里面有一个IdentityCard.h 文件,这个文件通过宏“AddPrereqComponent(framenwork,protected)”来声明“声明”这个框架的一些首先必备的其他框架名称,framework是框架名称。
CAA的编译器就是通过IdentityCard.h文件,来把头文件搜索限制在首先必备框架所包含的接口中。
每个模块下面定义了一个Imakefile.mk文件,这个文件指明了这个模块中所有文件在编译时用到的其它模块和一些外部库以及为编译器提供如何编译的模块必须信息,还指定在不同的操作系统下面编译时的一些可能的特殊要求。
CAA环境对Cnext能够运行的所有操作系统中采用同样的编译器,这为开发者提供了很大的方便,因为他们可以不需要知道怎样用不同的编译器和怎么写makefile。
但是MKMK并不能做所有的事情,开发者至少要说明他们想要做什么。
我们在自己的源文件中用到其它模块的接口,要在Imakefile.mk中进行说明。
程序结构采用了COM组件模型,组件模型中有两个常用的概念:接口(Interface)和实现(Implement)。
接口是一个包含许多纯虚函数的抽象对象,这些纯虚函数指明了接口支持的方法。
实现是一个具体定义接口中的方法的对象,一个实现对象必须显式声明它支持哪些接口,还必须定义它支持的接口中的所有抽象方法,实现对象可以支持一个或多个接口,而客户应用只能通过这些接口与实现对象发生联系。
CATIA CAA 二次开发程序的发布甄选.

CATIA CAA 二次开发程序的发布#.CATIA CAA 二次开发程序的发布1.发布条件:已安装了CATIA,版本不能低于开发使用的CAA版本。
CAA代码成果物“intel_a”文件中的所有文件。
其他版本的CATIA与此类似。
1.发布方法:2.将“intel_a”文件存放在要发布机器上,存放“intel_a”文件的路径最好不要有中文字符和空格。
(例:E:\VCINewFromExisting\intel_a)3.点击”开始” –> ”所有程序” –> “CATIA P3” –> “Tools” –>”Environment Editor V5R19”1.点击“确定”。
1.选择”Environment” –> “New”1.“Name” 栏为将要创建的桌面快捷方式的名称;在”Install Path” 栏中,CATIA的安装路径后输入”; E:\VCINewFromExisting\intel_a”,这是要发布的intel_a的存放路径;其他如图所选,采取默认设置。
完成后点击”OK”。
1.至此发布完成,在桌面上会生成一个名为”NewFromExisting”的CATIA类型图标。
双击该图标,会启动CATIA,用户便可使用CATIA原所有功能和新发布的功能。
1.与原CATIA图标集成发布方法:设:Catia的工作目录是 D:\DS\B19\intel_a;已开发插件的工作目录是D:\MyAddin\intel_a;将D:\MyAddin\intel_a下这些文件复制到D:\DS\B19\intel_a对应的位置,即可在运行Catia时候自动加载插件:code \ bin \ *.dll;\ code \dictionary \ *.dico;\ code \ productIC \ *.script;\ code \ productIC \ *.xml;\ resources \ graphic \ icons \ normal \ *.bmp;\ resources \ msgcatalog \ *.CATNls;\ resources \ msgcatalog \ *.CATRsc;感谢您使用本店文档您的满意是我们永恒的追求!(本句可删)------------------------------------------------------------------------------------------------------------。
CATIA CAA 二次开发详细教程 (2)-添加Workbench

CATIA CAA 二次开发第二讲:添加Workbench这一部分很重要请注意认真看,说它重要是因为在后面程序的调试中可能会出现错误,请你务必在安装开发vc环境的时候注意,在安装vc的时候记得有个地方自己选,最好你都装了,如果你没有装也没有关系,到时候从vc的安装文件里面考出来也可以,就是关于RA DE中会用到的lib库,在vc中的目录为vc98/mfc/lib目录下,如果你调试出现问题,比如error没有找到mfc42u.lib或者别的你就要从安装盘里面把所有的lib里面的文件考到你的vc对应安装目录下。
1.2进入正题新建工作空间你按照我以前的帖子安装完开发环境在vc下面就有了RADE的菜单找个标签页你可以选择下面的复选框,以后新建工程的时候就不会弹出了,然后选择ok你可以先建立你的开发目录然后选择Workspace Directory的时候指定目录,with就选择m kmk,tool level选择你的版本。
点击next选择创建一个新的框架frame,然后finish,弹出new framework对话框,输入你的frame 名字,下面的选择如图所示,framework t’ype-implementation,framework function -development,然后ok弹出下面的配置对话框然后ok,dos窗口闪动几下就可以了1.创建module有了工作空间和框架下面就是添加module了,好像你做的所有开发都在module里面(我也是刚入门,很多东西还不懂^_^)Project目录下面选择new module弹出下面的对话框输入你的module名字,module information选择shared object,也就是交互式(caa的开发分为交互式和批处理,听似水年华这么跟我讲的^_^),然后ok。
弹出下面的产生文件对话框然后点击ok,你的module就添加到workspace里面了,在vc的fileview窗口如下所示:1.载入必须的API函数选择菜单如下所示:弹出如下的对话框Mode选择第一项,然后点击add,添加函数所在目录,选到你的catia目录下面的B14,一定要选对。
CATIA CAA 二次开发详细教程 (3):添加Addin(菜单、对话框)
CATIA CAA 二次开发第三讲:添加Addin(菜单、对话框)下面简单介绍addin的制作:所谓Addin,是在系统已有的Workbench中插入新的工具条或者菜单。
下面的例子,我们来在PartDesign中插入一个工具条。
1、新建一个module命名为PartAddin,并将它设为active。
2、做接口CATIPrtWksAddin的implemention,insert->component,弹出对话框如图,输入addin的名字,点击add再点击浏览选择要执行的接口,如图。
要选择的接口为CATIPrtWksAddin注意Search workspace为你的CATIA安装路径,并将下面的单选框设为空。
点ok完成。
文件相应的试图如下:3、此时建立了一个空的Addin。
在yourframe.dico文件中可以看到这个Addin的声明:NewAddin????? CATIPrtWksAddin? libPartDesignAddin但是,要创建一个工具条,我们还需要在这个类:NewAddin中添加一些函数。
在NewAddin类中添加两个Public函数声明:void CreateCommands();CA TCmdContainer * CreateToolbars();在NewAddin.cpp中添加宏定义:#include "CATCommandHeader.h"???????MacDeclareHeader(PartCmdHeader);这两个函数及宏都可以按ctrl+F1查到,CreateCommands里面的代码只是用MacDeclareHeader生成的PartCmdHeader定义命令的header(不知道怎么翻译,就是工具条或菜单里面可以看到的执行命令的按钮了,这个命令是连接界面命令和实现代码的桥梁。
)如:?new PartCmdHeader(“point”,“CmdModule”,“TestCmd”,(void *)NULL);new PartCmdHeader("line","CmdModule","LinCmd",(void *)NULL);第一个参数是按钮的名字,第二、三个代表按钮执行的命令所在的module和命令的名字,参数四缺省就行了。
CAA用户界面开发——实例说明(CATIA二次开发)
用户界面开发——实例说明——Creating a Workbench一、目标1.1 目标Showing how to create a workbench to be added to a given workshop.1.2 显示界面(workbench )Like the workshop, the workbench is an object that gathers the commands to work on the document and arrange them in toolbars and menus.1.3 命令标签(command header )Command headers are used to make the link between the workbench and the commands.二、CAAAfrGeoCreationWbench 实例说明2.1 功能The CAAAfrGeoCreationWbench use case creates a workbench named CAA Geometrical Creation for the CAAGeometry document. Its specifications cover most of the cases you will meet. Two toolbars areprovided:The Solids toolbar. It includes five new commands: Cuboid, Sphere, Torus,and Cylinder 1 and 2.The Surfaces toolbar. It includes three new commands: Revolution Surface,Nurbs Surface, and Offset Surface.The only change in the menu bar is the addition of these commands in the Insert menu using twosubmenus below the existing ones.2.2 运行运行CATIA系统,并依次选择Start->Infrastructure->CAA V5: Geometrical Creation:This creates a new CAAGeometry document with the CAA V5: Geometrical Creation workbench active.2.3 框架组成CAAAfrGeoCreationWkb Workbench description class CAAAfrGeoCreationWkbFactory Factory class for the workbench class CAAIAfrGeoCreationWkbFactory Factory interface implemented by CAAAfrGeoCreationWkbFactory TIE_CAAIAfrGeoCreationWkbFactory TIE class for the factory interfaceCAAIAfrGeoCreationWkbAddin Add-in interface exposed by the workbench and that all its add-ins must implementTIE_CAAIAfrGeoCreationWkbAddin TIE class for the add-in interface三、程序结构(Step-by-Step)3.1 编程准备3.1.1 确认∙Make sure that the workshop to which it is dedicated exposes the CATIxxxConfiguration interface, where xxx is the workshop identifier, in a PublicInterfaces or ProtectedInterfaces directory.∙Create the module directory to store the workbench code along with its two subdirectories LocalInterfaces and src. Then you will need to create the following files.In the framework's ProtectedInterfaces directoryCAAIAfrGeoCreationWkbAddin.h The header file of the workbench exposed interfaceto enable clients to create add-ins In the CAAAfrGeoCreationWbench.m\LocalInterfaces directoryCAAIAfrGeoCreationWkbFactory.h The header file of the workbench factory interface CAAAfrGeoCreationWkbFactory.h The header file of the workbench factory classCAAAfrGeoCreationWkb.h The header file of the workbench description class In the CAAAfrGeoCreationWbench.m\src directoryCAAIAfrGeoCreationWkbAddin.cpp The source file of the workbench exposed interfaceto enable clients to create add-ins CAAIAfrGeoCreationWkbFactory.cpp The source file of the workbench factory interface CAAAfrGeoCreationWkbFactory.cpp The source file of the workbench factory classCAAAfrGeoCreationWkb.cpp The source file of the workbench description class TIE_CAAIAfrGeoCreationWkbAddin.tsrc The file to create the TIE forCAAIAfrGeometryWksAddinTIE_CAAIAfrGeoCreationWkbFactory.tsrc The file to create the TIE forCAAIAfrGeometryWksFactoryIn the dictionary, that is the CNext\code\dictionary directory, referenced at run time using theCATDictionaryPath environment variable, create or update.dico The interface dictionary.fact The factory dictionaryIn the CNext\resources\msgcatalog directory, referenced at run time using theCATMsgCatalogPath environment variableCAAAfrGeoCreationWkb.CATNls The workbench message fileThe command header resource files CAAAfrGeoCreationWkbHeader.CATNls andCAAAfrGeoCreationWkbHeader.CATRsc3.1.2 开发步骤# Step Where1 Create the workbench factory interface LocalInterfaces and src2 Create the workbench factory LocalInterfaces and src3 Create the workbench description class LocalInterfaces and src4 Create the command headers CreateCommands method5 Create the workbench and arrange the commands CreateWorkbench method6 Provide the resources and insert the workbench into the Start menu Resource files7 Create the workbench exposed interface ProtectedInterfaces and src 3.2 建立Workbench 的Factory Interface(Creating the Workbench Factory Interface)3.2.1 命名CAAIAfrGeoCreationWkb Factory3.2.2 头文件(the header file )CAAIAfrGeoCreationWkbFactory.hA factory interface is a CAA interface, that is, an abstract class that derives from CATIGenericFactory.As any interface, it has an IID declared as IID_ followed by the interface name, and includes the CATDeclareInterface macro that declares that this abstract class is an interface. No additionalmethod than those of CATIGenericFactory is necessary. Don't forget the public keyword required by the TIE compiler.(???)3.2.3 源文件(The source file )CAAIAfrGeoCreationWkbFactory.cpp#include <CAAIAfrGeoCreationWkbFactory.h>IID IID_CAAIAfrGeoCreationWkbFactory = {0xb32eed10,0xd4c1,0x11d3,{0xb7, 0xf5, 0x00, 0x08, 0xc7, 0x4f, 0xe8, 0xdd}};CATImplementInterface(CAAIAfrGeoCreationWkbFactory, CATIGenericFactory);The CATImplementInterface macro is used in conjunction with CATDeclareInterface in the header file to make an interface from this abstract class and to declare that it OM-derives fromCATIGenericfactory.3.2.4 TIE文件(The TIE tsrc file)The Multi-Workspace Application Builder (mkmk) will generate the TIE for this interface for you, that is, the TIE_CAAIAfrGeoCreationWkbFactory.h file in the ProtectedGenerated directory.3.3 建立Workbench 的Factory(Creating the Workbench Factory)3.3.1 注意事项The factory class that creates workbench instances must concatenate the name of the class to instantiate, that is, the workbench description class CAAAfrGeoCreationWkb, with the string Factory. This gives CAAAfrGeoCreationWkbFactory.3.3.2 头文件CATDeclareConfigurationFactoryclass.3.3.3 源文件The CATImplementConfigurationFactory arguments are the name of the workbench description class and the name of the workbench factory interface respectively. TheCATDeclareConfigurationFactory and CATImplementConfigurationFactory macros create the workbench factory implementation class as a data extension of the CATApplicationFrame component3.3.4 更新字典3.3.4.1 The interface dictionarythat is a file whose name is the framework name suffixed by dico, such as CAAApplicationFrame.dico, and that you should create or update in the framework CNext/code/dictionary directory. The interface dictionary contains the following declaration to state that the CATApplicationFrame component implements the CAAIAfrGeoCreationWkbFactory interface, by means of the extension class created by the macros, whose code is located in the libCAAAfrGeoCreationWbench shared library or DLL:(不太明白)3.3.4.2 The factory dictionarythat is a file whose name is the framework name suffixed by fact, such as CAAApplicationFrame.fact, and that you should create or update in the framework CNext/code/dictionary directory. The factory dictionary contains the following declaration to state that the CAAIAfrGeoCreationWkbFactory interface is anclass instance:3.4 定义与实现Workbench 类(Creating the Workbench Description Class)3.4.1 说明The CAAAfrGeoCreationWkb class implements the CATICAAAfrGeometryWksConfiguration interface exposed by the CAAGeometry workshop . It includes the following methods:∙CreateCommands to instantiate the command headers for the commands of the workbench∙CreateWorkbench to create the containers for the workbench, the menus, and the toolbars, and arrange the commands in the menus and toolbars∙GetCustomInterface s which returns the names of the interfaces exposed by the workbench to enable its customizationGetAddinInterface which returns the name of the interface exposed by the workbench to create add-ins.3.4.2 头文件CAAAfrGeoCreationWkb.h#include "CATBaseUnknown.h"#include "CATListPV.h"class CATCmdWorkbench;class CAAAfrGeoCreationWkb : public CATBaseUnknown{CATDeclareClass;public:CAAAfrGeoCreationWkb();virtual ~CAAAfrGeoCreationWkb();void CreateCommands();CATCmdWorkbench * CreateWorkbench();CATClassId GetAddinInterface();void GetCustomInterfaces(CATListPV * oDefaultIIDList ,CATListPV * oCustomIIDList) ;private:CAAAfrGeoCreationWkb(const CAAAfrGeoCreationWkb &iObjectToCopy);};The CAAAfrGeoCreationWkb class C++-derives from CATBaseUnknown. The CATDeclareClass macro declares that the class CAAAfrGeoCreationWkb belongs to a component. The class has a constructor, a destructor, the four methods of the CATIWorkbench interface, and a copy constructor.Note that the copy constructor is set as private. This prevents the compiler from creating the copy constructor as public without you know. This copy constructor is not implemented in the source file.3.4.3 源文件TIE_CATICAAAfrGeometryWksConfiguration(CAAAfrGeoCreationWkb);CAAAfrGeoCreationWkb::CAAAfrGeoCreationWkb() {}CAAAfrGeoCreationWkb::~CAAAfrGeoCreationWkb() {}void CAAAfrGeoCreationWkb::CreateCommands(){... // See Creating the Command Headers}CATCmdWorkbench * CAAAfrGeoCreationWkb::CreateWorkbench(){... // See Creating the Workbench and Arranging the Commands}CATClassId CAAAfrGeoCreationWkb::GetAddinInterface(){return "CAAIAfrGeoCreationWkbAddin";}void CAAAfrGeoCreationWkb::GetCustomInterfaces(CATListPV * oDefaultIIDList,CATListPV * oCustomIIDList){}3.4.3.1 TIE_CATICAAAfrGeometryWksConfiguration 宏The CAAAfrGeoCreationWkb class states that it implements the CATICAAAfrGeometryWksConfiguration interface3.4.3.2 TIE_ CATImplementClass宏declaring that the CAAAfrGeoCreationWkb class is a component main class [2], thanks to the Implementation keyword, and that it OM-derives from CATBaseUnknown [2]. The fourth parameter must always be set to CATNull for component main classes.3.4.3.3 创建命令标签(Creating the Command Headers)(见《命令标签》)3.4.3.3.1 命令标签Each command available in your workbench must have a command header. A command header is an instance of a command header class, and different commands can share the same command header class to create their command header.3.4.3.3.2 创建命令标签类The MacDeclareHeader macro creates the header file and the source file for the CAAAfrGeoCreationWkbHeader class, and associates with this class the resource files CAAAfrGeoCreationWkbHeader.CATNls and CAAAfrGeoCreationWkbHeader.CATRsc.3.4.3.3.3 定义命令标签Create the code to instantiate your command headers in the empty CreateCommands method. This method should contain one instantiation statement of the command header class per command. Each statement其中:1)CAAAfruboidHdr is the identifier you need to assign to the command header. It will be used afterwards:(1)To associate the command starters you will define to put the command in a menu and in toolbars with the command header.(2)To build the variables that define the command header resources, such as the name seen by the end user in his/her own language in the menu, or the icon to display in a toolbar.2)CAADegGeoCommands is the name of the shared library or DLL containing the Cuboid command's code, without the prefix lib, and without the suffix depending on the operating system.3)CAADegCreateCuboidCmd is the name of the Cuboid command class4)the last argument is the possible pointer to the object to pass to the command when executing it. It is often a character string that indicates the action to carry out when the same command can perform several actions depending on the active document and data, such as "update" or "update all", or "cut" or "copy".3.4.3.4 Creating the Workbench and Arranging the Commands3.4.3.4.1 创建workbenchNewAccesspCAAAfrGeoCreationWkb is the variable used to handle the workbench instance pointer, and CAAAfrGeoCreationWkb is the workbench identifier. Note that the workbench class name and the workbench identifier must be identical to take into account the workbench resources in the Start menu.They appear both in bold typeface. This identifier is also used to name the workbench resource files CAAAfrGeoCreationWkb.CATNls and CAAAfrGeoCreationWkb.CATRsc. The workbench resources, and how to provide them, are described in Creating Resources for Workbenches.3.4.3.4.2 创建containers...NewAccess(CATCmdContainer,pCAAAfrSolidEltTlb,CAAAfrSolidEltTlb);SetAccessChild(pCAAAfrGeoCreationWkb, pCAAAfrSolidEltTlb);... // See Creating the Solids Toolbar ContentAddToolbarView(pCAAAfrSolidEltTlb,1,Right);NewAccess(CATCmdContainer,pCAAAfrSurfacicEltTlb,CAAAfrSurfacicEltTlb);SetAccessNext(pCAAAfrSolidEltTlb,pCAAAfrSurfacicEltTlb);... // See Creating the Surfaces Toolbar ContentAddToolbarView(pCAAAfrSurfacicEltTlb,-1,Right);NewAccess(CATCmdContainer,pCAAAfrGeoCreationMbr,CAAAfrGeoCreationMbr);... // See Creating the Menu Bar ContentSetWorkbenchMenu(pCAAAfrGeoCreationWkb,pCAAAfrGeoCreationMbr);...其中:(1)The Solids toolbar is created as an instance of the CATCmdContainer class using the NewAccess macro. pCAAAfrSolidEltTlb is the variable used to handle the Solids toolbar command container instance pointer, and CAAAfrSolidEltTlb is the identifier used to refer to it in the workbench resource files. This identifier must be unique among all the toolbar identifiers that can be found within the application. The Solids toolbar is set as the child of the workbench using the SetAccessChild macro, and its default location is defined using the AddToolbarView macro, where 1 means that the Solids toolbar is visible by default (-1 means invisible), and Right means that the toolbar is docked at the right side of the application window.(2)The Surfaces toolbar is created in the same way, but it is set next to the Solids toolbar using the SetAccessNext macro. It is invisible (-1 means invisible) by default, and is also docked at the right side of the application window.(3)The menu bar is also created as an instance of the CATCmdContainer class and is referred to using the pCAAAfrGeoCreationMbr pointer. Its identifier is CAAAfrGeoCreationMbr and is used for its resources. It is set as the workbench's menu bar using the SetWorkbenchMenu macro.The toolbar resources, and how to provide them, are described in Creating Resources for Workbenches. See also Providing the Resources and Inserting the Workbench into the Start Menu for an overview of allthe resources to create.1)添加Solids 工具条按钮(Creating the Solids Toolbar Content)This toolbar contains four commands: Cuboid, Sphere, Torus, and Cylinder. You should, for each command:(1)Create a command starter using the NewAccess macro(2)Associate the command starter, using the SetAccessCommand macro, with the appropriate command header identifier defined in the CreateCommands method(3)Arrange the command starters in the toolbar using the SetAccessChild and SetAccessNext macros ...NewAccess(CATCmdStarter,pCAAAfrTSolidEltCuboidStr,CAAAfrTSolidEltCuboidStr);SetAccessCommand(pCAAAfrTSolidEltCuboidStr,"CAAAfrCuboidHdr");SetAccessChild(pCAAAfrSolidEltTlb,pCAAAfrTSolidEltCuboidStr);NewAccess(CATCmdStarter,pCAAAfrTSolidEltSphereStr,CAAAfrTSolidEltSphereStr);SetAccessCommand(pCAAAfrTSolidEltSphereStr,"CAAAfrSphereHdr");SetAccessNext(pCAAAfrTSolidEltCuboidStr,pCAAAfrTSolidEltSphereStr);NewAccess(CATCmdStarter,pCAAAfrTSolidEltTorusStr,CAAAfrTSolidEltTorusStr);SetAccessCommand(pCAAAfrTSolidEltTorusStr,"CAAAfrTorusHdr");SetAccessNext(pCAAAfrTSolidEltSphereStr,pCAAAfrTSolidEltTorusStr);NewAccess(CATCmdStarter,pCAAAfrTSolidEltCylinder1Str,CAAAfrTSolidEltCylinder1Str);SetAccessCommand(pCAAAfrTSolidEltCylinder1Str,"CAAAfrCylinder1Hdr");SetAccessNext(pCAAAfrTSolidEltTorusStr,pCAAAfrTSolidEltCylinder1Str);NewAccess(CATCmdStarter,pCAAAfrTSolidEltCylinder2Str,CAAAfrTSolidEltCylinder2Str);SetAccessCommand(pCAAAfrTSolidEltCylinder2Str,"CAAAfrCylinder2Hdr");SetAccessNext(pCAAAfrTSolidEltCylinder1Str,pCAAAfrTSolidEltCylinder2Str);...Three macros are required for each command. For example, the Cuboid command is processed as follows:1) First create the command starter as a CATCmdStarter instance using the NewAccess macro. pCAAAfrTSolidEltCuboidStr is the variable used to handle a pointer to thatinstance, and CAAAfrTSolidEltCuboidStr is its identifier.2) Then associate the Cuboid command header with this command starter using the SetAccessCommand macro. The second parameter is the Cuboid command headeridentifier defined as the first parameter of the command header consrtuctor. Refer toCreating the Command Headers3) Finally set the Cuboid command starter as the child of the Solids toolbar.Proceed in the same way for the other commands, except that they are set as next of one another using the SetAccessNext macro.2)添加Surfaces 工具条按钮(Creating the Surfaces Toolbar Content)This toolbar contains three commands: Revolution Surface, Nurbs Surface, and Offset Surface. You should, for each command:(1)Create a command starter using the NewAccess macro(2)Associate the command starter, using the SetAccessCommand macro, with the appropriate command header identifier defined in the CreateCommands method(3)Arrange the command starters in the toolbar using the SetAccessChild and SetAccessNext macros ...NewAccess(CATCmdStarter,pCAAAfrTSurfRevolStr,CAAAfrTSurfRevolStr);SetAccessCommand(pCAAAfrTSurfRevolStr,"CAAAfrRevolSurfHdr");SetAccessChild(pCAAAfrSurfacicEltTlb,pCAAAfrTSurfRevolStr);NewAccess(CATCmdStarter,pCAAAfrTSurfNurbsStr,CAAAfrTSurfNurbsStr);SetAccessCommand(pCAAAfrTSurfNurbsStr,"CAAAfrNurbsSurfHdr");SetAccessNext(pCAAAfrTSurfRevolStr,pCAAAfrTSurfNurbsStr);NewAccess(CATCmdStarter,pCAAAfrTSurfOffsetStr,CAAAfrTSurfOffsetStr);SetAccessCommand(pCAAAfrTSurfOffsetStr,"CAAAfrOffsetSurfHdr");SetAccessNext(pCAAAfrTSurfNurbsStr,pCAAAfrTSurfOffsetStr);...Three macros are required for each command. For example, the Revolution Surface command is processed as follows:(1)First create the command starter as a CATCmdStarter instance using the NewAccess macro. pCAAAfrTSurfRevolStr is the variable used to handle a pointer to that instance, and CAAAfrTSurfRevolStr is its identifier.(2)Then associate the Revolution Surface command header with this command starter using the SetAccessCommand macro. The second parameter is the Revolution Surface command header identifier defined as the first parameter of the command header consrtuctor. Refer to Creating the Command Headers(3)Finally set the Revolution Surface command starter as the child of the Surfaces toolbar.Proceed in the same way for the other commands, except that they are set as next of one another using the SetAccessNext macro.3)添加菜单项(Creating the Menu Bar Content)Menus and submenus are created as CATCmdContainer instances, and menu items as CATCmdStarter instances. The menu bar you create will be merged when the workbench is loaded or activated at run time with the workshop menu bar, itself resulting in the merge of the default menu bar, that is, the one that exists when no document is active, with the one defined for the workshop. You can neither remove a menu from the default menu bar or from the menu bar defined for the workshop, nor change the menu order. You can add submenus to menus. You can also add submenus to your own submenus, but not to existing submenus.You should:(1)Create a command container for each menu and submenu using the NewAccess macro(2)Create a command starter for each command using the NewAccess macro(3)Associate each command starter, using the SetAccessCommand macro, with the appropriate command header identifier defined in the CreateCommands method(4)Arrange the command starters in the menu using the SetAccessChild, and SetAccessNext macros ——Insert Menu - Solids SubmenuSetAccessNext(pCAAAfrGeoCreationInsertSep,pCAAAfrSolidEltSnu);NewAccess(CATCmdStarter,pCAAAfrMSolidCuboidStr,CAAAfrMSolidCuboidStr);SetAccessChild(pCAAAfrSolidEltSnu,pCAAAfrMSolidCuboidStr);SetAccessCommand(pCAAAfrMSolidCuboidStr,"CAAAfrCuboidHdr");NewAccess(CATCmdStarter,pCAAAfrMSolidSphereStr,CAAAfrMSolidSphereStr);SetAccessNext(pCAAAfrMSolidCuboidStr,pCAAAfrMSolidSphereStr);SetAccessCommand(pCAAAfrMSolidSphereStr,"CAAAfrSphereHdr");NewAccess(CATCmdStarter,pCAAAfrMSolidTorusStr,CAAAfrMSolidTorusStr);SetAccessNext(pCAAAfrMSolidSphereStr,pCAAAfrMSolidTorusStr);SetAccessCommand(pCAAAfrMSolidTorusStr,"CAAAfrTorusHdr");NewAccess(CATCmdStarter,pCAAAfrMSolidCylinder1Str,CAAAfrMSolidCylinder1Str);SetAccessNext(pCAAAfrMSolidTorusStr,pCAAAfrMSolidCylinder1Str);SetAccessCommand(pCAAAfrMSolidCylinder1Str,"CAAAfrCylinder1Hdr");NewAccess(CATCmdStarter,pCAAAfrMSolidCylinder2Str,CAAAfrMSolidCylinder2Str);SetAccessNext(pCAAAfrMSolidCylinder1Str,pCAAAfrMSolidCylinder2Str);SetAccessCommand(pCAAAfrMSolidCylinder2Str,"CAAAfrCylinder2Hdr");...The Insert menu command container is created, even if it already exists. Then the Solids submenu command container is created and set as the child of the Insert menu command container. Since no other positioning information is given, it should lay below the last submenu or command of the workshop menu bar, that is the Plane command. Then the Cuboid command starter is created and set as the child of the Solids submenu command container, and the others are cretaed and set next of one another.——Insert Menu - Surfaces Submenu...NewAccess(CATCmdContainer,pCAAAfrSurfacicEltSnu,CAAAfrSurfacicEltSnu) ;SetAccessNext(pCAAAfrSolidEltSnu,pCAAAfrSurfacicEltSnu);NewAccess(CATCmdStarter,pCAAAfrMSurfRevolStr,CAAAfrMSurfRevolStr);SetAccessChild(pCAAAfrSurfacicEltSnu,pCAAAfrMSurfRevolStr);SetAccessCommand(pCAAAfrMSurfRevolStr,"CAAAfrRevolSurfHdr");NewAccess(CATCmdStarter,pCAAAfrMSurfNurbsStr,CAAAfrMSurfNurbsStr);SetAccessNext(pCAAAfrMSurfRevolStr,pCAAAfrMSurfNurbsStr);SetAccessCommand(pCAAAfrMSurfNurbsStr,"CAAAfrNurbsSurfHdr");The Surfaces submenu command container is created and set next to the Solids submenu command container. Then the Revolution Surface command starter is created and set as the child of the Surfaces submenu command container, and the others are cretaed and set next of one another.The menu and submenu resources, and how to provide them, are described in Creating Resources for Workbenches. See also Providing the Resources and Inserting the Workbench into the Start Menu for an overview of all the resources to create.3.4.3.5 GetCustomInterfaces方法The GetCustomInterfaces method must be empty. The names of the interface exposed by the workbench to enable clients to create add-ins is returned by the GetAddinInterface method.3.4.4 修改字典(Updating the Dictionary)Update the interface dictionary, that is a file named, for example, CAAApplicationFrame.dico, whose directory's pathname is concatenated at run time in the CATDictionaryPath environment variable, and containing the following declaration to state that the CAAAfrGeoCreationWkb class implements the CATICAAAfrGeometryWksConfiguration interface, and whose code is located in the libCAAAfrGeoCreationWbench shared library or DLL. The update is in bold typeface:3.5 创建资源及嵌入Workbench(Providing the Resources and Inserting the Workbench into the Start Menu)3.5.1 workbench资源(The workbench and command container resources)3.5.1.1 文本资源The resource file containing the title and help messages in the English language, and that can be translated into other languages. It is suffixed using CATNls The resource files must have the workbench identifier as file name, that is CAAAfrGeoCreationWkb. This identifier is declared in the CreateWorkbench method of the workbench description class, as the third parameter of the NewAccess macro that creates theThe workbench resource files are then CAAAfrGeoCreationWkb.CATNls and CAAAfrGeoCreationWkb.CATRsc. These files are located in the CNext\resources\msgcatalog directory of the framework containing the workbench module. This directory includes subdirectories, one for each language into which the title and messages of the CAAAfrGeoCreationWkb.CATNls file can be translated. The resource files contain:o Workbench: the title, messages, and icons to be displayed in the Start menuo Toolbars: their titleso Menus and submenus: their titles, icons, and mnemonicso Icon boxes: their titles.Each resource is provided using a key and a text, or a file name without suffix, separated by the equal sign. The key is built as a concatenation of the object identifier you defined as the third parameter of the NewAccess macro, a dot, and a keyword designating the appropriate resource. The message is enclosed using double quotes and ended using a semicolon. For example, the CAAAfrGeoCreationWkb workbenchThe CAAAfrGeoCreationWkb.CATNls file contains:▪The resources for the workbench itself: the title used in the Start menu, itsassociated help message, the short help displayed when the mouse is over theworkbench icon, and the long help▪The titles of the toolbars and icon boxes▪The titles and mnemonics of the menus and submenus.//----------------------------------------------------------------------------// WORKBENCH//----------------------------------------------------------------------------CAAAfrGeoCreationWkb.Title = "CAA V5: Geometrical Creation";CAAAfrGeoCreationWkb.ShortHelp = "Workbench to create Geometrical Elements";CAAAfrGeoCreationWkb.Help = "Workbench to create Geometrical, Solid and Surfacic Elements";CAAAfrGeoCreationWkb.LongHelp = "This is the CAA V5: Geometrical Creation Workbench.It is used to demonstrate workbenches.It contains two toolsbars:- One for some Solid Elements- The other for some Surfacic Elements";//----------------------------------------------------------------------------// TOOLBAR//----------------------------------------------------------------------------CAAAfrSolidEltTlb.Title = "Solids" ;CAAAfrSurfacicEltTlb.Title = "Surfaces" ;//----------------------------------------------------------------------------// SUB - MENU//----------------------------------------------------------------------------CAAAfrSolidEltSnu.Title = "Solids" ;CAAAfrSolidEltSnu.Mnemonic = "S";CAAAfrSurfacicEltSnu.Title = "Surfaces" ;CAAAfrSurfacicEltSnu.Mnemonic = "u";3.5.1.2 位图资源CAAAfrGeoCreationWkb.CATRscThis file contains the category, that is the submenu of the Start menu where the workbench should appear, and the names of the icons to be associated with the workbench for the Start menu.CAAAfrGeoCreationWkb.Category = "Infrastructure" ;// Icons for the Welcome window 64x64CAAAfrGeoCreationWkb.Icon.NormalPnl = "I_WkAsCAAAfrGeoCreationWkb";CAAAfrGeoCreationWkb.Icon.PressedlPnl = "IP_WkAsCAAAfrGeoCreationWkb";CAAAfrGeoCreationWkb.Icon.FocusedlPnl = "IF_WkAsCAAAfrGeoCreationWkb";// Icons for the Start menu 32x32CAAAfrGeoCreationWkb.Icon.NormalCtx = "I_WkNvCAAAfrGeoCreationWkb";CAAAfrGeoCreationWkb.Icon.PressedlCtx = "IP_WkNvCAAAfrGeoCreationWkb";CAAAfrGeoCreationWkb.Icon.FocusedlCtx = "IF_WkNvCAAAfrGeoCreationWkb";// Icons for the workbench toolbar 24x24CAAAfrGeoCreationWkb.Icon.NormalRep = "I_WkCAAAfrGeoCreationWkb";CAAAfrGeoCreationWkb.Icon.PressedlRep = "IP_WkCAAAfrGeoCreationWkb";CAAAfrGeoCreationWkb.Icon.FocusedlRep = "IF_WkCAAAfrGeoCreationWkb";It is in this file that you declare if the workbench is warm start compliant [3]. The CAAGeometry document is not warm start compliant, so its workbenches are not compliant too.3.5.2 command header资源The command header resources in the command header resource files: titles, messages, icons, and the accelerators associated with the commands. The resource files searched for at run time should have the same name than you command header class, that is CAAAfrGeoCreationWkbHeader.3.5.2.1 文本资源CAAAfrGeoCreationWkbHeader.CATNlsThe CAAAfrGeoCreationWkbHeader.CATNls file contains the following for the Cuboid commandsFor each command, the title, short help, help, and long help are declared.3.5.2.2 位图资源CAAAfrGeoCreationWkbHeader. CATRscThe CAAAfrGeoCreationWkbHeader.CATRsc file includes the following for the Cuboid command。
CATIA二次开发(CAA)技术基础之零件设计说明
CATIA二次开发(CAA)技术基础之零件设计说明CATIA是由法国达索公司开发的一款三维设计软件,被广泛应用于航空航天、汽车、工程机械、电子等行业。
CATIA提供了丰富的功能模块,可以进行零部件设计、装配设计、模具设计等操作。
而CATIA二次开发(CAA)则是在CATIA的基础上进行的二次开发,通过CAA技术,用户可以根据自己的需求进行功能拓展,提高工作效率。
1.C++语言基础CAA的二次开发主要通过C++语言来实现。
因此,作为开发人员,需要具备扎实的C++语言基础,包括语法、指针、类和对象等的使用。
此外,还需要了解面向对象的设计和编程思想,以便能够高效地使用CAA的各种功能接口。
2.CATIA基础知识熟悉CATIA的基本操作和功能是进行CAA二次开发的前提条件。
开发人员需要了解CATIA的各个模块,包括零部件设计、装配设计、模具设计等,以及CATIA的数据结构和文件格式。
只有对CATIA有深入的了解,才能更好地在开发中应用和扩展CATIA的功能。
3.CAA架构CAA是CATIA的二次开发平台,提供了各种功能接口和开发工具,使开发人员能够通过编程的方式对CATIA进行功能拓展。
CAA的架构包括CATIA定义的一系列C++库和工具,熟悉CAA的架构和各个模块的接口,是进行二次开发的关键。
4.开发环境配置进行CAA二次开发需要配置开发环境,主要包括编译器、开发工具和CATIA软件本身。
常用的CAA开发环境有Visual Studio和Eclipse等,通过配置编译器和开发工具,可以在集成开发环境中进行代码编写、调试和测试。
另外,还需要安装CATIA的开发包,并进行相关配置,以便能够使用CATIA的功能接口。
5.开发流程和规范CAA的二次开发需要按照一定的流程和规范进行。
首先,需要明确开发的目标和需求,在此基础上进行功能设计和接口设计。
然后,根据设计,编写代码并进行调试和测试。
最后,进行代码的集成和发布,确保开发的功能能够正常运行。
CATIACAA二次开发详细教程
CATIACAA⼆次开发详细教程CATIA CAA ⼆次开发详细教程(11)程序的发布1.发布条件:已安装了CATIA,版本不能低于开发使⽤的CAA版本。
CAA代码成果物“intel_a”⽂件中的所有⽂件。
1.发布⽅法:2.将“intel_a”⽂件存放在要发布机器上,存放“intel_a”⽂件的路径最好不要有中⽂字符和空格。
(例:E:\VCINewFromExisting\intel_a)3.点击”开始” –> ”所有程序” –> “CATIA P3” –> “Tools” –>”Environment Editor V5R18”1.点击“确定”。
1.选择”Environment” –> “New”1.“Name” 栏为将要创建的桌⾯快捷⽅式的名称;在”Install Path”栏中,CATIA的安装路径后输⼊”;E:\VCINewFromExisting\intel_a”,这是要发布的intel_a的存放路径;其他如图所选,采取默认设置。
完成后点击”OK”。
1.⾄此发布完成,在桌⾯上会⽣成⼀个名为”NewFromExisting”的CATIA类型图标。
双击该图标,会启动CATIA,⽤户便可使⽤CATIA 原所有功能和新发布的功能。
1.与原CATIA图标集成发布⽅法:设:Catia的⼯作⽬录是 D:\DS\B18\intel_a;已开发插件的⼯作⽬录是D:\MyAddin\intel_a;将D:\MyAddin\intel_a下这些⽂件复制到D:\DS\B18\intel_a对应的位置,即可在运⾏Catia时候⾃动加载插件:code \ bin \ *.dll;\ code \dictionary \ *.dico;\ code \ productIC \ *.script;\ code \ productIC \ *.xml;\ resources \ graphic \ icons \ normal \ *.bmp; \ resources \ msgcatalog \ *.CATNls;\ resources \ msgcatalog \ *.CATRsc;。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
CATIA CAA 二次开发详细教程第一讲:基本概念1. 什么是组件?由于本人是自学,属于摸着石头过河,所以很多东西显得比较幼稚,大家请见谅。
CAA,全称 C omponent A pplication A rchitecture,组件应用架构。
这个东西对不搞软件的人来说可能很陌生,我也很陌生啊,原来光知道“面向对象的技术”就很牛逼了,“组件技术”难道更牛逼吗?既然类和组件有着这么多类似的地方,那么传统的面向对象编程和面向组件编程有什么区别呢?简单的说,面向对象关注的是组合在一个二进制可执行文件中的各个类的关系,而面向组件的编程关注的是在彼此独立的基础上模块之间的交互性,这种交互性使得你并不需要熟悉它们内部的工作原理。
这两种方法最基本的不同在于它们对最终的应用程序的观点。
在传统的面向对象编程中,尽管你可以精心的把所有的商业逻辑分布在不同的类中,一旦这些类被编译,它们就被固化成了一个巨大的二进制代码。
所有的类共享同一个物理单元(通常是一个可执行文件)、被操作系统认为是同一个进程,使用同一个地址空间以及共享相同的安全策略等等。
如果多个开发者在同一份代码上进行开发,他们甚至还要共享源文件。
在这种情况下,修改一个类可能会让整个项目被重新链接,并重新进行必要的测试,更严重的,还有可能要修改其他的类。
但是,在面向组件开发中,应用程序是由一系列可以互相交互的二进制模块组合而成的。
一个具体的二进制组件可能并不能完成什么工作。
有些组件是为了提供一些常规服务而编写的,例如通信的封装或者文件访问组件。
也有一些是为了某些特定应用而专门开发的。
一个应用程序的设计者可以通过把这些不同的组件提供的功能粘合在一起来实现他们需要的商业逻辑。
很多面向组件的技术——例如: COM 、 J2 EE 、 CORBA 和 .NET 都为二进制组件提供了的无缝链接的机制。
而唯一的不同就是你需要在组件通信上花费的力气。
把一个二进制应用程序分解成不同的二进制组件的动机和把不同的类放到不同的文件中是类似的。
后者使得不同的类的开发人员可以彼此独立的工作,尽管即时修改了一个类也要重新链接整个应用程序,但是你只需要重新编译被修改的部分就可以了。
但是,面向组件的开发还是和简单软件项目的管理更复杂一些。
因为一个面向组件的应用程序是一个二进制代码块的集合,你可以把组件当作是 LEGO 的积木块一样,随心所欲的拆装它们。
如果你需要修改一个组件的实现,只需要修改那个组件就可以了,而组件的客户机不需要重新编译也不需要重新开发。
对于那些不常用到的组件,组件甚至可以在一个程序运行的时候被更新。
这些改进和增强使得组件可以立即进行更新,而所有该组件的客户都将立即受益。
无论是在同一台机器上还是通过网络远程访问。
面向组件的应用程序也更易于扩展。
当你需要实现新的需求的时候,你可以提供一个新的组件,而不去影响那些和新需求无关的组件。
这些特点使得面向组件的开发降低了大型软件项目长期维护的成本,这是一个最实际的商业问题,也正是如此,组件技术才如此迅速的被接受。
面向组件的应用程序通常可以更快的响应市场,因为你可以有很大的选择空间,不仅仅是自己开发的组件,还可以从第三方厂商来购买某些组件,从而避免了重复制造轮子。
这里, VB 就是一个很好的例子,丰富的 ActiveX 控件使得很多人在快速开发中得到了享受。
面向对象和面向组件另一个重要的不同在于这两种技术在继承和重用模型上的侧重点不同。
在面向对象的分析和设计中,应用程序通常被分解成复杂的类继承结构。
类的设计和要解决的商业问题紧密结合。
你可以从已有基类继承并特化其行为来实现代码重用。
问题在于,这是一种很糟糕的重用的方法。
当你从一个基类派生一个子类的时候,你必须对基类的实现有透彻的理解才可能保证不出问题。
例如:修改一个成员变量会不会带来副作用?这会对基类中的代码有什么影响?重载基类的方法会不会破坏那些想使用基类版本的客户的行为?等等。
这种形式的重用被称为白盒重用(White-box reuse),因为当你重用的时候你就需要去了解基类实现的细节。
显然。
白盒重用在可扩展性较高的大型应用中并不经济,也很难得到第三方Framework厂商的支持。
面向组件的开发采用了黑盒重用(Black-box reuse)的方法,它可以让你对组件内部全然不知的情况下来使用组件公开的接口。
这样,你就可以远离那些复杂的继承关系。
而面向组件的开发者也可以把更多的精力放在制定组件和客户的沟通的接口上了。
最后,面向对象编程提供了有限的工具和设计模式来处理和应用程序运行时相关的问题,例如多线程、并发管理、安全、分布式应用和版本控制等。
面向对象的开发者当面对这些“公共需求”的时候,或多或少的需要自己来解决问题。
但是面向组件的开发方式却使你在这方面要灵活的多。
以下是CSDN社区网友对组件的一个讨论:1面向对象是面向组件的基础,组件是在对象的基础上加上属性和事件2复用粒度的大小不同。
通常多个密切相关的对象组织在一起完成一个/或多特定的功能。
组件有多个侧面(facet),不同的使用者可能只使用其中的部分。
3级别不一样,“面向对象”是对语言级别的,“组件”是对应用级别的。
组件可以由对象实体组成。
? ?4组件由一个或若干个对象组成。
对象提供可访问的接口。
5可笑,现在很多人把面向对象编程理解为面向组件编程,真是幼稚!6组件是一种面向应用的概念,对象是一种面向编程方法的概念。
一般进行组件编程都是用面向对象的方法编程进行实现。
组件已经是一种能实际应用的实例了。
本人的理解,见笑了。
7面向对象是在代码一级对数据和方法的封装,C++,JAVA面向组件是在二进制代码上的封装,COM/COM+,CORBA8面向组件的集成度和可重用度更高(如楼上的meking_lee所说的),面向组件渴望一种真正的接口级的搭积木的软件模式,目前在语言特性上支持这一点的就只有java了(当然也许我见识短)。
9用C++实现组件,是因为没有直接支持组件的语言。
现在的组件太大了。
10 应该说是面向对像和基于组件2. CAA架构CATIA本身是按照组件模型建立起来的,用户可以通过开发自己的CAA组件,对DASSAULT SYSTEMES的CATIA V5进行扩展;也可以把用户自己开发的CAA组件结合起来,实现用户自定义应用。
CAA应用的框架结构遵从组件对象模型,有自己的框架结构。
每个应用有至少一个框架(framework),每个框架有至少一个模块(module)。
每个框架里面有一个Ide ntityCard.h文件,这个文件通过宏“AddPrer eqComponent(framenwork,protecte d)”来声明“声明”这个框架的一些首先必备的其他框架名称,framework是框架名称。
CAA的编译器就是通过IdentityCard.h文件,来把头文件搜索限制在首先必备框架所包含的接口中。
8每个模块下面定义了一个Imakefile.mk文件,这个文件指明了这个模块中所有文件在编译时用到的其它模块和一些外部库以及为编译器提供如何编译的模块必须信息,还指定在不同的操作系统下面编译时的一些可能的特殊要求。
CAA环境对Cn ext能够运行的所有操作系统中采用同样的编译器,这为开发者提供了很大的方便,因为他们可以不需要知道怎样用不同的编译器和怎么写makefile。
但是MKMK并不能做所有的事情,开发者至少要说明他们想要做什么。
我们在自己的源文件中用到其它模块的接口,要在Imakefile.mk中进行说明。
% S( c' R??y' [3 E- T0 Y$ _7 f程序结构采用了COM组件模型,组件模型中有两个常用的概念:接口(Interfa ce)和实现(Implement)。
接口是一个包含许多纯虚函数的抽象对象,这些纯虚函数指明了接口支持的方法。
实现是一个具体定义接口中的方法的对象,一个实现对象必须显式声明它支持哪些接口,还必须定义它支持的接口中的所有抽象方法,实现对象可以支持一个或多个接口,而客户应用只能通过这些接口与实现对象发生联系。
下面的这个图好像比较能体现CAA的思想,不过要仔细看看。
3.What's RADE??RADE,Rapid Application Development Environment,快速应用研发环境,是一个可视化的集成开发环境,它提供完整的编程工具组。
RADE以Micr osoft Visual C++6.0为载体,开发工具完全集成在了VC++环境中,并且提供了一个CAA框架程序编译器,但同时也限制了VC++的部分功能。
可以说CATIA CAA–RADE是目前所有高端CAD/CAM开发环境中最为复杂、同时也是功能最为强大的一个。
CAA V5 RADE包括一系列工具:TCK(Tool Configuration Key)、MAB(多工作空间应用生成器)、CUT(C++单元调试管理器)、MKMK(CAA编译工具) 、C ID(C++交互式面板)等,以插件的形式与MSDev VC++集成到一起。
然后借助于这些工具在MSDev? ?环境下开发自己的CAA组件。
TCK管理RADE环境,TCK命令是用来管理开发工具包的安装,用来创建一个工作环境。
当在WinowsNT上用CAA V5的可视化创建工具(以插件形式嵌入Microsoft Developer Studio),tck_init 和 tck_profile 命令在打开一个V5的工作区时被自动调用。
. Z7MKMK(多工作区应用编译器)是DS(Dassault Systems)原代码编译工具,它构建在平台无关(UNIX和WindowsNT)的标准编译器上,它支持面向组件的设计模式。
MKMK提供一种统一的工具来编译和连接CAA应用而不管是用的什么编程语言(Fortran, C, C++, IDL, Express, CIRCE, ...)。
1 ]1 V9 K??O8 n, S4 n' _CUT是单元调试管理器,CUT用mkodt命令来运行传递给测试框架中的测试对象,通过选择不同的命令参数来决定选择测试一个对象或者所有对象。
CID即C++交互式面板,CID根据软件开发人员的需求,支持从设计、开发到测试、推广及维护的整个开发设计周期,CID提供对RADE产品的单点访问。
尽管CID在WindowsNT下运行,它能够产生Unix程序代码。
MAB多工作空间应用生成器产品,它为CATIA V5应用程序提供一个集成统一的编译、链接、编辑、生成环境。
MAB能够承担多工作空间编辑,链接,运行代码生成,以及各工作空间之间依赖性的有效管理。
MAB还可以监控任一工作空间的源代码的变更,在整个编译过程中显示跟踪该变更,使编译过程只需要编译更改部分即可。