Mechanical Design

2D Layout for 3D Design

Creating 2D Layout Views from FTA Components

How to create 2DL Views from View or Capture created in 3D Functional Tolerancing & Annotation Application

Use Case

Abstract

This article discusses the CAA2DLCreate2DLViewFromFTA use case. This use case explains how to create a 2DL View from a 3D Functional Tolerancing & Annotation View or FTA Capture.

    2DL means: 2D Layout for 3D Design, this is the name of the CATIA application.

    FTA means: Functional Tolerancing & Annotation, this is the name of the CATIA application.


What You Will Learn With This Use Case

This use case is intended to show you how to access callouts in generative views.

[Top]

The CAA2DLCreate2DLViewFromFTA  Use Case

CAA2DLCreate2DLViewFromFTA  is a use case of the CAADrafting2DLInterfaces.edu framework that illustrates Drafting2DLInterfaces framework capabilities.

[Top]

What Does CAA2DLCreate2DLViewFromFTA  Do?

Fig. 1: Initial Document

Fig. 1 represents a part document containing an Annotation Set with FTA views and FTA captures.

 

 

Fig. 2 The Document modified by the Use Case

Fig. 2 represents the Part document modified by the use case program.

A Layout Root has been created with the same standard than FTA Annotation standard, then, two 2DL Views have been created from the FTA FrontView.1 and FTA Capture.1. A 2DL filter has been created from the FTA capture filter during the 2DL View creation from the capture.

 

[Top]

How to Launch CAA2DLCreate2DLViewFromFTA

To launch CAA2DLCreate2DLViewFromFTA , you will need to set up the build time environment, then compile CAA2DLCreate2DLViewFromFTA  along with its prerequisites, set up the run time environment, and then execute the use case [1].

When you launch the use case, pass the full pathname of the CATPart file as argument. A Part document is delivery in the following path: CAADrafting2DLInterfaces.edu\CNext\resources\graphic\CAA2DLPartWithFTA.CATPart.

[Top]

Where to Find the CAA2DLCreate2DLViewFromFTA  Code

The CAA2DLCreate2DLViewFromFTA  use case is made of a single source file named CAA2DLCreate2DLViewFromFTA .cpp located in the CAA2DLCreate2DLViewFromFTA .m module of the CAADrafting2DLInterfaces.edu framework:

Windows InstallRootDirectory\CAADrafting2DLInterfaces.edu\CAA2DLCreate2DLViewFromFTA .m\
Unix InstallRootDirectory/CAADrafting2DLInterfaces.edu/CAA2DLCreate2DLViewFromFTA .m/

where InstallRootDirectory is the directory where the CAA CD-ROM is installed.

[Top]

Step-by-Step

There are seven steps in CAA2DLCreate2DLViewFromFTA :

  1. Opening a Part Document
  2. Retrieving the TPS Set
  3. Retrieving the Part Root from the container
  4. Creating the 2DL Layout Root
  5. Retrieving the FTA Active View and the Capture
  6. Creating the 2DL View From FTA components
  7. Saving the Part Document and Exiting

[Top]

Opening a Part Document

