CAA用户界面开发——实例说明(CATIA二次开发)
CATIA CAA 二次开发详细教程 (4):创建自定义特征

CATIA CAA二次开发第四讲:创建自定义特征本例是使用CAA C++开发方式,建立一个自定义的用户特征,实现的功能是使一个任意曲面可以根据给定曲面的形状来生成和目标形状相同的形状,类似于生活中缝补的概念,其具体的开发步骤如下:(1)创建一个库(catalog)来定义特征的StartUp。
用CATfctEditorAssistant-new-catalog命令创建catalog,通过.osm文件定义catalog里StartUp数据结构。
对StartUp的定义要根据自定义特征的性质,选用合适的container,在feature定义中,要对对自定义特征的输入输出和该特征的中性数据给予明确的定义。
(2)创建一个扩展接口来访问特征的属性。
通常在该接口中定义设置和获取自定义特征属性的方法。
在本文中接口的作用是取得被缝合的表面和支撑面。
(3)创建一个可以实例化该特征的工厂(Factory)。
该工厂的作用是打开创建的catalog获取startup,然后实例化自定义特征并设置它的属性。
本文中为创建缝合面,然后打开catalog 并获取startup,实例化特征设置其属性。
(4)创建工具条Toolbar。
使用CA TCommandHeader类创建命令头,最简单的方法就是使用宏命令:#include"CATCommandHeader.h"、MacDeclareHeade(rMyHea-der)。
CommandHeader添加到工具条的Addin函数中,createco-mmand(s)用来实例化一个新的命令,createtoolbars 用来确定访问顺序,SetAccessCommand的作用是将命令头与按钮相连,SetAccessChild以及SetAccessNext这两个宏则可以顺序连接到入口。
(5)创建对话框Panal。
在Bulid函数里添加设置对话框各按钮相应的功能函数,并为各按钮设置默认的初始值。
CATIACAA二次开发详细教程(10)文档操作方法创建加载保存

