资源描述:
《CAA创建基于草图拉伸(Pad) 的状态命令》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、该例子在工具条创建一个状态命令,用户激活该命令后,根据提示依次选择草图,输入拉伸长度,点击确定完成一个拉伸特征的创建。通过该例子,可以熟悉零件文档的基本结构、获取草图工厂的方法,你还可以掌握如何获得草图支持面的方向。1.创建对话框在名为CAAPadCreateCmd的Module中创建一个名为PadParamInputDlg的对话框,安装如下方式布局并在对话框中添加对应的控件:布局完成后在对话框外的空白处点鼠标左键,然后按CTRL+S进行保存,向导会自动更新对应的资源文件和.h以及.cpp文件。最终该对话框对应的布局代码如下:123456789101112131415voidPadParam
2、InputDlg::Build() { // TODO:Thiscallbuildsyourdialogfromthelayoutdeclarationfile // ------------------------------------------------------------------- //CAA2WIZARDWIDGETCONSTRUCTIONSECTION _Label001=newCATDlgLabel(this,"Label001"); _Label001->SetGridConstraints(0,0,1,1,CATGRID_4S
3、IDES); _EditorSketch=newCATDlgEditor(this,"EditorSketch"); _EditorSketch->SetGridConstraints(0,1,1,1,CATGRID_4SIDES); _Label003=newCATDlgLabel(this,"Label003"); _Label003->SetGridConstraints(1,0,1,1,CATGRID_4SIDES); _EditorOffset1=newCATDlgEditor(this,"EditorOffset1"); _EditorOffs
4、et1->SetGridConstraints(1,1,1,1,CATGRID_4SIDES); _Label005=newCATDlgLabel(this,"Label005"); _Label005->SetGridConstraints(2,0,1,1,CATGRID_4SIDES); _EditorOffset2=newCATDlgEditor(this,"EditorOffset2");161718192021222324252627282930 _EditorOffset2->SetGridConstraints(2,1,1,1,CATGRID_4SIDE
5、S); //ENDCAA2WIZARDWIDGETCONSTRUCTIONSECTION //CAA2WIZARDCALLBACKDECLARATIONSECTION //ENDCAA2WIZARDCALLBACKDECLARATIONSECTION }2. 添加获取编辑框控件的成员方法为了方便命令类获取对话框编辑框控件,以获取或设置编辑框的内容,给对话框类PadParamInputDlg添加成员函数GetEditorControl:123456789//获得对话框控件CATDlgEditor*PadParamInputDlg::GetEditorControl(i
6、ntid){ switch(id){ case1: return_EditorSketch; case2: return_EditorOffset1; case3: return_EditorOffset2;10111213 default: returnNULL; }}3. 在命令类PadStateCmd添加成员变量下面是命令类CAApadCreateStCmd的头文件:classCAAPadCreateStCmd:publicCATS
7、tateCommand{//省略其它向导生成代码//结束当前命令voidExitCommand();//选择草图CATBooleanSelectSketch(void*data);//创建拉伸体CATBooleanCreatePad(void*data);//验证用户输入CATBooleanValidateInput();private://参数输入对话框PadParamInputDlg*_pDlgInput