V5-工程图标准的建立
在利用TPS视图投影生成工程图时,遇到了这样一个问题,CATIA提示一下错误:
“如果3D视图和工程图使用不同标准,则无法生成视图。请使用与3D视图相同的标准创建视图,然后重新启动该命令”
这是因为再利用CAA创建工程图后,为了保险起见,需要对工程图的标准进行设定。
// Gets the drawing feature using the CATIDftDocumentServices interface
CATIDrawing *piDrawing = NULL;
CATIDftDocumentServices *piDftDocServices = NULL;
CATIContainer_var spDrwcont;
CATISpecObject_var spSpecObj;
if (SUCCEEDED(pDoc->QueryInterface(IID_CATIDftDocumentServices, (void **)&piDftDocServices)))
{
// pDoc为创建的工程图文档
piDftDocServices->GetDrawing(IID_CATIDrawing, (void **)&piDrawing);
piDftDocServices->Release();
piDftDocServices = NULL;
spSpecObj=piDrawing;
if (spSpecObj != NULL_var) spDrwcont = spSpecObj->GetFeatContainer();
}
if (spDrwcont != NULL_var)
{
CATIDftStandardManager *piStdmgr = NULL;
HRESULT rc = spDrwcont->QueryInterface(IID_CATIDftStandardManager,(void**)&piStdmgr);
if (SUCCEEDED(rc))
{
// Find a standard in the list of allowed standards (ie. the list of .CATDrwSTD files in the reffiles directory)
CATIStringList *piListstd = NULL;
if ( SUCCEEDED(piStdmgr->GetAvailableStandards(&piListstd)) && piListstd )
{
unsigned int nbrstd = 0;
piListstd->Count(&nbrstd);
for (unsigned int indice = 0; indice < nbrstd; indice ++)
{
wchar_t *wstd = NULL;
if ( SUCCEEDED ( piListstd->Item ( indice, &wstd ) ) && wstd )
{
CATUnicodeString stdname;
const CATUnicodeString ANSI_UncS = "ANSI";
stdname.BuildFromWChar(wstd);
if ( stdname == ANSI_UncS )
{
// Import the ANSI standard in the document
piStdmgr->ImportStandard (wstd);
break;
}
}
if (wstd) {delete[] wstd; wstd = NULL;}
}
piListstd->Release(); piListstd=NULL;
}
piStdmgr->Release (); piStdmgr=NULL;
}
}