Equipment & Systems Engineering

Electrical Harness Flattening

Extracting a harness

How to extract a harness
Use Case

Abstract

This article discusses the ElecFlatteningItf use case. This use case explains how to extract a harness


What You Will Learn With This Use Case

This use case is intended to help you make your first steps in programming with CATIA EHF Interfaces. Its main intent is to allow you to extract a harness.

[Top]

The CAAEhfFlattenManagerExtract Use Case

CAAEhfFlattenManagerExtract.m is a use case of the CAAElecFlatteningItf.edu framework that illustrates the CATIA EHF Interfaces framework capabilities.

[Top]

What Does CAAEhfFlattenManagerExtract Do?

The goal of CAAEhfFlattenManagerExtract use case is to show how to extract a harness.

                                                                                                                             

                                               [Top]

How to Launch CAAEhfFlattenManagerExtract ?

Under Windows, the path would indicate: 'WS'\intel_a\resources\graphic\ModelFlattenManagerExtract directory.

 

·         ExtractOption – this option will decide the type of algo to be used while performing Extract of the Harness.

“N”     : Extract harness using ‘ExtractWithNewFrom’ algo.

“S”     : Extract harness using ‘ExtractWithSynchro’ algo.

 

[Top]

 Where to Find the CAAEhfFlattenManagerExtract Code

The CAAEhfFlattenManagerExtract  sample is made of a single class named CAAEhfFlattenManagerExtract  located in the CAAEhfFlattenManagerExtract.m module of the CAAElecFlatteningItf.edu framework:

Windows InstallRootDirectory\CAAElecFlatteningItf.edu\CAAEhfFlattenManagerExtract.m\
Unix InstallRootDirectory/CAAElecFlatteningItf.edu/CAAEhfFlattenManagerExtract.m/

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

 

This sample deals with the following classes:

 

CATSession Class for the session base class
CATDocument Class for the document base class
CATDocumentServices Class for managing document in the session
CATIDocRoots Class for browsing root object in document
CATIProduct Interface dedicated to define product behaviour
CATIEleDocServices Interface dedicated electrical environment initialization
CATIEhfEnvironment Interfaces dedicated to retrieve the flattening parameter
CATIEhfFlatteningParameters Interfaces dedicated to read attribute on flattening parameter
CATMathPlane Class representing a mathematical plane in 3D

[Top]

Step-by-Step

We will now first comment the Electrical environment and it’s components creation by looking at the code of the Main . There are 11 logical steps in Main :

# Step
1 Check the input data
2 Create a session and open the document
3 Initializing Electrical Environment
4 Retrieve the root product of the input document
5 Open a new document
6 Initializing Electrical Environment for the new document
7 Retrieve the root product of the new document
8 Create FlatteningParameters in the new document
9 Set the FlatteningParameters in the new document
10 Extract the Harness
11 Epilogue

[Top]

Check the input data.

 

...
if ( 3 > argc ) 
{
retCode = 1; 
goto EscapeWay;
}

...

[Top]

Create a session and open the document.

We need a CATSession pointer to create the Session.

...
pSession = CATSession::Create_Session(sessionIdent);

...

We need a CATDocument pointer to opening the document.

...
CATDocumentServices::Open(argv[1], pDoc, cusInType);

...

 

Once the current session has been created, the CATProduct document can be loaded into the session . pDoc is a pointer to this document.

[Top]

Initializing Electrical Environment.

We initialize the Document by using CATIEleDocServices interface pointer and the method Initialize() on it.

....
  hr = pDoc->QueryInterface(IID_CATIEleDocServices,(void**)&pIEleDocServices );
  if ( FAILED(hr) )
  {
    retCode = 4; 
    goto EscapeWay;
  }

  hr = pIEleDocServices->Initialize();
  if ( FAILED(hr) )
  {
    retCode = 5; 
    goto EscapeWay;
  }
....

Initializing the electrical environment is mandatory to enable access to electrical object or electrical attributes.

[Top]

Retrieve the root product of the input document.

We need a CATProduct pointer to retrieving the root product. 

....
  hr = pDoc->QueryInterface(IID_CATIDocRoots, (void**)(&pIDocRootsOnDoc));
  if(FAILED(hr))
  {
    retCode = 6;
    goto EscapeWay;
  }
  
  // Get the root product which is the first element of root elements
  pListUnkRootProducts = pIDocRootsOnDoc->GiveDocRoots();
  if(NULL == pListUnkRootProducts)
  {
    retCode = 7;
    goto EscapeWay;
  }
  
  nProducts = pListUnkRootProducts->Size();
  if( 0 == nProducts)
  {
    retCode = 8;
    goto EscapeWay;
  }
  
  hUnkRootProd = (*pListUnkRootProducts)[1];
  if(NULL_var == hUnkRootProd)
  {
    retCode = 9;
    goto EscapeWay;
  }

  hr = hUnkRootProd->QueryInterface(IID_CATIProduct, (void**)(&pIRootProduct));
  if(FAILED(hr))
  {
    retCode = 10;
    goto EscapeWay;
  }
....

[Top]

Open a new document.

...
hr = CATDocumentServices::New("Product", pNewDoc);
if ( ( NULL == pNewDoc )|| ( FAILED(hr) ) )
{
retCode = 11; 
goto EscapeWay;
}

...

 

Initializing Electrical Environment.