CATIACAA二次开发详细教程(10)文档操作方法创建加载保存CATIA CAA 二次开发详细教程(10)文档操作方法创建加载保存一、创建(Create the new document)CATDocument* pDoc = NULL;rc = CATDocumentServices::New("Part",pDoc);if (NULL != pDoc){cout << "New document created OK" << endl << flush;}else{cout << "ERROR in creating New document" << endl << flush;return 2;}Now that the session is opened, you can create a new document using the New static method of CATDocumentServices. This method creates a document and initializes it, allowing it to be loaded and stored and making it editable. In this use case, a pre-defined document type, "Part", is used as a document type. In interactive mode, this is the name that appears when performing a File/New operation. It is not the file extension, which, in this case, is "CATPart".二、打开(Load the document)CATDocument *pDoc = NULL;rc = CATDocumentServices::Open(argv[1],pDoc);if (SUCCEEDED(rc) && (NULL != pDoc)){cout << "Document opened OK" << endl << flush;}else{cout << "ERROR in opening an existing document" << endl << flush;return 2;}Now that the session is opened, you can load an existing document using the Open static method of CATDocumentServices. This method needs, as a first parameter, the entire storage path name and document name of the existing document that we want to load into the session. In this use case, we enter this information as an argument to the program. The second parameter of the Open method returns a CATDocument pointer to the document it has loaded.Once the document exists in the session, you can work with objects within it, using specific interfaces external to the ObjectModelerBase framework.三、获取当前文档CATFrmEditor * pEditor = GetEditor();if (NULL != pEditor ){cout << "Editor got OK" << endl << flush;}else{cout << "ERROR in getting the current editor" << endl << flush;}CATDocument *pDoc = pEditor->GetDocument();if (NULL != pDoc){cout << "Document opened OK" << endl << flush;}else{cout << "ERROR in opening an existing document" << endl << flush;return 2;}四、提取根容器(Retrieving the Document Root Container)CATInit *piInitOnDoc = NULL;rc = pDoc -> QueryInterface (IID_CATInit, (void**) &piInitOnDoc);if (FAILED(rc)){cout << "ERROR in QueryInterface on CATInit for doc" << endl << flush;return 3;}const CATIdent idCATIContainer = "CATIContainer";CATIContainer *piRootContainer = NULL;piRootContainer = (CATIContainer*) piInitOnDoc -> GetRootContainer(idCATIContainer);if (NULL == piRootContainer){cout << "ERROR in GetRootContainer" << endl << flush;}The document root container is retrieved using the CATInit::GetRootContainer method. The CATIContainer handle retrieved through GetRootContainer will be necessary whenever you want to create or manipulate objects in the document.五、保存文档(Save the Document)5.1 另存rc = CATDocumentServices::SaveAs (*pDoc, argv[1]);if (SUCCEEDED(rc)){cout << "Document saved OK" << endl << flush;}else{cout << "ERROR in saving document" << endl << flush;return 5;}To save the new document, use the SaveAs static method of CATDocumentServices. This method takes the pointer to the document created by New as a first parameter, and the storage path name and document name under which the document is to be stored as a second parameter. In this use case, we pass the storage path name and document name as an argument to the program.5.2 保存rc = CATDocumentServices::Save (*pDoc);if (SUCCEEDED(rc)){cout << "Document saved OK" << endl << flush;}else{cout << "ERROR in saving document" << endl << flush;return 3;}To save the new document under the same name, use the Save static method of CATDocumentServices. This method takes the CATDocument pointer to the document as the only parameter.六、删除(Remove the document)rc = CATDocumentServices::Remove (*pDoc);if (SUCCEEDED(rc)){cout << "Document removed OK" << endl << flush;}else{cout << "ERROR in removing document" << endl << flush;return 6;}If you ever needed to re-open the document during this same session, it would then be necessary to also remove it from the session after having saved it. Otherwise, you need not worry about it since deleting the session will automatically remove the document as well. To remove the document, you should use the Remove static method of CATDocumentServices.七、按指定文档格式保存(Exporting a Document Format Type)7.1 Defining the New Document Format TypeCATProduct_OmbExportType CATIExportTypeManagerlibCAAOmbExportTypeA new document format type is simply defined by adding a new entry in the current framework's dictionary. This new entry will cause the File/SaveAs dialog box to list the new format type among the types defined to the save operation. The first parameter, CATProduct_OmbExportType, indicates that the exporting document is a Product-type document (i.e., a document having a .CATProduct suffix) and that the exported document format type is "OmbExportType", which will also be the suffix of the saved document. The second parameter indicates that this new document type will implement the CATIExportTypeManager interface in order to define the specific save operations necessary to export the new document. The last parameter is the name of the library in which the implementation module is to be found.7.2 Implementing CATIExportTypeManager See the Object Modeler articles [2] for a detailed explanation about interface implementations.The implementation of CATIExportTypeManager is found in the CAAOmbExportType.m module defining the CAAEOmbExportTypeData implementation class.CATImplementClass( CAAEOmbEExportTypeData,CodeExtension,CATBaseUnknown,CATProduct_OmbExportType );The CATImplementClass macro defines the implementation class CAAEOmbExportTypeData as a code extension implementing theCATProduct_OmbExportType late type.#include "TIE_CATIExportTypeManager.h"TIE_CATIExportTypeManager( CAAEOmbExportTypeData );The above statement indicates that this is an implementation of the CATIExportTypeManager interface.HRESULTCAAEOmbExportTypeData::ExportData( CATDocument *pDoc,CATUnicodeStringpath ){cout << "************** Begin ExportData 1" <<endl << flush;HRESULT rc = CATDocumentServices::SaveAs(*pDoc,path);return rc;}In this case, the document is simply saved using the SaveAs method of CATDocumentServices. However, it is in this method that you must code any specific save operations necessary for your new document type.。
catia caa 开发实例

