2014-08-05 14:13:38|?次阅读|上传:huigezrx【已有?条评论】发表评论
关键词:C/C++, CAA, CATIA|来源:唯设编程网
// Adds the format to the current sheet. CATIDftSheet *piDftSheet = NULL; CATIDftSheetFormat *piDftSheetFormat = NULL; // Gets active sheet. if (SUCCEEDED(piDftDrawing->GetActiveSheet(&piDftSheet))) { CATIDftSheetFormat *piDftSheetFormat = NULL; if (piDftSheet && SUCCEEDED(piDftSheet->QueryInterface (IID_CATIDftSheetFormat,(void **)&piDftSheetFormat))) { if (FAILED(piDftSheetFormat->SetSheetFormat(myFormatName))) { // Memory clean. piDftSheetFormat->Release(); piDftSheetFormat=NULL; piDftSheet->Release(); piDftSheet=NULL; piDftDrawing->Release(); piDftDrawing=NULL; CATDocumentServices::Remove (*pDoc); ::Delete_Session("SampleSession"); return 5; } piDftSheetFormat->Release(); piDftSheetFormat=NULL; } piDftSheet->Release(); piDftSheet=NULL; }
CATDftDrawingFormat接口有工程图根节点(drawing root)实现。GetAvailableFormats方法返回可用格式的列表。SetSheetFormat方法初始化页(sheet)中的格式。
CATIDftDrawing接口的AdSheet方法创建页(sheet)并且将它添加到工程图根节点(drawing root)。如果这个方法在交互式环境被调用,页选项卡(sheet tab)将会自动更新。
CATIDftSheet *piDftNewSheet = NULL; wchar_t *pSheetName= L"MyNewSheet"; if (SUCCEEDED(piDftDrawing->AddSheet(&piDftNewSheet,pSheetName))) {
// The drawing factory is implemented on the drawing container CATIDrwFactory_var spDrwFact = spDrwCont; // 5. Creating a View and Adding it to the Just Created Sheet // =========================================================== // Create a view with Make Up CATIDftViewMakeUp *piNewViewMU = NULL; if (NULL_var != spDrwFact && SUCCEEDED(spDrwFact -> CreateViewWithMakeUp(IID_CATIDftViewMakeUp, (void **)&piNewViewMU))) { if (piNewViewMU) { // Gets the view from the MakeUp CATIView *piNewView = NULL; if (SUCCEEDED(piNewViewMU->GetView(&piNewView))) { if (piNewView) { // The view has to be typed: FrontView for Interactive view. piNewView->SetViewType(FrontView); piNewViewMU->SetAxisData(100.0,50.0); // At last, add the view to the sheet if (piDftNewSheet) piDftNewSheet->AddView(piNewViewMU);
为了在视图(view)中创建几何元素,对应的视图必须设置成当前视图。通过当前视图获取线框工厂(Wire frame factory)。
if (rc == 0) { hr = CATDocumentServices::SaveAs(*pDoc, (char *)fileName); if (FAILED(hr)) { CATDocumentServices::Remove (*pDoc); ::Delete_Session("SampleSession"); return 1; } } // Ends session and drops document. CATDocumentServices::Remove (*pDoc); ::Delete_Session("SampleSession"); return rc;
这部分描述了保存一个新建CATIA文档的通用步骤。