CATIA二次开发(CAA)技术基础零件设计说明_第1页
CATIA二次开发(CAA)技术基础零件设计说明_第2页
CATIA二次开发(CAA)技术基础零件设计说明_第3页
CATIA二次开发(CAA)技术基础零件设计说明_第4页
CATIA二次开发(CAA)技术基础零件设计说明_第5页
已阅读5页,还剩15页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

第五章部件设计5.1部件设计环境图5.1部件设计环境部件设计环境中,MyPart1中包含参照平面(包含XY平面、YZ平面、ZX平面)、轴系、参数、几何图形集、有序几何图形集、部件几何体、几何体、会合中的几何体等节点。几何图形集是无序建模,一般全曲面建模就是他比较管用;有序几何图形集,他里面能够包含会合中的几何体,几何图形集,几何特色,但建模方式是有序的;几何体是直接插入部件环境下,他里面能够包含几何图形集,有序几何图形,几何特色,但建模方式是有序的;会合中的几何体在插入前会咨询用户,他能够放在树的根目录下也能够放在有序几何图形集里面,...还能够在插入的同时把有序几何图形集里的特色会合到(会合中的几何体)里面。5.2部件设计接口介绍操控部件的一般步骤...图5.2操控部件的主要接口及步骤获取CATIPrtPart参照代码以下:CATIPrtContainer_varspPrtContainer=spContainer;CATIPrtPart_varspPrtPart=spPrtContainer->GetPart( );获取部件下全部节点方法一:利用CATIDescendants接口CATIDescendants_varspDescendantsOnPart=spPrtPart;CATListValCATISpecObject_varspSpecObjects;piDescendantsOnPart->GetAllChildren("CATISpecObject",spSpecObjects);方法二:利用CATContainer中的ListMembersHere方法SEQUENCE(CATBaseUnknown_ptr)ListObj;longNbObj=piRootContainer->ListMembersHere("CATISpecObject",ListObj);for(intj=0;j<NbObj;j++)//注意从0开始{}注意:"CATISpecObject"表示将全部的节点列出,假如想要只列出某种元素,能够将该参数设置为相应的接口,比方"CATPoint"表示全部的点。获取参照平面参照平面包含XY平面、YZ平面、ZX平面,参照代码以下:CATListValCATISpecObject_varspReferencePlanes;spReferencePlanes=spPrtPart->GetReferencePlanes( );注意:spReferencePlanes为包含三个元素的数组,数组元素挨次为xy平面,yz平面和zx平面。假如要使用yz平面,则参照代码以下:CATISpecObject_varspyzPlane=spReferencePlanes[2];获取轴系参照代码以下:CATIMf3DAxisSystemManager_varspAxisSystem=NULL_var;spPrtPart->QueryInterface(IID_CATIMf3DAxisSystemManager,(void**)&spAxisSystem);...获取的全部轴系CATLISTV(CATIMf3DAxisSystem_var)oAxisSystemList;spAxisSystem->GetAxisSystems(oAxisSystemList);获取参数方法一:利用CATIDescendants接口CATIDescendants_varspDescendantsOnPart=spPrtPart;CATListValCATISpecObject_varspSpecObjects;piDescendantsOnPart->GetAllChildren("CATICkeParm",spSpecObjects);方法二:利用CATIParmPublisher中接口CATIParmPublisher_varspParmPublisher=spPrtPart;CATListValCATISpecObject_varListFound;spParmPublisher->GetAllChildren("CATICkeParm",ListFound);方法三:利用CATContainer中的ListMembersHere方法SEQUENCE(CATBaseUnknown_ptr)ListObj;longNbObj=spContainer->ListMembersHere("CATICkeParm",ListObj);for(intj=0;j<NbObj;j++)//注意从0开始{CATIAlias_varspAlias=ListObj[j];cout<<spAlias->GetAlias( )<<endl;//输出参数的名字}获取几何图形集等节点该节主要介绍获取几何图形集、有序几何图形集、部件几何体、几何体、会合中的几何体等节点的方法,主要方法流程图如图5.3所示。...获取CATIPrtPart获取CATIPartRequestGetAllBodiesGetSurfBodiesGetSolidBodiesGetMainBody几何图形集有序几何图形集部件几何领会合中几何体的几何体CATIMmiNonOrderedGeometricalSetCATIMmiOrderedGeometricalSetCATIGSMToolCATIMechanicalTool获取CATIBodyRequestCATBody图5.3流程图例1:获取部件中的全部几何体的代码以下。CATIPartRequest*pIPartRequest=NULL;HRESULTrc=spPart->QueryInterface(IID_CATIPartRequest,(void**)&pIPartRequest);if(SUCCEEDED(rc)){CATLISTV(CATBaseUnknow_var)ListBodies;//全部几何体CATUnicodeStringViewContext="MfDefault3DView";rc=pIPartRequest->GetSolidBodies(ViewContext,ListBodies);}例2:获取部件中的全部有序几何图形集的代码以下。CATIDescendants_varspDescendantsOnPart=spPrtPart;CATListValCATISpecObject_varspSpecOGSs;//全部有序几何图形集piDescendantsOnPart->GetAllChildren("CATIMmiOrderedGeometricalSet",spSpecOGSs);例3:获取部件几何体的代码以下。CATBaseUnknow_varspMainBody;//部件几何体...pIPartRequest->GetMainBody(ViewContext,spMainBody);例4:获取CATBody的代码以下。CATIBodyRequest*pIBodyRequest=NULL;spMainBody->QueryInterface(IID_CATIBodyRequest,(void**)&pIBodyRequest);CATLISTV(CATBaseUnknown_var)ListResult;pIBodyRequest->GetResults("",ListResult);CATIGeometricalElement*pIGeometricalElement=NULL;for(inti=1;i<=ListResult.Size( );i++){CATBaseUnknown_varspResult=ListResult[i];spResult->QueryInterface(IID_CATIGeometricalElement,(void**)&pIGeometricalElement);CATBody_varspBodyResult=pIGeometricalElement->GetBodyResult( );}创立轴系第一初始化工厂CATIMf3DAxisSystemFactory*pIMf3DAxisSystemFactoryOnFeatCont=spContainer;CATMathPointOrigin(150.0,.0,.0);CATMathVectorX(1.0,.0,.0);CATMathVectorY(0.0,1.0,.0);CATIMf3DAxisSystem_varNewAxisSystemStd;//创立的轴系pIMf3DAxisSystemFactoryOnFeatCont->CreateAxisSystem(Origin,X,Y,NewAxisSystemStd);对轴系的X、Y方向进行改正NewAxisSystemStd->SetAxisDirection(CATAxisSystemXNumber,pVectorX);NewAxisSystemStd->SetAxisDirection(CATAxisSystemYNumber,pVectorY);创立参数和公式1.创立参数//初始化CATICkeParmFactory工厂CATICkeParmFactory_varspParmFactory=spContainer;CATICkeParm_varspParam1=spParmFactory->CreateLength("Base",0.1);CATICkeParm_varspParam2=spParmFactory->CreateLength("Width",0.15);//长度单位为米...CATICkeParm_varspParam3=spParmFactory->CreateLength("Height",0.2);//创立长度参数...CATIParmPublisher与CATICkeFunctionFactory功能为将全部参数显示在构造树中CATIParmPublisher_varspParmPublisher=NULL_var;CATICkeFunctionFactory_varspFuncFactory=CATCkeGlobalFunctions::GetFunctionFactory( );spParmPublisher=spFuncFactory->GetCurrentSet(CATICkeFunctionFactory::Parameter,spPrtPart,CATCke::True);spParmPublisher.Append(spParam1);spParmPublisher.Append(spParam2);spParmPublisher.Append(spParam3);2.创立公式创立参数列表CATCkeListOfParmpList;pList->Append(spParam1);pList->Append(spParam2);pList->Append(spParam3);//创立公式Height=Width+BaseCATICkeRelation_varspFormula1=spParmFactory->CreateFormula("Formula","","",spParam3,pList,"Width+Base",spParmPublisher,CATCke::True);spFuncFactory->AddToCurrentRelationSet(spFormula1,spParmPublisher);改正参数进行测试spParam1->Valuate(0.5);创立几何图形集等节点//初始化CATIMechanicalRootFactory工厂CATIMechanicalRootFactory_varspMechanicalRootFactory=spContainer;//创立几何图形集virtualHRESULTCreateGeometricalSet(constCATUnicodeString&iUserName,constCATISpecObject_var&iDestination,CATISpecObject_var&oGeomSet,intiPosition=-1)=0;函数说明以下表5.1所示:...表5.1函数说明iDestination为部件节点iDestination为其余节点iPosition=-1几何图形集位于部件最后几何图形集与iDestination在同一父节点iPosition=0几何图形集位于部件最后几何图形集位于iDestination中的最后几何图形集位于部件中几何图形集位0<iPosition<=iDestinatio+1处于iDestinationn的大小iPosition中的OtherwiseE_FAILE_FAIL//创立有序的几何图形集virtualHRESULTCreateOrderedGeometricalSet(constCATUnicodeString&iUserName,constCATISpecObject_var&iDestination,CATISpecObject_var&oOrderedGeomSet,intiPosition=-1)=0;创立几何体virtualCATISpecObject_varCreatePRTTool(constCATUnicodeString&iUserName,constCATISpecObject_var&iDestination);virtualCATISpecObject_varCreatePRTTool(constCATUnicodeString&iUserName,constCATISpecObject_var&iDestinationintiPosition=-1);创立实体特色实体特色主要包含凸台、槽、旋转体、孔、盒体、倒圆、倒角和厚曲面等特色,创立实体特色采纳CATIPrtFactory工厂中的方法,相应的方法以下表所示。表5.2创立实体特色的方法目标方法凸台CreatePad槽CreatePocket旋转体CreateRotate孔CreateHole盒体CreateShell倒圆CreateFillet倒角CreateChamfer厚曲面CreateThickness...现举创立孔的例子以下:1.常用的创立孔的方法包含三种,挨次以下。publicvirtualCATISpecObject_varCreateHole(constCATISpecObject_varihSurface,constCATISpecObject_varihDirection)=0参数介绍:ihSurface指支持孔的平面或曲面;ihDirection指孔的特色方向,特色方向可用CATIGSMFactory中的CreateDirection创立,孔方向若为NULL_var,则依据曲面的法向创立孔。publicvirtualCATISpecObject_varCreateHole(constCATISpecObject_varihPoint,constCATISpecObject_varihSurface,constCATISpecObject_varihDirection,constintIsPointOnSurface)=0参数介绍:ihPoint指在支持面上的特色点;ihSurface指支持孔的平面或曲面;ihDirection指孔的特色方向,孔方向若为NULL_var,则依据曲面的法向创立孔;IsPointOnSurface的值如果为0,说明ihPoint不在ihSurface上,若为0,则说明ihPoint在ihSurface上。publicvirtualCATISpecObject_varCreateHole(constCATMathPointiMathPoint,constCATISpecObject_varihSurface,constCATISpecObject_varihDirection,constintIsPointOnSurface)=0参数介绍:iMathPoin指在支持面上的数学点;ihSurface指支持孔的平面或曲面;ihDirection指孔的方向,孔方向若为NULL_var,则依据曲面的法向创立孔;IsPointOnSurface的值假如为0,说明ihPoint不在ihSurface上,若为0,则说明ihPoint在ihSurface上。2.设置孔的参数CATISpecObject_varspHole=spPrtFactory->CreateHole( );CATINewHole_varspNewHole=spHole;spNewHole->SetHoleType(1);//设置孔种类为简单孔spNewHole->SetBottomType(1);//设置孔底面种类为平底spNewHole->SetDiameter(5)//设置直径spNewHole->SetLimit(1)//设置为盲孔CATIHoleLimit_varspHoleLimit=spHole;...spHoleLimit->SetOffset(5);//设置孔的深度3.将孔增添在构造树中...spHole->Update( );CATIGSMProceduralView_varispProcView=spHole;if(NULL_var!=ispProcView){HResultrc=ispProcView->InsertInProceduralView( );}创立部件设计表//初始化CATICkeParmFactory工厂CATICkeParmFactory_varspParmFactory=spContainer;创立设计表的函数以下CATIDesignTable_varCreateDesignTable(constCATUnicodeString&iRelationName,constCATUnicodeString&iComment,constCATUnicodeString&iFilePath,intorientation=1,intsheetWithoutFile=0);函数说明:iRelationName为设计表的名字,iComment为设计表的说明,iFilePath为创建表的路径。创立部件族的步骤以下:1.创立参数CATICkeParm_varspPp1=spFact->CreateInteger("Column1",0);CATICkeParm_varspPp2=spFact->CreateReal("r",0.0);CATICkeParm_varspPp3=spFact->CreateString("s","");CATICkeParm_varspPp4=spFact->CreateBoolean("b",CATCke::True);CATICkeParm_varspPp5=spFact->CreateLength("l",0);CATICkeParm_varspPp6=spFact->CreateAngle("a",0);2.将参数显示在构造树上CATIPrtContainer_varspPrtCont=spContainer;CATIParmPublisher_varspPubroot=spPrtCont->GetPart( );CATICkeFunctionFactory_varfact=CATCkeGlobalFunctions::GetFunctionFactory( );CATISpecObject_varspParameterSet=NULL_var;spParameterSet=fact->GetCurrentSet(CATICkeFunctionFactory::Parameter,spPubroot,CATCke::True);CATIParmPublisher_varspParmPublisher=spParameterSet;...spParmPublisher->Append(spPp1);...spParmPublisher->Append(spPp2);spParmPublisher->Append(spPp3);spParmPublisher->Append(spPp4);spParmPublisher->Append(spPp5);spParmPublisher->Append(spPp6);创立设计表CATIDesignTable_varspDesignTable=spFact->CreateDesignTable( );将设计表显示在构造树上CATISpecObject_varspRelationSet=fact->GetCurrentSet(CATICkeFunctionFactory::Relation,spPubroot,CATCke::True);spParmPublisher=spRelationSet;spParmPublisher->Append(spDesign);将参数与设计表关系,注意参数名字与设计表的列参数名字必定要同样参数列表CATLISTV(CATBaseUnknown_var)list;list.Append(spPp1);spDesign->AutomaticAssociations(spContainer,NULL_var,&list);增添关系spDesign->AddAssociation("Column2",spPp2);spDesign->AddAssociation("Column3",spPp3);spDesign->AddAssociation("Column4",spPp4);spDesign->AddAssociation("Column5",spPp5);6.设置配置spDesign->SetCurrentConfiguration(1);创立草图Sketch有两种方式能够创立草图:经过参照平面创立获取参照平面CATLISTV(CATISpecObject_var)spRefPlanes=spPart->GetReferencePlanes( );初始化草图工厂CATISketchFactory_varspSketchFactory(spContainer);...//在XYplane上创立草图CATISketch_varspSketch=spSketchFactory->CreateSketch(spRefPlanes[1]));经过原点和两个矢量方向该方法经过定义一个原点和两个方向pH、pV进行创立。定义原点和方向:doublepOrigin[3]={0,0,10};doublepH[3]={1,0,0};doublepV[3]={0,1,0};CATISketchFactory_varspSketchFactory(spContainer);CATISketch_varspSketch=spSketchFactory->CreateSketch(pOrigin,pH,pV);创立草图几何第一申明编写草图spSketch->OpenEdition( );CATI2DWFFactory_varsp2DFactory(spSketch);下边创立点CATI2DPoint_varspPt_bottom_left,spPt_bottom_right,spPt_top_right,spPt_top_left;doublept_bottom_left[2]={10,10};doublept_bottom_right[2]={50,10};doublept_top_right[2]={50,50};doublept_top_left[2]={10,50};spPt_bottom_left=sketch2DFactory->CreatePoint(pt_bottom_left);spPt_bottom_right=sketch2DFactory->CreatePoint(pt_bottom_right);spPt_top_right=sketch2DFactory->CreatePoint(pt_top_right);spPt_top_left=sketch2DFactory->CreatePoint(pt_top_left);//开始创立线CATI2DLine_varspLine1,spLine2,spLine3,spLine4;spLine1=sketch2DFactory->CreateLine(pt_bottom_left,pt_bottom_right);spLine2=sketch2DFactory->CreateLine(pt_bottom_right,pt_top_right);spLine3=sketch2DFactory->CreateLine(pt_top_right,pt_top_left);spLine4=sketch2DFactory->CreateLine(pt_top_left,pt_bottom_left);将线的首尾连结起来...CATI2DCurve_varspCurve1(spLine1);CATI2DCurve_varspCurve2(spLine2);CATI2DCurve_varspCurve3(spLine3);CATI2DCurve_varspCurve4(spLine4);spCurve1->SetStartPoint(spPt_bottom_left);spCurve1->SetEndPoint(spPt_bottom_right);spCurve2->SetStartPoint(spPt_bottom_right);spCurve2->SetEndPoint(spPt_top_right);spCurve3->SetStartPoint(spPt_top_right);spCurve3->SetEndPoint(spPt_top_left);spCurve4->SetStartPoint(spPt_top_left);spCurve4->SetEndPoint(spPt_bottom_left);然退后出草图:spSketch->CloseEdition( );创立草图拘束CATI2DConstraintFactory_varspConstraint2DFactory(spSketch);定义spLine1为水平拘束spConstraint2DFactory->CreateConstraint(spLine1,NULL,NULL,NULL,NULL,NULL,NULL,Cst2DType_Horizontal,0,0);定义spLine2为垂直拘束spConstraint2DFactory->CreateConstraint(spLine2,NULL,NULL,NULL,NULL,NULL,NULL,Cst2DType_Vertical,0,0);定义spLine3为水平拘束spConstraint2DFactory->CreateConstraint(spLine3,NULL,NULL,NULL,NULL,NULL,NULL,Cst2DType_Horizontal,0,0);定义spLine4为垂直拘束spConstraint2DFactory->CreateConstraint(spLine4,NULL,NULL,NULL,NULL,NULL,NULL,Cst2DType_Vertical,0,0);//定义spLine2的长度拘束...spConstraint2DFactory->CreateConstraint(spLine2,NULL,NULL,NULL,NULL,NULL,NULL,Cst2DType_Length,0,0);...//定义spLine2与spLine4的距离拘束spConstraint2DFactory->CreateConstraint(spLine2,NULL,spLine4,NULL,NULL,NULL,NULL,Cst2DType_Distance,0,0);//定义spPt_bottom_left与X轴的距离拘束CATI2DAxis_varspSupport=NULL_var;spSketch->GetAbsolute2DAxis(spSupport);spConstraint2DFactory->CreateConstraint(spPt_bottom_left,NULL,spSupport->GetHDirection( ),NULL,NULL,NULL,NULL,Cst2DType_Distance,0,0);//定义spPt_bottom_left与Y轴的距离拘束spConstraint2DFactory->CreateConstraint(spPt_bottom_left,NULL,spSupport->GetVDirection( ),NULL,NULL,NULL,NULL,Cst2DType_Distance,0,0);5.3生成圆柱体实例本实例所实现的功能本实例主要实现创立圆柱的功能,在对话框中直接输入圆柱直径和圆柱高度,点击确立按钮,在部件中自动创立相应直径和高度的圆柱体,其界面如图5.4所示。图5.4创立圆柱界面实现的步骤获取部件指针获取文件指针CATDocument*pDoc=NULL;CATFrmEditor*_pEditor=CATFrmEditor::GetCurrentEditor( );pDoc=_pEditor->GetDocument( );//这里获取了PART环境下的文档指针CATInit_varspInitOnDoc(pDoc);获取部件根容器...CATIPrtContainer*piPrtCont=(CATIPrtContainer*)spInitOnDoc->GetRootContainer("CATIPrtContainer");获取部件指针CATIPrtPart_varspPart=piPrtCont->GetPart( );创立草图初始化草图工厂CATISketchFactory_varspSketchFactory(piPrtCont);//在XYplane上创立草图CATISketch_varspSketch=spSketchFactory->CreateSketch(spRefPlanes[1]));创立草图几何第一申明编写草图spSketch->OpenEdition( );CATI2DWFFactory_

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论