catia caa 开发实例
以下是一个使用CATIA CAA进行开发的实例,该实例演示了如何修改产品中的子产品实例名称:
首先,需要使用CAA框架来设置生成时间和运行时环境。
具体来说,需要在工作区根目录中复制包含用例的CAA框架,并使用mkmk工具来生成用例。
假设加载的模块是。
在设置好生成时间和运行时环境后,就可以开始开发了。
假设需要修改产品中的子产品实例名称,可以通过以下步骤实现:
1. 打开CATIA软件,并加载需要修改的子产品实例。
2. 在产品结构树中找到需要修改名称的子产品实例。
3. 右键单击子产品实例,选择“属性”选项。
4. 在属性对话框中,找到“名称”属性,并进行修改。
5. 确认修改后,保存并关闭属性对话框。
6. 重新生成产品,以使修改生效。
以上是一个简单的使用CATIA CAA进行开发的实例,通过这个实例可以了解如何使用CAA框架进行CATIA二次开发。
CATIA CAA 二次开发 详细教程(5)添加一个点

CATIA CAA 二次开发详细教程(5)添加一个点在创建任何几何对象之前,必须在激活的函数命令中添加以下代码,:CATFrmEditor* pEditor = CATFrmEditor::GetCurrentEditor();if(pEditor == NULL){printf("error getting the FRM editor");}CATDocument *pDoc = pEditor->GetDocument();CATIContainerOfDocument_var spConODocs = pDoc;CATIContainer* pSpecContainer = NULL;HRESULT hr = spConODocs->GetSpecContainer(pSpecContainer);if(spConODocs == NULL_var){printf("error getting the container of documents");}以上代码的主要功能是获取editor, the document and the container。
CATIGSMFactory_var spGSMFactory = NULL_var;CATIPrtFactory_var spPrtFactory = NULL_var;CATICkeParmFactory_var spParmFactory = NULL_var;spGSMFactory = pSpecContainer;spPrtFactory = pSpecContainer;spParmFactory = pSpecContainer;以上代码设置工厂,在这基础上你才可以造型,GSMFactory用于创建底层的几何对象比如点、线等。
PrtFactory包含创建孔特征、拉伸特征实体等函数。
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,一定要选对。
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;}。
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。
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;。
CATIA CAA 二次开发 详细教程(9)创建圆角三角形

CATIA CAA 二次开发详细教程(9)创建圆角三角形1)创建三个点(参见教程5)2) 将点连成线(参见教程6)3) 通过三点创建一个参考平面,后面进行圆弧倒角时要用到该平面。
CATIGSMPlane3Points_var Supportplane = spGSMFactory->CreatePlane(spPoint1, spPoint2,spPoint3);CATISpecObject_var spSupportplane = Supportplane;4) 创建倒角半径的参数:CATICkeParm_var Radius1 = NULL_var;CATICkeMagnitude_var spRadMag = spParamDictionary->FindMagnitude("LENGTH");CATUnicodeString name("Radius 1");Radius1 = spParmFactory->CreateDimension(spRadMag,name, .01); 5) 创建倒角::CATIGSMCorner_var Corner1 = spGSMFactory->CreateCorner(spLine1, spLine2,spSupportplane,Radius1,CATGSMSameOrientation,CATGSMSameOrientation,FALSE);CATISpecObject_var spCorner1 = Corner1;6) 裁剪去多余的线和点:CATIGSMSplit_var Split1 = spGSMFactory->CreateSplit(spLine1, spRadius1,CATGSMSameOrientation);CATISpecObject_var spSplit1 = Split1;CATIGSMSplit_var Split1a = spGSMFactory->CreateSplit(spSplit1, spRadius3,CATGSMInvertOrientation);CATISpecObject_var spSplit1a = Split1a;7) 将线和圆弧依次连接起来,创建一个序列:CATLISTV(CATISpecObject_var) joincurves;joincurves.Append(spSplit1a);joincurves.Append(spSplit2a);joincurves.Append(spSplit3a);joincurves.Append(spRadius1);joincurves.Append(spRadius2);joincurves.Append(spRadius3);8)在讲序列连接起来之前,需要创建一个最小的结合距离:CATICkeParm_var Mergedist = NULL_var;CATICkeMagnitude_var spMergedist = spParamDictionary->FindMagnitude("LENGTH");CATUnicodeString mergename("Merge Distance");Mergedist = spParmFactory->CreateDimension(spMergedist, mergename,.0001);9)连接起来并插入到视图中:Now we can join this list of objects into a single shape and insert it into the part.CATIGSMAssemble_var CurveAssy = spGSMFactory->CreateAssemble(joincurves,Mergedist,FALSE);CATISpecObject_var spCurveAssy = CurveAssy;spCurveAssy->Update();CATIGSMProceduralView_var spCurObj = Curveassembly;spCurObj->InsertInProceduralView();。
CATIACAA二次开发详细教程