We initialize the new Document by using CATIEleDocServices interface pointer and the method Initialize() on it.

....
  hr = pNewDoc->QueryInterface(IID_CATIEleDocServices,(void**)&pINewEleDocServices );
if ( FAILED(hr) )
{
retCode = 12; 
goto EscapeWay;
}

hr = pINewEleDocServices->Initialize();
if ( FAILED(hr) )
{
retCode = 13; 
goto EscapeWay;
}
....

Initializing the electrical environment is mandatory to enable access to electrical object or electrical attributes.

 

Retrieve the root product of the new document.

 

....
  
  hr = pNewDoc->QueryInterface(IID_CATIDocRoots, (void**)(&pINewDocRootsOnDoc));
if(FAILED(hr))
{
retCode = 14;
goto EscapeWay;
}

// Get the root product which is the first element of root elements
pNewListUnkRootProducts = pINewDocRootsOnDoc->GiveDocRoots();
if(NULL == pNewListUnkRootProducts)
{
retCode = 15;
goto EscapeWay;
}

nNewProducts = pNewListUnkRootProducts->Size();
if( 0 >= nNewProducts)
{
retCode = 16;
goto EscapeWay;
}

hUnkNewRootProd = (*pNewListUnkRootProducts)[1];
if(NULL_var == hUnkNewRootProd)
{
retCode = 17;
goto EscapeWay;
}

hr = hUnkNewRootProd->QueryInterface(IID_CATIProduct, (void**)(&pINewRootProduct));
if(FAILED(hr))
{
retCode = 18;
goto EscapeWay;
}

hr = pINewRootProduct->QueryInterface(IID_CATIEhfEnvironment,(void**)&pINewEhfEnvironment);
if ( FAILED(hr) )
{
retCode = 19;
goto EscapeWay;
}
....

 

Create the Flattening parameters from the root Product.

We need a CATIEhfEnviroment pointer on root product to create the Flattening parameters

...
  hr = pINewEhfEnvironment->CreateFlatteningParameters(pIEhfCreateFlattenPara);
if( ( FAILED(hr) ) || ( NULL == pIEhfCreateFlattenPara ) )
{
retCode = 20;
goto EscapeWay;
}

// -------------------------------------------------------------------------
// -Test if the FlatteningParameters can be successfully retrieved
// -------------------------------------------------------------------------
hr = pINewEhfEnvironment->GetFlatteningParameters(&phListFlatteningPara);
if ( ( FAILED(hr) ) || ( NULL == phListFlatteningPara ) )
{
retCode = 21;
goto EscapeWay;
}

nbFlatteningPara = phListFlatteningPara->Size();
if (0 >= nbFlatteningPara)
{
retCode = 22; 
goto EscapeWay;
}

hUnkFlatteningPara = (*phListFlatteningPara)[1];
if (NULL_var == hUnkFlatteningPara)
{
retCode = 23; 
goto EscapeWay;
}

hr = hUnkFlatteningPara->QueryInterface(IID_CATIEhfFlatteningParameters, (void **)&pIFlatteningPara);
if ( FAILED(hr) )
{
retCode = 24; 
goto EscapeWay;
}
  
  
...

 

 

Set the Flattening parameters.

 

....
  
hr = pIFlatteningPara->SetName(&setName);
if ( FAILED(hr) )
{
retCode = 25; 
goto EscapeWay;
}

hr = pIFlatteningPara->SetAlgorithmMode(&setAlgoMode);
if ( FAILED(hr) )
{
retCode = 26; 
goto EscapeWay;
}

hr = pIFlatteningPara->SetAngleMode(&setAngleMode);
if ( FAILED(hr))
{
retCode = 27; 
goto EscapeWay;
}

hr = pIFlatteningPara->SetBNSTypeScaledDuringSync(&setBNSType);
if ( FAILED(hr))
{
retCode = 28; 
goto EscapeWay;
}

hr = pIFlatteningPara->SetMoveIntermediatePtDuringSync(&setMoveIntermediatePt);
if ( FAILED(hr))
{
retCode = 29; 
goto EscapeWay;
}
....

 

 

Extract the harness.

 

....
  
hr = pINewRootProduct->QueryInterface(IID_CATIEhfFlattenManager,(void**)&pIExtract);
if ( FAILED(hr) )
{
retCode = 30;
goto EscapeWay;
}

hr = pIRootProduct->QueryInterface(IID_CATBaseUnknown, (void**)&pIUnkGBN) ;
if( FAILED(hr) )
{
retCode = 31;
goto EscapeWay; 
}

ListOfHarnessGBNs.Append(pIUnkGBN) ;

extractOption = new CATString();

if ( temp == tempN )
{
(*extractOption) = ("ExtractWithNewFrom");
}
else if ( temp == tempS)
{
(*extractOption) = ("ExtractWithSynchro");
}

hr = pIExtract->ExtractHarness( extractOption, &ListOfHarnessGBNs, &ListOfExtractedGBNs);
if (FAILED( hr))
{
retCode = 32;
goto EscapeWay;
}
....

[Top]

Epilogue

Removing document from session and closing the session.

 ...
  CATDocumentServices::Remove (*pDoc) ;

  if ( NULL != pSession )
  {
    pSession->Delete_Session(sessionIdent);
  }
 

[Top]


In Short

This use case has demonstrated the way to extract a harness. 

[Top]


[Top]

History

Version: 2 [January 2007] Document updated
[Top]

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