int main(int iArgc, // Number of arguments (2) 
char** iArgv) // Path to the new *.CATPart document
{
  // Check arguments
  if(3 != iArgc) return 1;
  const char *pfileNamePart = iArgv[1];
  const char *pfileNameOut = iArgv[2];
  
  // CREATE THE SESSION
  // ==================
  CATSession *pSampleSession = NULL;
  HRESULT hr = ::Create_Session("SampleSession",pSampleSession);
  if (FAILED(hr)) return 1;


  // READ THE PART DOCUMENT 
  // ======================
  CATDocument *pDocPart = NULL;
  if( SUCCEEDED(CATDocumentServices::OpenDocument(pfileNamePart, pDocPart)) && pDocPart)
  {
    CATInit_var spInitOnDoc(pDocPart);
    if(NULL_var != spInitOnDoc)
...

This section represents the usual sequence for loading a CATIA document [2].

[Top]

Retrieving the TPS Set

...
// Retrieves the TPS Component: The TPS Set
//=========================================
CATITPSDocument *piTPSDoc= NULL;
CATITPSSet *piTPSSet = NULL;
if (SUCCEEDED(spInitOnDoc->QueryInterface(IID_CATITPSDocument,(void **)&piTPSDoc)) && piTPSDoc)
{
  CATITPSList *piTPSList = NULL;
  if (SUCCEEDED(piTPSDoc->GetSets(&piTPSList)) && piTPSList)
  {
    unsigned int nbSet;
    piTPSList->Count(&nbSet);
    // Only one set in the Part Document
    if (nbSet > 0)
    {
      CATITPSComponent *piTPSCmp = NULL;
      if (SUCCEEDED(piTPSList->Item(0,&piTPSCmp)) && piTPSCmp)
      {
        piTPSCmp->QueryInterface(IID_CATITPSSet,(void **)&piTPSSet);
        if (piTPSSet)
        cout << " The active TPS Set is correctly retrieved" << endl;
        piTPSCmp->Release();piTPSCmp=NULL;
      }
    }
    piTPSList->Release();piTPSList=NULL;
  }
  piTPSDoc->Release();piTPSDoc=NULL;
}
...

The Annotation Set is aggregated by the Mechanical Part. CATITPSDocument allows to retrieve the Annotation Set from the document. When the document is a CATProduct, several Annotation Sets may be retrieved if the recursive mode is activated [3].

[Top]

Retrieving the Part Root from the container

...
// Retrieves the Part Root from the container
// ===========================================
CATIPrtContainer * piPrtCont = (CATIPrtContainer*) spInitOnDoc->GetRootContainer("CATIPrtContainer"); 
if (piPrtCont)
{
  // Get the part feature of the container.
  CATIPrtPart_var spPart = piPrtCont->GetPart();
...

GetPart method defined in CATIPrtPart interface returns the Mechanical Part.

[Top]

Creating the 2DL Layout Root

...
// Creates the 2DLayout Root
// =========================
if (NULL_var != spPart)
{
  CATI2DLayoutLayout *pi2DLayout = NULL;
  cout << "call CAT2DLayoutServices::GetLayout2DL" << endl;
  CAT2DLayoutServices::GetLayout2DL(spPart,&pi2DLayout);

  if (!pi2DLayout)
  {
    cout << "No 2DL. A 2DL must be created "<< endl;
    CATListOfCATUnicodeString lstStd;
    if (SUCCEEDED(CAT2DLayoutServices::GetAvailable2DLayoutStandards(lstStd)))
    {
      cout << "nb std in the environment = " << lstStd.Size() << endl;
      for ( int indice = 1 ; indice <= lstStd.Size() ; indice ++ )
      cout << "lstStd ("<< indice << ") = " << lstStd[indice].ConvertToChar() << endl;
      // The fifth standard defined in the list is choosen (ISO_3D)
      // The 2DL standard and FTA standard must be identical
      CATUnicodeString myStd = lstStd[5];
      cout << " myStd = " << myStd.ConvertToChar() << endl;

      CATListOfCATUnicodeString lstSheetStyle;
      if (SUCCEEDED(CAT2DLayoutServices::GetListOfSheetStyles(myStd,lstSheetStyle)))
      {
        for (int indice = 1 ; indice <= lstSheetStyle.Size() ; indice ++ )
        cout << "lstSheetStyle ("<< indice << ") = " << lstSheetStyle[indice].ConvertToChar() << endl;
      }
      CATUnicodeString mySheetStyle = lstSheetStyle[2];
      cout << " mySheetStyle = " << mySheetStyle.ConvertToChar() << endl;

      // Creates the 2DLayuout Root
      if (SUCCEEDED(CAT2DLayoutServices::CreateLayout2DL(spPart,myStd, mySheetStyle,&pi2DLayout)) && pi2DLayout)
        cout << " The 2DL is correctly created" << endl;
    }
  }
...

Only one 2D Layout Root may be created in the Part document. GetLayout method defined in CAT2DLayoutServices allows to check is a 2D Layout Root already exists in the document.

[Top]

Retrieving the FTA Active View and the Capture

...
// Retrieves the FTA Active View and the Capture
// =============================================
CATBaseUnknown *piTPSViewBU = NULL;
CATBaseUnknown *piTPSCaptureBU1 = NULL;
CATBaseUnknown *piTPSCaptureBU2 = NULL;

if (piTPSSet)
{
  CATITPSView *piTPSView = NULL; 
  piTPSSet->GetActiveView(&piTPSView);
  if (piTPSView)
  {
    piTPSView->QueryInterface(IID_CATBaseUnknown,(void **)&piTPSViewBU);
    piTPSView->Release();piTPSView=NULL;
    cout << " The active TPS View is correctly retrieved" << endl;
  }
  CATITPSCaptureList *piTPSCaptList = NULL;
  piTPSSet->GetCaptures (&piTPSCaptList);
  piTPSSet->Release();piTPSSet=NULL;
  if (piTPSCaptList)
  {
    unsigned int nbCapt;
    piTPSCaptList->Count(&nbCapt);
    // there is at least one capture in the Part Document
    if (nbCapt > 0)
    {
      CATITPSCapture *piTPSCapture = NULL;
      if (SUCCEEDED(piTPSCaptList->Item(0,&piTPSCapture)) && piTPSCapture)
      {
        piTPSCapture->QueryInterface(IID_CATBaseUnknown,(void **)&piTPSCaptureBU1);
        cout << " The first capture is correctly retrieved" << endl;
        piTPSCapture->Release();piTPSCapture=NULL;
      }
      if (SUCCEEDED(piTPSCaptList->Item(1,&piTPSCapture)) && piTPSCapture)
      {
        piTPSCapture->QueryInterface(IID_CATBaseUnknown,(void **)&piTPSCaptureBU2);
        cout << " The 2nd capture is correctly retrieved" << endl;
        piTPSCapture->Release();piTPSCapture=NULL;
      }
    }
    piTPSCaptList->Release();piTPSCaptList=NULL;
  }
}
...

Creating the 2DL View From FTA components

...
// Retrieves the 2DL Sheet
// =======================
if (pi2DLayout)
{
  CATI2DLayoutSheet *pi2DLSheet = NULL;
  pi2DLayout->GetActiveSheet(&pi2DLSheet);
  if (pi2DLSheet)
  {
     cout << " The active 2DL Sheet is correctly retrieved" << endl;
     double pt1Coord[2] = {20.0,40.0};
     CATI2DLayoutView *pi2DLayoutView = NULL;
     cout << "Start the 2DL view creation from 3D FTA View" << endl;
     if (SUCCEEDED(pi2DLSheet->CreateView2DLFromFTA (piTPSViewBU, pt1Coord, &pi2DLayoutView)))
     {
       cout << "View has been correctly created" << endl;
       pi2DLayoutView->Release();pi2DLayoutView=NULL;
      }
      double pt2Coord[2] = {600.0,40.0};
      CATI2DLayoutView *pi2DLayoutView1 = NULL;
      cout << "Start the 2DL view creation from the 1st 3D FTA Capture" << endl;
      if (SUCCEEDED(pi2DLSheet->CreateView2DLFromFTA (piTPSCaptureBU1, pt2Coord, &pi2DLayoutView1)))
      {
        cout << "View has been correctly created" << endl;
        pi2DLayoutView1->Release();pi2DLayoutView1=NULL;
      }
      double pt3Coord[2] = {800.0,40.0};
      CATI2DLayoutView *pi2DLayoutView2 = NULL;
      cout << "Start the 2DL view creation from the 2nd 3D FTA Capture" << endl;
      // This view can not be created because the capture is not associated to a view annotation plane
      if (SUCCEEDED(pi2DLSheet->CreateView2DLFromFTA (piTPSCaptureBU2, pt3Coord, &pi2DLayoutView2)))
      {
        cout << "View has been correctly created" << endl;
        pi2DLayoutView2->Release();pi2DLayoutView2=NULL;
      }
      else
        cout << "The View can not be created" << endl;
     }
     pi2DLSheet->Release();pi2DLSheet=NULL;
   }
...

The 2D Layout Root aggregates one or several 2DL sheets. A 2DL Sheet aggregates one 2DL Main View one 2DL Background View. CATI2DLayout sheets contains methods to create 2DL View. The created 2DL View will be automatically aggregated by the 2DL Sheet.

[Top]

Saving the Document and Exiting

...
  // Save the result
   CATDocumentServices::SaveAs(*pDocPart, (char *)pfileNameOut);
   CATDocumentServices::Remove (*pDocPart);

  return 0;
}

This section represents the usual sequence for saving a newly created CATIA document [3].

[Top]


In Short

This use case shows the way to :

  1. Open a Part document.
  2. Retrieving the TPS Set
  3. Retrieving the Part Root from the container.
  4. Retrieving the FTA components from the Annotation Set
  5. Creating 2DLayout View from FTA components.
  6. Save the document.

[Top]


References

[1] Building and Lauching CAA V5 Samples
[2] Load an existing Document
[3] 3D Functional Tolerancing & Annotation
[Top]

History

Version: 1 [Feb 2007] Document created
[Top]

Copyright © 2007, Dassault Systèmes. All rights reserved.