CATIA CAA 二次开发详细教程第一讲:基本概念1. 什么是组件?由于本人是自学,属于摸着石头过河,所以很多东西显得比较幼稚,大家请见谅。
CAA,全称 C omponent A pplication A rchitecture,组件应用架构。
这个东西对不搞软件的人来说可能很陌生,我也很陌生啊,原来光知道“面向对象的技术”就很牛逼了,“组件技术”难道更牛逼吗?既然类和组件有着这么多类似的地方,那么传统的面向对象编程和面向组件编程有什么区别呢?简单的说,面向对象关注的是组合在一个二进制可执行文件中的各个类的关系,而面向组件的编程关注的是在彼此独立的基础上模块之间的交互性,这种交互性使得你并不需要熟悉它们内部的工作原理。
这两种方法最基本的不同在于它们对最终的应用程序的观点。
在传统的面向对象编程中,尽管你可以精心的把所有的商业逻辑分布在不同的类中,一旦这些类被编译,它们就被固化成了一个巨大的二进制代码。
所有的类共享同一个物理单元(通常是一个可执行文件)、被操作系统认为是同一个进程,使用同一个地址空间以及共享相同的安全策略等等。
如果多个开发者在同一份代码上进行开发,他们甚至还要共享源文件。
在这种情况下,修改一个类可能会让整个项目被重新链接,并重新进行必要的测试,更严重的,还有可能要修改其他的类。
但是,在面向组件开发中,应用程序是由一系列可以互相交互的二进制模块组合而成的。
一个具体的二进制组件可能并不能完成什么工作。
有些组件是为了提供一些常规服务而编写的,例如通信的封装或者文件访问组件。
也有一些是为了某些特定应用而专门开发的。
一个应用程序的设计者可以通过把这些不同的组件提供的功能粘合在一起来实现他们需要的商业逻辑。
很多面向组件的技术——例如: COM 、 J2 EE 、 CORBA 和 .NET 都为二进制组件提供了的无缝链接的机制。
而唯一的不同就是你需要在组件通信上花费的力气。
把一个二进制应用程序分解成不同的二进制组件的动机和把不同的类放到不同的文件中是类似的。
CATIA二次开发CAA培训课件

2.4 定义资源
在文件:MyWkb.CATNIS中,可以定义此 Workbench以及其工具条、菜单的所有名 字(Title),定义格式为: MyWkb.Title="MyWkb title";
第一章 CAA二次开发一般步骤
2.添加Workbench
2.4 定义资源
第一章 CAA二次开发一般步骤
1.程序的建立
1.1 工程的建立
IdentityCard.h:本文件定义了所有用于编译 使用此Framework的预定义Framework。即, 在开发过程中如果使用了系统或者外部的API, 必须包含此API所在的头文件、module和 Framework,其中Framework的预定义就在 这个文件中进行。其格式如下:
宏定义: MacDeclareHeader(PartCmdHeader);
第一章 CAA二次开发一般步骤
3.创建Addin
(5)添加包含的模块
在.mk文件中加入: CATApplicationFrame
在Identitycard.h中加入: AddPrereqComponent("ConstraintModelerUI",Protected); AddPrereqComponent("ApplicationFrame",Protected);
File -> Add CAAV5 Project ->New Module
第一章 CAA二次开发一般步骤
2.添加Workbench
2.1 添加Module
弹出对话框如图所示 Module名称
共享模块
ቤተ መጻሕፍቲ ባይዱ一章 CAA二次开发一般步骤
基于CATIA V5R18的CAA二次开发

