挂树
HRESULT wwwwww::InsertObjOnTree(CATIProduct_var ispProd,CATISpecObject_var ispiSpecGSMTool,CATUnicodeString istrObjName,CATBody_var ispBody, CATISpecObject_var &ospiSpecObj)
{
HRESULT rc = S_OK;
//
if (ispProd == NULL_var || ispBody == NULL_var)
{
return E_FAIL;
}
//
CATSoftwareConfiguration * pConfig = new CATSoftwareConfiguration();//配置指针
CATTopData * topdata =new CATTopData(pConfig, NULL);//topdata
CATIPrtContainer_var ospiCont=NULL_var;
CATGeoFactory* pGeoFactory=_pTGen->GetProductGeoFactoryAndPrtCont(ispProd,ospiCont);
if (ospiCont==NULL_var||pGeoFactory==NULL)
{
cout<<"GetProductGeoFactoryAndPrtCont Failed"<<endl;
return E_FAIL;
}
//
CATIDatumFactory *piDatumFactory =NULL;
ospiCont->QueryInterface(IID_CATIDatumFactory,(void**) &piDatumFactory);
if (piDatumFactory==NULL)
{
cout<<"QI CATIDatumFactory Failed"<<endl;
return E_FAIL;
}
//特征化
CATISpecObject * pTempSpec = NULL;
rc=piDatumFactory->InstanciateDatum(ispBody,pTempSpec);
if (pTempSpec==NULL_var)
{
return E_FAIL;
}
CATISpecObject_var spiTempSpec = pTempSpec;
CATTry
{
spiTempSpec ->Update();
}
CATCatch(CATMfErrUpdate , pUpdateError)
{
return E_FAIL;
}
CATCatch(CATError , pError)
{
return E_FAIL;
}
CATEndTry
//重命名
if (istrObjName != "")
{
CATIAlias_var spiAlias = spiTempSpec;
if (spiAlias != NULL_var)
{
spiAlias->SetAlias(istrObjName);
}
}
//插入模型树中,放在该GeoSet下
CATIPrtProceduralView_var spiProceduralView = spiTempSpec;
//CATIGSMProceduralView_var spiProceduralView = spiTempSpec;
if (NULL_var != spiProceduralView )
{
spiProceduralView->InsertInProceduralView(ispiSpecGSMTool);
}
//
if (ispiSpecGSMTool != NULL_var)
{
ispiSpecGSMTool->Update();
}
ospiSpecObj = spiTempSpec;
return rc;
}
放在指定Geo下