Machining

All Machining workbenches

Managing (User Defined) Features Referencing Axis Systems

Implementing the CATIMfgMappingForMachiningAxis interface
Use Case

Abstract

This article discusses the CAAMaiUdfForMachiningAxis use case and explains how to implement the CATIMfgMappingForMachiningAxis manufacturing interface.


What You Will Learn With This Use Case

This use case is intended to help you to use Machining Axis Systems from  User Defined Feature data, by implementing the CATIMfgMappingForMachiningAxis manufacturing interface. This involves the following:

[Top]

The CAAMaiUdfForMachiningAxis Use Case

CAAMaiUdfForMachiningAxis is a use case of the CAAManufacturingItf.edu framework in the CAAMaiUserDefFeatureMapping.m module that illustrates ManufacturingInterfaces framework capabilities.

[Top]

What Does CAAMaiUdfForMachiningAxis Do

CAAMaiUdfForMachiningAxis illustrates an implementation of CATIMfgMappingForMachiningAxis interface for the User Defined Features identified by the UdfFeature type. This implementation enables to set the Axis System of a Machining Axis System Change defined in the Machining Process. A such implementation can be done to any feature that is used as input of the Machining Process instantiation window.

[Top]

How to Use CAAMaiUdfForMachiningAxis

To use CAAMaiUdfForMachiningAxis, you will need to:

[Top]

Where to Find the CAAMaiUdfForMachiningAxis Code

The CAAMaiUdfForMachiningAxis use case is made of a class named CAAMaiUdfForMachiningAxis located in the CAAMaiUserDefFeatureMapping.m module of the CAAManufacturingItf.edu framework:

Windows InstallRootDirectory\CAADoc\CAAManufacturingItf.edu\CAAMaiUserDefFeatureMapping.m
Unix InstallRootDirectory/CAADoc/CAAManufacturingItf.edu/CAAMaiUserDefFeatureMapping.m

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

[Top]

Step-by-Step

There are three logical steps in CAAMaiUdfForMachiningAxis:

  1. Implementing the CATIMfgMappingForMachiningAxis Interface for UdfFeature Types
  2. Creating a User Defined Feature Template and Generating Instances
  3. Applying the "MachiningProcessUsingAxisSystemChange" Machining Process on a User Defined Feature Instance

We now comment each of those sections by looking at the code.

[Top]

Implementing the CATIMfgMappingForMachiningAxis Interface for UdfFeature Types

The CAAMaiUdfForMachiningAxis.cpp file uses the "CATIUdfFeatureInstance" interface to access to the User Defined Feature information - then, the right data is accessed by its right role name - and the "CATIMfgMappingRuleName" interface to access to "mapping rule name" tag which defines the using context of the feature . See below a part of the implementation:

This part of code enables to access to the "mapping rule name" defined in the operation of machining process

...
//----------------------------------------------------------------------
// Read the mapping rule name associated to the operation 
//----------------------------------------------------------------------
CATUnicodeString MappingRuleName = "";
CATIMfgMappingRuleName *piMappRuleName = NULL;
RetCode = this->QueryInterface(IID_CATIMfgMappingRuleName,(void **)&piMappRuleName);
if (SUCCEEDED(RetCode) && NULL != piMappRuleName) 
{
 MappingRuleName = piMappRuleName->GetMappingRuleName();
 piMappRuleName->Release();
 piMappRuleName = NULL;
}
...

Then, when executing Catia, the value of the MappingRuleName variable can be "AxialUdfWithAxisMap" corresponding to the Machining Process definition   

 According to this variable, the implementation is looking for the right User Feature geometry:

...
  CATUnicodeString GeometryName;
  if (MappingRuleName == "AxialUdfWithAxisMap")
  {
   GeometryName = "...";
  }
  else 
   GeometryName = "...";
  }
  CATBaseUnknown_var Geometry;
  if (SUCCEEDED(RetCode))
  {
    CATBaseUnknown *piUdf = NULL;
    RetCode = this->QueryInterface(IID_CATBaseUnknown,(void **)&piUdf);
    if (SUCCEEDED(RetCode) && NULL != piUdf) 
    {
     RetCode = CAAMaiUdfUtilities::GetUdfGeometry (piUdf, GeometryName, Geometry);
     piUdf->Release();
     piUdf = NULL;
    }
  }