CAA工具条插件制作方法在VC环境中新建CAA工作空间“VCICAATrain1”:CAA工具条插件制作方法选择创建一个一般FWCAA工具条插件制作方法输入Framework名字为: MyCenterLineCAA工具条插件制作方法指定CAA API安装位置CAA工具条插件制作方法建立新的模块: 命名为VCICLModule在刚建立的Module中插入Component:Component name为VCICLAddin;TIE mode 选择“CATIDRWFRAMEAddin”CAA工具条插件制作方法CAA工具条插件制作方法声明header class :MacDeclareHeader(VCIDrwHeader);编译,会提示需要创建函数 CreateCommands()和 CreateToolbars();代码如下void VCICLAddin ::CreateCommands(){new CAADrwHeader(“CenterLine”,“CAADrwCenterLine”,“VCICenterLineCmd",(void *)NULL);}CATCmdContainer *VCICLAddin::CreateToolbars(){NewAccess(CATCmdContainer, pCAADrwTlb, MyCenterLine);NewAccess (CATCmdStarter , pCenterLineStr , CenterLineStr );SetAccessCommand (pCenterLineStr , "CenterLine" );SetAccessChild (pCAADrwTlb , pCenterLineStr );AddToolbarView (pCAADrwTlb , 1 , UnDock);return pCAADrwTlb;}CAA工具条插件制作方法添加头文件:.cpp中:#include "CATCreateWorkshop.h"#include "CATCommandHeader.h“.h中:#include "CATCmdContainer.h"在IdentityCard中预定义用到的Framework:AddPrereqComponent("ApplicationFrame",Protected);在imakfile.mk中添加引用API所在的模块名:CATApplicationFrameCAA工具条插件制作方法在刚建立的Module中插入Command:VCICenterLineCmdCAA工具条插件制作方法同样的方法,插入Dialog: VCICenterLineDlgCAA工具条插件制作方法框架搭建好以后的历程树:CAA工具条插件制作方法现在我们在Cmd中编码,使在触发Cmd的时候,给Dlg一个信号,使其动作。
CATIACAA二次开发详细教程(3):添加Addin(菜单、对话框)

CATIACAA⼆次开发详细教程(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和命令的名字,参数四缺省就⾏了。
Catia的二次开发

近的项目也快结束了,第一次接触Catia的二次开发,对于一个以前完全没有学过Catia 的人来说,当时感觉这似乎是不可能完成的任务。
Catia二次开发多数是以VB进行,网上的资料也偏VB居多,而我们偏偏选择了CAA,使用C++开发。
网上关于CAA的二次开发相关资料不多,但是CAA自带了很详细的说明文档,类库,和大量示例程序(虽然我至今也仍未跑成功过它的例子)。
现在就准备将项目开发过程中一些认为比较重要的部分记录下来。
在项目中,有一个很重要的功能,就是上传Catia文件。
普通的上传文档并不困难,但关键在于Catia文件带有相链接的文档,比如CATProduct文件,所以需要在程序中自动找到Catia文件的相链接的文档。
起初,在帮助文档中找到一篇关于Retrieving a Product's Properties的文章,其中介绍了如何打印一个文档的属性。
首先它获得文档的根CATIProduct对象,然后获得它的所有孩子GetAllChildren(),这个方法将获得CATIProduct对象的所有孩子,并且不分层次。
然后使用CATIAttributesDescription类来获得CATIProduct的属性名,最后通过CATIInstance对象获得属性名对应的属性值,从CATIProduct获得CATIAttributesDescription和CATIInstance对象的操作如下:CATIProduct *iInstanceProd;......CATIAttributesDescription *piAttrDesc = NULL;iInstanceProd->QueryInterface(IID_CATIAttributesDescription, (void **) &piAttrDesc); CATIInstance *piInstance = NULL;rc = iInstanceProd->QueryInterface(IID_CATIInstance, (void **) &piInstance);接着就可以使用CATIAttributesDescription的List()方法将属性获取到一个CATListValCATAttributeInfos对象中,然后就是对CATListValCATAttributeInfos的一个遍历过程。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
用户界面开发——实例说明——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。