Catia二次开发源码分享:创建零件设计表
创建零件设计表//初始化CATICkeParmFactory 工厂
CATICkeParmFactory_var spParmFactory = spContainer;
//创建设计表的函数如下
CATIDesignTable_var CreateDesignTable( const CATUnicodeString& iRelationName,
const CATUnicodeString& iComment,
const CATUnicodeString& iFilePath,
int orientation = 1,
int sheetWithoutFile = 0 );
函数说明:iRelationName 为设计表的名字,iComment 为设计表的说明,iFilePath 为创建
表的路径。
创建零件族的步骤如下:
1.创建参数
CATICkeParm_var spPp1 = spFact->CreateInteger ("Column1",0);
CATICkeParm_var spPp2 = spFact->CreateReal ("r",0.0);
CATICkeParm_var spPp3 = spFact->CreateString ("s","");
CATICkeParm_var spPp4 = spFact->CreateBoolean ("b",CATCke::True);
CATICkeParm_var spPp5 = spFact->CreateLength ("l",0);
CATICkeParm_var spPp6 = spFact->CreateAngle ("a",0);
2.将参数显示在结构树上
CATIPrtContainer_var spPrtCont = spContainer;
CATIParmPublisher_var spPubroot = spPrtCont->GetPart();
CATICkeFunctionFactory_var fact = CATCkeGlobalFunctions::GetFunctionFactory();
CATISpecObject_var spParameterSet = NULL_var;
spParameterSet=
fact->GetCurrentSet(CATICkeFunctionFactory::Parameter,spPubroot,CATCke::True);
CATIParmPublisher_var spParmPublisher = spParameterSet;
spParmPublisher->Append(spPp1);
spParmPublisher->Append(spPp2);
spParmPublisher->Append(spPp3);
spParmPublisher->Append(spPp4);
spParmPublisher->Append(spPp5);
spParmPublisher->Append(spPp6);
3.创建设计表
CATIDesignTable_var spDesignTable = spFact->CreateDesignTable();
4.将设计表显示在结构树上
CATISpecObject_var spRelationSet = fact ->GetCurrentSet(
CATICkeFunctionFactory::Relation,spPubroot,CATCke::True);
spParmPublisher = spRelationSet;
spParmPublisher->Append(spDesign);
5.将参数与设计表关联,注意参数名字与设计表的列参数名字一定要相同
// 参数列表
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);
学习学习 ,后面希望自己也能学会 感谢分享
页:
[1]