2014-09-21 16:28:52|?次阅读|上传:wustguangh【已有?条评论】发表评论
关键词:C/C++, CAA, CATIA|来源:唯设编程网
该例子在工具条创建一个状态命令,用户激活该命令后,根据提示依次选择草图,输入拉伸长度,点击确定完成一个拉伸特征的创建。通过该例子,可以熟悉零件文档的基本结构、获取草图工厂的方法,你还可以掌握如何获得草图支持面的方向。
在名为CAAPadCreateCmd的Module中创建一个名为PadParamInputDlg的对话框,安装如下方式布局并在对话框中添加对应的控件:
布局完成后在对话框外的空白处点鼠标左键,然后按CTRL+S进行保存,向导会自动更新对应的资源文件和.h以及.cpp文件。最终该对话框对应的布局代码如下:
void PadParamInputDlg::Build() { // TODO: This call builds your dialog from the layout declaration file // ------------------------------------------------------------------- //CAA2 WIZARD WIDGET CONSTRUCTION SECTION _Label001 = new CATDlgLabel(this, "Label001"); _Label001 -> SetGridConstraints(0, 0, 1, 1, CATGRID_4SIDES); _EditorSketch = new CATDlgEditor(this, "EditorSketch"); _EditorSketch -> SetGridConstraints(0, 1, 1, 1, CATGRID_4SIDES); _Label003 = new CATDlgLabel(this, "Label003"); _Label003 -> SetGridConstraints(1, 0, 1, 1, CATGRID_4SIDES); _EditorOffset1 = new CATDlgEditor(this, "EditorOffset1"); _EditorOffset1 -> SetGridConstraints(1, 1, 1, 1, CATGRID_4SIDES); _Label005 = new CATDlgLabel(this, "Label005"); _Label005 -> SetGridConstraints(2, 0, 1, 1, CATGRID_4SIDES); _EditorOffset2 = new CATDlgEditor(this, "EditorOffset2"); _EditorOffset2 -> SetGridConstraints(2, 1, 1, 1, CATGRID_4SIDES); //END CAA2 WIZARD WIDGET CONSTRUCTION SECTION //CAA2 WIZARD CALLBACK DECLARATION SECTION //END CAA2 WIZARD CALLBACK DECLARATION SECTION }
为了方便命令类获取对话框编辑框控件,以获取或设置编辑框的内容,给对话框类PadParamInputDlg添加成员函数GetEditorControl:
//获得对话框控件 CATDlgEditor* PadParamInputDlg::GetEditorControl(int id){ switch(id){ case 1: return _EditorSketch; case 2: return _EditorOffset1; case 3: return _EditorOffset2; default: return NULL; } }