CATIA VPLM

ENOVIA V5 VPM Navigator

API's to execute ENOVIA V5 VPM commands from ENOVIA V5 VPM Navigatorigator

Manipulating an ENOVIA Item Instance from within the ENOVIA V5 VPM Navigator environment
Use Case

Abstract

This article shows the way, from within the ENOVIA V5 VPM Navigator environment, to retrieve an ItemInstance from ENOVIA V5 database that has been selected in VPM Navigator window and to launch the execution of an ENOVIA V5 service involving this same ItemInstance. It also describes how the ItemInstance retrieved from the database can be loaded in CATIA. These capabilities are managed by several APIs that are presented into a global command in the coming sections.


What You Will Learn With This Use Case

This use case is intended...

[Top]

The EV5 CV5 Bind test Command Use Case

The EV5-CV5 Bind test Command is a use case of the CAACATImmENOVIAProvider.edu framework that illustrates ENOVIA V5 VPM Navigator Architecture Enhancement & CAA API highlight capabilities.

[Top]

What Does the EV5 CV5 Bind test Command Do

CAAImmEV5CV5BindTestCmd is a command which starts triggering the execution, on the ENOVIA V5 server, of a user-exit involving the ENOVIA ItemInstance related to the Instance selected from within the ENOVIA V5 VPM Navigator window. Then, the command opens in CATIA the Instances returned by the user-exit that has succeeded.

[Top]

How to Launch the EV5 CV5 Bind test Command

To launch CAAImmEV5CV5BindTestCmd, you will need to set up the build time environment, then compile CAAImmEV5CV5BindTestCmd along with its prerequisites, set up the run time environment, and then execute the use case [1] in the following way:

CAAImmEV5CV5BindTestCmd.jpg

[Top]

Where to Find the EV5 CV5 Bind test Command Code

The EV5 CV5 Bind test command is made up of a single class named CAAImmEV5CV5BindTestCmd located in the CAAImmIdAcqAgentTestCmd.m module of the CAACATImmENOVIAProvider.edu framework :

Windows InstallRootDirectory\CAACATImmENOVIAProvider.edu\CAAImmIdAcqAgentTestCmd.m\
Unix InstallRootDirectory/CAACATImmENOVIAProvider.edu/CAAImmIdAcqAgentTestCmd.m/

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

[Top]

Step-by-Step

There are 4 main steps in the CAAImmEV5CV5BindTestCmd use case:

# Step Where
1 Retrieving the selected ItemInstance using the Identification Acquisition Agent Header File and BuildGraph method
2 Retrieving the CATIPLMIdentificator of the selected Item Instance Transition action method OnSelectionDone method
3 Triggering the user-exit execution involving the ENOVIA ItemInstance on server Transition action method OnSelectionDone method
4 Opening an Iteminstance from ENOVIA V5 VPM Navigator to CATIA Transition action method OnSelectionDone method

[Top]

Retrieving the selected ItemInstance using the Identification Acquisition Agent

Refer to the Step by Step explanations given by the use case Extending EV5 VPM Navigator capabilities.

