使用CAA创建工程图(Drafting)的基本步骤

2014-08-05 14:13:38|?次阅读|上传:huigezrx【已有?条评论】发表评论

关键词:C/C++, CAA, CATIA|来源:唯设编程网

4 在工程图文档中的当前页(sheet)追加格式

// 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)中的格式。

5 创建一个附加页(Additional Sheet)并将其添加到工程图特征(Drawing Feature)

CATIDftDrawing接口的AdSheet方法创建页(sheet)并且将它添加到工程图根节点(drawing root)。如果这个方法在交互式环境被调用,页选项卡(sheet tab)将会自动更新。

CATIDftSheet *piDftNewSheet = NULL;
wchar_t *pSheetName= L"MyNewSheet";
if (SUCCEEDED(piDftDrawing->AddSheet(&piDftNewSheet,pSheetName)))
{

6 创建一个视图并将它添加到刚才新建的页(sheet)中

  // 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)。

7 保存文档并退出

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文档的通用步骤。

<12>
发表评论0条 】
网友评论(共?条评论)..
使用CAA创建工程图(Drafting)的基本步骤