|
马上注册登录,享用更多网站功能!
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
想做一个交互模式的参数化的例子,现在交互界面做好了(如图),参数化驱动程序写完了,但是运行时一直有点问题,感觉应该是获取参数列表和参数赋值有问题,但一直解决不了,功能实现的主要代码如下,程序框架在附件上,请指点。
//内存中加载零件
HRESULT rc=E_FAIL;
CATDocument * pDocument=NULL;
CATUnicodeString ModelDocName="F:\savefile\catia_development\zhou.CATPart";
rc = CATDocumentServices::OpenDocument(ModelDocName,pDocument);
if (SUCCEEDED(rc))
{
CATInit *pInitOnDoc=NULL;
rc = pDocument->QueryInterface(IID_CATInit,(void**)&pInitOnDoc);
//获取零件的根容器
CATIPrtContainer *pIPrtCont = NULL;
pIPrtCont=(CATIPrtContainer *)pInitOnDoc->GetRootContainer("CATIPrtContainer");
//获取零件设计特征
CATISpecObject_var spSpecObjectPart = pIPrtCont->GetPart();
if (NULL_var != spSpecObjectPart)
{
//获取参数列表
CATIParmPublisher * pIParmPublisher = NULL;
rc = spSpecObjectPart->QueryInterface(IID_CATIParmPublisher,(void**)&pIParmPublisher);
if (SUCCEEDED(rc))
{
CATUnicodeString L1="L1";
CATUnicodeString L2="L2";
CATLISTV (CATISpecObject_var) List ;
CATICkeParm *pICkeParm = NULL;
pIParmPublisher->GetAllChildren("CATICkeParm",List);
int Nb = List.Size();
if ( Nb >= 1 )
{
CATISpecObject_var specObj = List[1] ;
rc = specObj->QueryInterface(IID_CATICkeParm,(void**) &pICkeParm);
}
//根据特征尺寸依次获取参数并赋值
if (pICkeParm->Name()==L1)
{
L1=pICkeParm->Content();
CATUnicodeString msg;
double OutputReal;
msg = _pL1Editor->GetText();
int IsConversionOK = msg.ConvertToNum(&OutputReal);
OutputReal = OutputReal/1000;
pICkeParm->Valuate(OutputReal);
}
else
{
L2=pICkeParm->Content();
msg = _pL2Editor->GetText();
int IsConversionOK = msg.ConvertToNum(&OutputReal);
OutputReal = OutputReal/1000;
pICkeParm->Valuate(OutputReal);
}
ObjectUpdate(spSpecObjectPart);
}
}
}
|
|