void CAAImmEV5CV5BindTestCmd::BuildGraph()
{
    ...
    _ImmIdentifierAcquisition = new CATImmIdentifierAcquisitionAgent();
    ...

[Top]

Retrieving the CATIPLMIdentificator of the selected Item Instance

The CATIPLMidentificator ensure the correspondence between a ENOVIA V5 VPM Navigator client persistent object and an ENOVIA server persistent object. The CATIPLMIdentificator of the selected ENOVIA V5 VPM Navigator ItemInstance is retrieved from the Acquisition Agent. It has to be released once it is not needed anymore.

CATBoolean CAAImmEV5CV5BindTestCmd::OnSelectionDone( void *data )
{
    ...
    CATIPLMIdentificator* opId = NULL;
    rc = _ImmIdentifierAcquisition->GetIdentificator(&opId);
    if (SUCCEEDED(rc) && opId != NULL)
    {
        ...
        opId->Release(); opId = NULL;
        ...

[Top]

Triggering the user-exit execution involving the ENOVIA ItemInstance on server

Giving the CATIPLMIdentificator of the selected ENOVIA V5 VPM Navigator ItemInstance in input of the API CATPDMCSServices::RunObjectService, it is then possible to trigger the execution of a server treatment involving the ENOVIA ItemInstance corresponding to our selected ENOVIA V5 VPM Navigator ItemInstance. The triggered server treatment is given by the implementation of the ENOVIObjectServiceCode::RunObjectServiceCode user-exit. Refer to the use case Using the ENOVIObjectServiceCode user-exit to get the ItemInstances that share the same PartVersion in a ProductRootClass (See reference [3]) to see how it have to be implemented.

First thing to do is to compute correctly the arguments given to the API...

1. Compute a list that contains all CATIPLMIdentificator of the object we want to interact with. Here the CATIPLMidentificator of the selected ItemInstance is the only one added to the list.

  ...
CATIPLMIdentificator_var spPLMIdentifs = opId;
opId->Release(); opId = NULL;

if (spPLMIdentifs != NULL_var)
{
    ...
    CATListOfCATIPLMIdentificator lstPLMIdent;
    lstPLMIdent.Append(spPLMIdentifs);
    ...

2. Give in a CATString the service name to be invoke on the server. First, it has to be composed of the LateType of the implementation that will be executed on the EV5 server calling the ENOVIObjectServiceCode::RunObjectServiceCode user-exit. Then, it has to be prefixed with the PDM environment name, for ENOVIA V5, it is "ENOVIA5". Here is mentioned the latetype of the user-exit implementation exposed in use case Using the ENOVIObjectServiceCode user-exit to get the ItemInstances that share the same PartVersion in a ProductRootClass (See reference [3]).

...
CATString iServName = "ENOVIA5_GetII";
...

3. It is possible to give in input additional informations computed in a char*. Here we choose to add the V_Id of the VPMProductRootClass opened in the ENOVIA V5 VPM Navigator window.

...
CATListOfCATUnicodeString   lstIdsNames;
CATListOfCATUnicodeString   lstIdsValues;
CATUnicodeString    stRootType;

rc = CATImmCAAServices::GetCurrentRootIdentifiers(lstIdsNames,lstIdsValues,stRootType);
...
const char* ipString = lstIdsValues[1];
...

4. Call the API once the declaration of the output arguments is done.

...
char* opString = NULL;
CATListOfCATIPLMIdentificator olstPLMIdent;

HRESULT rc = CATPDMCSServices::RunObjectService(iServName, lstPLMIdent, ipString, olstPLMIdent, &opString);
...

[Top]

Opening an Iteminstance from ENOVIA V5 VPM Navigator to CATIA

In this use case, the CATPDMCSServices::RunObjectService API returns a list of CATIPLMIdentificators that correspond to the ENOVIA ItemInstances retrieved on the server by the user-exit command. Below is listed in 5 steps the way to load these ItemInstances in CATIA.

1. Get the list of the currently selected object in ENOVIA V5 VPM Navigator and Empty it.

  ...
// Retrieve current window
CATFrmEditor * pEditor = GetEditor(); 

if (pEditor != NULL)
{
  // Current selection, only one per window !
  CATCSO * pCSO = pEditor->GetCSO(); 

  if (pCSO != NULL)
  {
    pCSO->Empty();
  ...

2. Build an empy list of object. It will later contain the ItemInstances to be loaded.

  ...
CATSO * pSO = new CATSO();  
  ...

3. Get the ENOVIA V5 VPM Navigator ItemInstances from the list of CATIPLMIdentificators returned by the the API CATPDMCSServices::RunObjectService.

  ...
for (int i=1; i<=countIDs; i++)
{
  CATIPLMIdentificator * piPLMID = olstPLMIdent[i];
  if (piPLMID != NULL)
  {
    // Bind the Nav Object from its PLMIDs
    CATBaseUnknown * pBase = NULL;
    tempRC = CATPDMNavServices::BindEnoviaIdToNav(piPLMID, &pBase);  
    ...

4. Add the ENOVIA V5 VPM Navigator ItemInstances to the list of object and then insert the list in the CSO previously recovered.

...
for (int i=1; i<=countIDs; i++)
{
  ...
  if (SUCCEEDED(tempRC) && pBase)
  {
    // Add Nav Object in SO
    CATPathElement * pathElem = new CATPathElement(pBase);
    if (pathElem) 
    {
      tempRC = pSO->AddElement(pathElem);
      ...
    }
  }
}

// Add SO in CSO
pCSO->AddSO(pSO, CATCSO::Replace);
    ...

5. Open in CATIA the ENOVIA V5 VPM Navigator ItemInstances contained in the CSO.

...
CATCommand * pConnectCmd = NULL;
tempRC = ::CATAfrStartCommand("Open", pConnectCmd); 
...

[Top]


In Short

This use-case shows how the new API's can be used to implement business behaviors on ENOVIA V5 server that can be executed from ENOVIA V5 VPM Navigator client. It is imported to emphasize that these services are handled as short transactions, in the sense that persistent objects which are created/modified/deleted are saved/committed into the database, and hence, should be in any case launched within long transactions (Save In ENOVIA V5).

[Top]


References

[1] Building and Launching a CAA V5 Use Case
[2] Extending EV5 VPM Navigator capabilities
[3] Server Use case Implementing ENOVIObjectServiceCode in CAAVPMInterfacesDoc.edu/CAAVpiUseCases.doc/src/CAAVpmPsEnovGetII.htm
[Top]

History

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

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