Catia二次开发源码分享:创建参数和公式
创建参数和公式1.创建参数
//初始化CATICkeParmFactory 工厂
CATICkeParmFactory_var spParmFactory = spContainer;
CATICkeParm_var spParam1 = spParmFactory->CreateLength("Base",0.1);
CATICkeParm_var spParam2 = spParmFactory->CreateLength("Width",0.15);//长度单位为米
CATICkeParm_var spParam3 = spParmFactory->CreateLength("Height",0.2);//创建长度参数
// CATIParmPublisher 与CATICkeFunctionFactory 功能为将所有参数显示在结构树中
CATIParmPublisher_var spParmPublisher = NULL_var;
CATICkeFunctionFactory_var spFuncFactory =CATCkeGlobalFunctions::GetFunctionFactory();
spParmPublisher=
spFuncFactory->GetCurrentSet(CATICkeFunctionFactory::Parameter,spPrtPart,CATCke::True);
spParmPublisher.Append(spParam1);
spParmPublisher.Append(spParam2);
spParmPublisher.Append(spParam3);
2.创建公式
//创建参数列表
CATCkeListOfParm pList;
pList->Append (spParam1);
pList->Append (spParam2);
pList->Append (spParam3);
//创建公式Height = Width + Base
CATICkeRelation_var spFormula1 = spParmFactory->CreateFormula("Formula","","",
spParam3, pList, "Width+Base", spParmPublisher, CATCke::True);
spFuncFactory->AddToCurrentRelationSet(spFormula1, spParmPublisher);
//修改参数进行测试
spParam1->Valuate(0.5);
页:
[1]