最近开发中涉及到了WorkingSupport,工作支持面…(开发版本R18),通过各种方式,并未找到相关接口,则去寻找相关大神,大神回复:CATIGSMWorkingSupport….曙光来到,心头一喜…可帮助文档中并无此接口,最后了解到,此接口在R22版本中才出现在帮助文档中。无奈…
最后,死马当活马医…我找到R22帮助文档,直接拿来使用,竟然成功了…
一下代码纯属测试,杂乱无章,待以后整理…
HRESULT hr = S_OK;
//---------------------------------------------//
// 1 - Retrieve Specification container //
//---------------------------------------------//
CATFrmEditor *pEditor = CATFrmEditor::GetCurrentEditor();
CATPathElement path = pEditor->GetUIActiveObject ( );
CATISpecObject *piSpecOnActive = NULL;
hr = path.Search (IID_CATISpecObject, (void **) &piSpecOnActive );
if (FAILED(hr)||(NULL == piSpecOnActive)) {
cout<<"failed to get interface CATISpecObject from active object"<<endl;
}
// GetFeatContainer returns a smart pointer, we must store the result in a SP
// Otherwise, we will loose the reference on the returned object
CATIContainer_var spSpecCont = piSpecOnActive->GetFeatContainer();
piSpecOnActive->Release();piSpecOnActive=NULL;
CATIPrtContainer_var spPrtCont(spSpecCont);
CATIPrtPart_var spPart = spPrtCont->GetPart();
CATIGSMWorkingSupportFactory *piWorkingSupport = NULL;
hr = spSpecCont->QueryInterface (IID_CATIGSMWorkingSupportFactory, (void **) &piWorkingSupport );
CATListValCATISpecObject_var spListRefPlanes = spPart->GetReferencePlanes();
// defines the xy plane as the first sketch plane
CATISpecObject_var spSketchPlane = spListRefPlanes[1];
CATIGSMWorkingSupport::GridType Type = CATIGSMWorkingSupport::GSMCartesianGrid;
CATIGSMWorkingSupport_var spWorkingSupport = piWorkingSupport->CreateWorkingSupport(spSketchPlane, Type);
CATIDescendants_var spDesc(spPart);
CATISpecObject_var spObject(spCartesianGrid);
spDesc ->Append(spObject);