...
// Generic method to get a User Feature geometry from its role name
HRESULT CAAMaiUdfUtilities::GetUdfGeometry (CATBaseUnknown * iUdf, 
        CATUnicodeString iGeometryName, CATBaseUnknown_var &oGeometry)
{
 oGeometry = NULL_var;
 HRESULT RC = E_FAIL;
 if (NULL == iUdf) return RC;

 //--------------------------------------------------------------------------
 // Get your object as a CATIUdfFeatureInstance
 //--------------------------------------------------------------------------
 CATIUdfFeatureInstance *piUdfFeatureInstance = NULL;
 RC = iUdf->QueryInterface(IID_CATIUdfFeatureInstance,(void **)&piUdfFeatureInstance);
 //--------------------------------------------------------------------------
 // Your object is a CATIUdfFeatureInstance: we can use the associated methods
 //--------------------------------------------------------------------------
 if (SUCCEEDED(RC) && NULL != piUdfFeatureInstance)
 { 
  CATUnicodeString role = "";
  CATBaseUnknown_var spGeom;
 
  //----------------------------------------------------------------------
  // Read the Inputs number: this is the geometrical inputs of your Udf
  // defined when creating the Udf template
  //----------------------------------------------------------------------
  int InputNb = 0;
  RC = piUdfFeatureInstance->GetInputsNumber(InputNb);

  int i = 1;
  while (SUCCEEDED(RC) && i <= InputNb && role != iGeometryName)
  {
   RC = piUdfFeatureInstance->GetInputRole(i, role);
   //----------------------------------------------------------------------
   // The right Input is found
   //----------------------------------------------------------------------
   if (role == iGeometryName)
   {
    RC = piUdfFeatureInstance->GetInput(i,spGeom);
   }
   i++;
  }
  //----------------------------------------------------------------------
  // The right Input was not found
  //----------------------------------------------------------------------
  if (FAILED(RC) || role != iGeometryName)
  {
   //----------------------------------------------------------------------
   // Analyse the Outputs : this is the geometrical outputs of your Udf
   // added in the Outputs List when creating the Udf template
   //----------------------------------------------------------------------
   CATListValCATBaseUnknown_var * oOutputs = NULL;
   CATIUdfFeatureUser *piUdfFeatureUser = NULL;

   RC = iUdf->QueryInterface(IID_CATIUdfFeatureUser,(void **)&piUdfFeatureUser);
   if (SUCCEEDED(RC) && NULL != piUdfFeatureUser)
   { 
    //----------------------------------------------------------------------
    // Read the Outputs list
    //----------------------------------------------------------------------
    piUdfFeatureUser->GetOutputs (oOutputs);
    int OutputNb = 0;
    if (NULL != oOutputs) OutputNb = oOutputs->Size();

    //----------------------------------------------------------------------
    // At least, one output is available
    //----------------------------------------------------------------------
    if (0 < OutputNb)
    {
     for (int i = 1; i <= OutputNb && role != iGeometryName; i++)
     {
      RC = piUdfFeatureUser->GetOutputRole (i, role);
      //----------------------------------------------------------------------
      // The right Output is found
      //----------------------------------------------------------------------
      if (role == iGeometryName)
      {
       spGeom = (*oOutputs)[i];
      }
     } 
    }
    if (NULL != oOutputs) delete oOutputs;
   }
   if (NULL != piUdfFeatureUser) piUdfFeatureUser->Release();
   piUdfFeatureUser = NULL;
  }

  oGeometry = spGeom;
 }

 if (NULL_var != oGeometry)
  RC = S_OK;
 else
  RC = E_FAIL;

 if (NULL != piUdfFeatureInstance) piUdfFeatureInstance->Release();
 piUdfFeatureInstance = NULL;

 return (RC);
}

Update the interface dictionary, that is a file named, for example in this case, CAAManufacturingItf.edu.dico, whose directory's pathname is concatenated at run time in the CATDictionaryPath environment variable, and containing the following declaration to state that the UdfFeature feature implements the CATIMfgMappingForMachiningAxis interface, and whose code is located in the libCAAMaiUserDefFeatureMapping shared library or DLL. Pay attention to remove the comment (#) in the supplied dictionary.

UdfFeature CATIMfgMappingForMachiningAxis libCAAMaiUserDefFeatureMapping

The CAAManufacturingItf.edu.dico file is located in:

Windows InstallRootDirectory\CAADoc\CAAManufacturingItf.edu\CNext\code\dictionary\
Unix InstallRootDirectory/CAADoc/CAAManufacturingItf.edu/Cnext/code/dictionary/

[Top]

Creating a User Defined Feature Template and Generating Instances

Here, you will find specific informations according to the implementation of the CATIMfgMappingForMachiningAxis interface. You can access to the User Defined Feature commands under the Shape or Part Design Workbenches, then edit the UserHoleWithAxisSystem User feature under the UserFeatures tree, and display the different tab-pages, specially Inputs and Outputs ones.

[Top]

Applying the "MachiningProcessUsingAxisSystemChange" Machining Process

To apply this machining process, update the  "CAAPrismaticMachiningItf.edu.dico" file that enables to use a Machining Axis System Change for the described user feature.

 

[Top]


In Short

This article provides an example on how to use the manufacturing interface classes, to machine User Defined Features. It shows how to implement the CATIMfgMappingForMachiningAxis interface to be authorized to assign geometry  to the geometrical macro motions when instantiating a machining process. This is an elementary step to do this.

[Top]


References

[1] Building and Launching a CAA V5 Use Case
[Top]

History

Version: 1 [January 2003] Document created
[Top]

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