MechanicalModeler

An Overview of Power Copies and User Features

Essential characteristics and mechanisms of Power Copies and User Features
Technical Article

Abstract

This article details the essential characteristics and mechanisms of Power Copies and User Features. A reading of the technical articles about the Part document [1][2][3] is recommended to take full benefits from this article.


Introduction

To design your geometrical models, in most cases, Part and GSD features are sufficient. But if these features cannot answer your needs, you must create others. One solution is to redefine an existing geometrical feature, but then you have to re-implement complex interfaces like CATIBuild, CATIReplace... So, an intermediate solution is to create User Features or Power Copies. These elements are geometrical features that are composed of other features. With this solution you can create new geometrical features with a minimal implementation cost.

Power Copy and User Feature capabilities are used to group features which are often repeated and never modified and to create applicative features. With the User Feature, the internal features are hidden. This is useful for designers to hide complexity and/or for customers to maintain confidentiality.

This document begins by defining the terms used to describe a User Feature or a Power Copy.

In the next section, How to Use the Interfaces, the MechanicalCommands framework's interfaces are described for each process: how to create a User Feature (or a Power Copy), how to instantiate a User Feature (or a Power Copy) and how to edit a User Feature instance (process not available for Power Copy).

The Technologies Used section gives an internal view where the main difference between a Power Copy and a User Feature becomes explicit: on the one hand, the Copy/Paste mechanism is used and on the other hand, the Reference/Instance mechanism is used. Before reading this section, you should already be familiar with the concepts explained in the Feature Modeler Overview [4], a technical article of the PPR Hub.

The Power Copy or the User Feature to be instantiated is saved in a Part document, and is, in most cases, also referenced in a catalog. The catalog integration is explained in the Catalog Integration section.

This document is useful for the CAA developer, but also for the end user who may need to use interactive commands to create or instantiate a Power Copy or a User Feature. This article also gives a number of Useful Tips to enhance the usage of these features.

[Top]

Definitions

What is a "Component"?

A component is a feature that is used to form the User Feature (or the Power Copy) reference. This feature can be:

A User Feature (or a Power Copy) can be made up of any number of components. These components must be selected from the same Part document as the one containing the User Feature or the Power Copy reference.

What are the "KnowledgeTemplates" Set and the "PowerCopy" Set?

User Features and Power Copies that are used to be instantiated are called User Feature references and Power Copy references respectively.

The "KnowledgeTemplates" and "PowerCopy" sets aggregate User Feature references and Power Copy references respectively. These two sets are non mechanical features aggregated in the MechanicalPart feature

What is an "Input"?

An input is a feature that is not directly selected to form the User Feature or the Power Copy, but this feature is pointed at through an external link by a component that is part of the UserFeature or Power Copy. Inputs must be valuated at the time of instantiation.

For example, let's look at the inputs of the User Feature reference created in the use case "Creating a User Feature Reference" [5]

Fig.1:Input's Description

This feature has only one component, a Geometrical Set (the green box). It contains a loft, Loft.2, defined by two circles, Circle.3 and Circle.4. These circles are placed on two planes, Plane.1 and Plane.2. These two planes are perpendicular to a line, Line.2, at each of its end points. These end points, Point.1 and Point.2, are not inside the group of features defining the components. So these two points are the "inputs".

What is a "Published Parameter"?

The feature can have knowledge parameters which can be published or not. Refer to the CATIParmPublisher interface of the KnowledgeInterfaces Framework. The parameters of the User Feature (or the Power Copy) are made up of the set of all knowledge parameters of its components. Among these parameters, you can select (publish) those whose values are likely to be modified during the instantiation step.

Let's take the same example that was shown in the What is an "Input"? section:

Fig.2:Parameter's Description

The User Feature reference contains only one component, a Geometrical Set (the green box) and it contains several features: Line.2, Circle.3, Circle.4, Plane.1... In Fig.2 we have only presented the parameters for Line.2 (L. from the start point, L. from the end point), Circle.3 (Radius) and Circle.4 (Radius). These two last radius parameters are outside the green box because they have been "published".

The published parameters appear in the specification tree only for the User Feature; they can be found in the UserFeatures set and under each instance.

What is a "Role"?

For each input and published parameter you can give an "external" name. This external name is the "role". The default role of an input is the name of the feature and the default role of a parameter is its default name. For example, in the case of a parameter, it is easier to understand "The Radius of the Top Circle" rather than "Radius".

For the input, the role has an extra significance: the role is useful to give more meaning to the end user, but it can also be used to automatically look for inputs. To valuate the inputs at each instantiation, you can specifically set a feature for each input, but you can also use the "Use Identical Name" function. This means that the process tries to valuate an input by looking for a feature whose name returned through CATIAlias is identical to the role name of the input.

What is a "Type"?

The type is a User Feature notion, there is no type for a Power Copy. The type is a string whose recommended naming rule is the following: the first part is the company prefix and the second part is dependent of the current user feature. There is two advantages to associate with a User Feature reference a type:

You can create a type by code using the CATIUdfFeatureUser interface or during the interactive creation. In the two cases, once the type is created, if instances already exist, don't change the type.

How to Use the Interfaces

Power Copy or User Feature Creation

The Power Copy references and the User Feature references are created nearly by the same process. Refer to the use case "Creating a User Feature Reference" [5] for a concrete example of creating a User Feature.

The process is the following:

  1. Retrieve a CATIUdfFactory interface pointer to the Part container
  2. The Part container, CATPrtContainer, which is the root container of the Part document, implements CATIUdfFactory. This interface enables the creation of a Power Copy reference or a User Feature reference.

      ...
      CATInit *piInitOnPartDocument = NULL ;
      rc = pPartDocument->QueryInterface(IID_CATInit,(void **) &piInitOnPartDocument );
      ...
      CATIPrtContainer *piPartContainer = NULL ;
      piPartContainer = (CATIPrtContainer *)piInitOnPartDocument->GetRootContainer("CATIPrtContainer") ;
      ...
      CATIUdfFactory *piUdfFactoryOnPartContainer = NULL ;
      piPartContainer->QueryInterface(IID_CATIUdfFactory,(void **) &piUdfFactoryOnPartContainer);
     

    pPartDocument is the CATDocument pointer.

  3. Create a new feature reference from the factory on the Part container
  4. Creating a User Feature:

      ...
      CATUnicodeString UserFeatureReferenceName= "NameOfTheUserFeatureReference" 
      CATIUdfFeature_var spiUdfFeature = piUdfFactoryOnPartContainer ->CreateUserFeature(UserFeatureReferenceName);
      ...
      

    The CreateUserFeature method returns a new User Feature whose name is the unique argument of the method. This name is used when a User Feature reference is instantiated. If you do not give an explicit name to the instance, its default name is the User Feature reference name to which an index is appended.

    Creating a Power Copy:

      ...
      CATIUdfFeature_var spiUdfFeature = piUdfFactoryOnPartContainer ->CreatePowerCopy();
      CATIAlias * piAliasOnPowerCopy = NULL ;
      spiUdfFeature->QueryInterface(IID_CATIAlias ,(void **) &piAliasOnPowerCopy);
      ...
      CATUnicodeString PowerCopyReferenceName= "NameOfThePowerCopyReference" 
      piAliasOnPowerCopy->SetAlias(PowerCopyReferenceName);
      ...
      

    For the Power Copy, the method of the factory is CreatePowerCopy. To set a specific name, the CATIAlias interface must be used.

    It is recommended to create only one User Feature or only one Power Copy by Part document. Refer to Useful Tips for an more detailed explanation.

  5. Retrieve the component (s)
  6. You need to have one or several features to form your User Feature or Power Copy. See the Components section for more details. All these features are grouped together in a list.

      ...
      CATListValCATBaseUnknown_var pComponentsList= new CATLISTV(CATBaseUnknown_var);
      pComponentsList->Append(spOnMyFirstFeature) ;
      pComponentsList->Append(spOnMySecondFeature) ;
      ...
      

    Note that spOnMyFirstFeature and spOnMySecondFeature are smart pointer on features in the current Part document.

  7. Check the component (s)
  8. Before valuating the User Feature or the Power Copy with the components, it is mandatory to check the validity of these component (s).

      ...
      rc = spiUdfFeature->VerifComponents(pComponentsList);
      ...
      

    The VerifComponents method mainly verifies that each component implements the CATIReplace interface. If the result of VerifComponents is S_OK, the verification is successful.

    You can perform the check step after the valuation of the User Feature or the Power Copy (next step), but in this case, if the check fails you must delete the new feature and create a new one. If you perform the check after the valuation, the unique argument of VerifComponents is NULL.

  9. Valuate the new feature reference with the components
  10.   ...
      rc = spiUdfFeature->SetComponents(pComponentsList);
      ...
      

    The main role of this method is to determine the inputs from the group of components.

  11. Rename the inputs
  12. This step is strongly recommended. It allows the end user to have a better understanding of their meaning.

      ...
      CATUnicodeString TheRoleOfThexInput ="...." ;
      rc = spiUdfFeature->SetInputRole(x,TheRoleOfThexInput);
      ...
      

    x is the position of the input in the list returned by the GetListInputs method. The value of x is ranged between 1 and the size of this list.

  13. Publish the useful parameters
  14. In the component (s), we have a group of parameters and among them you can select the useful parameters. Refer to the "Published Parameters" section for a technical explanation.

      ...
      CATBaseUnknown_var spUknOnParameter = ... ;
      rc = spiUdfFeature->AddParameter(spUknOnParameter);
      ...
      

    The AddParameter method publishes the parameter passed as an argument (the RemoveParameter method does the contrary). The GetInternalParameters method returns all the parameters of the User Feature or the Power Copy. The GetParameters method returns only the published parameters.

  15. Rename the published parameters
  16. As for inputs, it is strongly recommended to rename the published parameters.

      ...
      CATUnicodeString TheRoleOfTheParameter ="...." ;
      rc = spiUdfFeature->SetParameterRole(spUknOnParameter,TheRoleOfTheParameter);
      ...
      

    Use the SetParameterRole method to rename a published parameter.

  17. Put the new feature in the appropriate set
  18. For the User Feature:

      ...
      CATIUdfFeatureSet_var spiIdfFeatureSet = piUdfFactoryOnPartContainer->GetFeatureSet(1);
      ...
      spiIdfFeatureSet->Append(spiUdfFeature);
      ...
      

    The new User Feature reference is aggregated in the UserFeatures set. The set is indicated by the index 1.

    For the Power Copy:

      ...
      CATIUdfFeatureSet_var spiIdfFeatureSet = piUdfFactoryOnPartContainer->GetFeatureSet(0);
      ...
      spiIdfFeatureSet->Append(spiUdfFeature);
      ...
      

    The new Power Copy reference is aggregated in the PowerCopy set. The set is indicated by the index 0.

Caution: as long as the User Feature or the Power Copy is not yet instantiated, you can safely change an input's role, publish a parameter or change a parameter's role; afterwards, this is not recommended.

Power Copy or User Feature Instantiation

The Power Copy references and the User Feature references are instantiated by nearly the same process. Refer to the use case "Instantiating a User Feature Reference" [6] for a concrete example of instantiating a User Feature.

The User Feature or the Power Copy reference to be instantiated is found in a Part document (*) called the reference Part Document. The instance will be created in a destination Part document. These two documents can be the same but it is not recommended. Refer to Useful Tips for an more detailed explanation.

(*)The instantiation from a Catalog is not traited.

The instantiation process is the following:

  1. Retrieve the feature to be instantiated
  2. For the User Feature list:

      ...
      CATListValCATISpecObject_var *pFeatureList = NULL ;
      pFeatureList = piUdfFactoryOnPartContainer ->GetUserFeatureList();
      ...
      

    For the Power Copy list:

      ...
      CATListValCATISpecObject_var *pFeatureList = NULL ;
      pFeatureList = piUdfFactoryOnPartContainer ->GetPowerCopyList();
      ...

    piUdfFactoryOnPartContainer is the CATIUdfFactory pointer on the root container of the reference Part Document, and pFeatureList is a pointer on a CATISpecObject_var list.

    The list contains the User Feature or the Power Copy references that can be instantiated. These feature references implement the CATIUdfInstantiate interface to enable instantiations.

      ...
      CATISpecObject_var spFeatureReference =  (*pFeatureList)[i] ;   
      CATIUdfInstantiate *piUdfInstantiateOnFeatRef = NULL ;
      rc = spFeatureReference->QueryInterface(IID_CATIUdfInstantiate,(void **) &piUdfInstantiateOnFeatRef);
      ...
     

    The value of i is ranged between 1 and the maximum number of references. This number is given by the size of the pFeatureList list.

  3. Set the destination location
  4. An instance of a User Feature will always be located in a Geometrical Features Set of a MechanicalPart. The nature of the feature reference determines the choice between a Body, a Solid Body, a Geometrical Set or an Ordered Geometrical Set.

    For Power Copy instantiation, the location of duplicated features depends on their own nature.

    There are two different ways to define the destination location of instantiation:

    First retrieve a pointer on the MechanicalPart destination:

      ...
      CATISpecObject_var spSpecObjectOnMechanicalPart = piPartContainer->GetPart();
      CATBaseUnknown_var spBuknOnMechanicalPart = spSpecObjectOnMechanicalPart ;
      CATBaseUnknown * pMechanicalPart = (CATBaseUnknown *)spBuknOnMechanicalPart ;
      ... 

    piPartContainer is the root container of the destination Part document. Refer to the first in the section Power Copy or User Feature Creation to see how to retrieve such a pointer.

    Next, set the path of this MechanicalPart to the Feature reference:

      ...
      CATPathElement PathOfTheMechanicalPart (pMechanicalPart);
      CATBaseUnknown * pUIActiveObject = NULL ;
      CATBaseUnknown_var spMechanicalPartDestination;
      rc = piUdfInstantiateOnFeatRef->SetDestinationPath(&PathOfTheMechanicalPart,
                               pUIActiveObject,spMechanicalPartDestination);
      ... 

    PathOfTheMechanicalPart is a CATPathElement created from a CATBaseUnknown pointer on the MechanicalPart, and pUIActiveObject and spMechanicalPartDestination are NULL and NULL_var, respectively, as returned values of the SetDestinationPath method.

    Set the path of the choosen destination feature and the relative position to the Template reference:

      ...
      CATPathElement PathOfTheDestinationFeature (pDestinationFeature);
      CATUnicodeString relativePosition = "After";
      rc = piUdfInstantiateOnFeatRef->SetDestinationPathOfInsertion(&PathOfTheDestinationFeature,
                               relativePosition);
      ... 

    PathOfTheDestinationFeature is a CATPathElement created from a CATBaseUnknown pointer on the geometric feature designated as the destination (pDestinationFeature), and relativePosition is a CATUnicodeString whose value can be "Inside" or "After".

    If you want to use the current feature as the default destination, you can retrieve it using the GetDefaultDestinationOfInsertion method.

      ...
      CATPathElement PathOfTheMechanicalPart (pMechanicalPart);
      CATPathElement* PathOfTheDestinationFeature = NULL;
      CATUnicodeString relativePosition;
      rc = piUdfInstantiateOnFeatRef->GetDefaultDestinationOfInsertion(&PathOfTheMechanicalPart,
                               PathOfTheDestinationFeature,relativePosition);
      ... 

    PathOfTheMechanicalPart is a CATPathElement created from a CATBaseUnknown pointer on the MechanicalPart.

     

  5. Valuate all the inputs
  6. All the features that valuate the inputs are features from the same MechanicalPart as the MechanicalPart in which the Power Copy or the User Feature is to be instantiated.

    First solution: use the SetNewInput method for each input.

      ...
      CATPathElement * pPathOnInput (pFeatureInput);
      rc = piUdfInstantiateOnFeatRef->SetNewInput(x,pPathOnInput);
      ... 

    x is the position of the input in the list returned by the GetOldInputs method and is ranged between 1 and the number of inputs. This number is given by the size of the list. pPathOnInput is the CATPathElement of the feature pointed to by pFeatureInput

    Second solution: Use the UseIdenticalName method

      ...
      rc = piUdfInstantiateOnFeatRef->UseIdenticalName(spRoot);
      ... 

    spRoot, in most cases, is a smart pointer on the MechanicalPart of the destination Part document, spBuknOnMechanicalPart

    The role of this method is to automatically look for a feature for each input. An input is valuated when there exists in the root a feature whose CATIAlias name is identical to the role of the input.

    Example: The User Feature (or Power Copy) has 4 inputs whose first two have a specific role: MyRole1 and MyRole2 respectively.

    Input's Name Input's Role Default valuation
    Point.1 MyRole1 Point.1
    Point.2 MyRole2 Point.2
    Line.1 Line.1 Line.1
    Line.2 Line.2 Line.2

    The destination Part document, contains the following features: a point called MyRole1, Point.1,Line.1 ....

    The UseIdenticalName method finds only two features: MyRole1 and Line.1 associated to Point.1 and Line.1 respectively. Point.2 and Line.2 are not valuated because any feature in the root has MyRole2 or Line.2 as CATIAlias name.

    Input's Name Input's Role Valuation after UseIdenticalName
    Point.1 MyRole1 MyRole1
    Point.2 MyRole2 Point.2
    Line.1 Line.1 Line.1
    Line.2 Line.2 Line.2

    After the UseIdenticalName method it is important to check that all inputs are valuated.

      ...
      CATBoolean Uncomplete = FALSE ;  
      int i = 1 ; 
      int NbInput = .... ; // the size of the list returned by GetOldInputs
      while ( (FALSE == Uncomplete ) && ( i <= NbInput) )
      {
         CATBaseUnknown_var spOnInput = piUdfInstantiateOnFeatRef->GetNewInput(i);
         if ( NULL_var == spOnInput )
         {
            Uncomplete = TRUE ; // the current input is not valuated
         }else i ++ ;
      } 
      ...

    If one or several inputs are not valuated by the UseIdenticalName method, you can use the SetNewInput method to perform the valuation.

    Caution: the UseIdenticalName method returns S_OK even if an input is not valuated.

  7. Valuate the published parameters
  8. This step is not mandatory, you can keep the default values which are those values on the User Feature or the Power Copy reference. Retrieve the list of all published parameters using the GetParameters method. This method also returns the list of their role. These two lists have the same length.

      ...
      CATListValCATBaseUnknown_var * pParameterList = NULL;
      CATListOfCATUnicodeString * pParameterRoleList = NULL ;
      rc = piUdfInstantiateOnFeatRef->GetParameters(pParameterList,pParameterRoleList);
      if ( NULL != pParameterList )
      {
         int NbPublishedParameters = pParameterList->Size();
         for ( int i= 1 ; i <= NbPublishedParameters ; i++ )
         {
             CATICkeParm_var spCkeParmOnParameter = (*pParameterList)[i];
             if ( NULL_var != spCkeParmOnParameter )
             {
                 .....
             }
         }
      }
      ... 

    You can modify the parameters using the CATICkeParm interface of the KnowledgeInterfaces framework.

  9. Instantiate
  10.   ...
      rc = piUdfInstantiateOnFeatRef->Instantiate(NULL_var);
      ... 

    The argument of this method must be NULL_var.

    Caution: After this call, it is not possible to change an input or a parameter. In the case of a User Feature, you could change it by using the CATIUdfFeatureInstance interface, but always after the end of the current instantiation.

  11. Change the name of the new instantiated feature (for User Features only)
  12. You can change the name of a new instantiation by using the SetDisplayName method.

      ...
      CATUnicodeString   NewNameOfTheInstance = "A different name " ;
      rc = piUdfInstantiateOnFeatRef->SetDisplayName(NewNameOfTheInstance);
      ... 

    The default name of the User Feature instance is the name of its reference, returned by the GetDisplayName method with an index appended.

  13. End the instantiation process
  14.   ...
      rc = piUdfInstantiateOnFeatRef->EndInstantiate();
      ... 

    After this call the instantiation is closed, you can make a new instantiation by returning to the second step Set the MechanicalPart destination location.

User Feature Edition

The User Feature is editable thanks to the CATIUdfFeatureInstance interface. Refer to the use case "Editing a User Feature" [7] for two examples of the edition process.

[Top]

Power Copy and User Feature Icon

Interactively, you can choose an icon for the newly created reference thanks to the following tab page of the Userfeature Definition dialog box [Fig.11] or the PowerCopy Definition dialog box.

Fig.11: Interactively, Choosing an Icon

When you create by CAA a new reference, see the Power Copy and User Feature Creation section, you can also do that.

  ...
  CATUnicodeString IconName = "I_CombinedCurve" ;
  CATIIcon_var spIconOnRef =spiUdfFeature ;
  spiUdfFeature ->SetIconName(IconName);
  ... 

where  spiUdfFeature is a CATIUdfFeature interface pointer created by the CreateUserFeature or the CreatePowerCopy methods of the CATIUdfFactory interface.  IconName is the name of an icon without the file extension. Such as usual, the icons are bit map files, suffixed by bmp. They should have a size of 24 by 24 pixels. The icon files are contained in the CNext\resources\graphic\icons\normal directory of a framework.

[Top]

Technologies Used

Following is a description of the mechanisms used for the creation and instantiation of User Features and Power Copies.

Fig.3:Mechanism's Description

In the case of a Power Copy:

This is the Copy/Paste mechanism.

In the case of a User Feature:

This is the Instance/Reference mechanism.

An example of the Copy/Paste Mechanism

As you have seen, the Copy/Paste mechanism is used for Power Copy instantiation. Here is an example showing the created object, the linked object during creation and the instantiation.

Creation:

In a reference Part document we have a line, Line.2. The Power Copy reference is created by selecting this line. We publish the "Distance to P2" parameter of the line.

Fig.4: Internal View of a Power Copy Reference

Notice that:

Instantiation:

In a destination Part document, we have four points : Point.1, Point.2, Point.3 and Point.4. We choose Point.3 and Point.4 as inputs for the Power Copy. After the instantiation, in the destination document we have:

Fig.5: Internal View of an Instance of a Power Copy Reference

Notice that:

An example of the Instance/Reference Mechanism

As you have seen, the Instance/Reference mechanism is used for User Feature instantiation. Here is an example of the created objects, the linked objects during creation and the instantiation.

Creation

In a reference Part document we have a line, Line.2. The user feature reference is created by selecting this line. We publish the "Distance to P2" parameter of the line.

Fig.6: Internal View of a User Feature Reference

Notice that:

Instantiation:

In a destination Part document, we have four points : Point.1, Point.2, Point.3 and Point.4. We choose Point.3 and Point.4 as inputs for the User Feature. After the instantiation, in the destination document we have:

Fig.7: Internal View of an Instance of a User Feature Reference

Notice that:

The Replace Mechanism

See the Use case "Performing a Replace on a Mechanical Feature" [8] for a detailed example of the Replace mechanism.

[Top]

Catalog Integration

Fig.8: Links Between Features and Catalog

There are no links between the feature and the description in the catalog.

[Top]

Useful Tips

PowerCopy and User Feature Creation

PowerCopy and User Feature Instantiation

[Top]


In Short

Use the User Feature or Power Copy to create new feature at a minimal cost. They are also useful to group features which are often repeated and never modified and to create applicative features.

The Copy/Paste mechanism is used to instantiate a Power Copy with inputs and parameters. After instantiation of a Power Copy, the resulting features are all independant features and are editable.

The Instance/Reference mechanism is used to instantiate a User Feature. It is more powerful than the Copy/Paste mechanism. The User Feature is a black box whose arguments are the inputs and the published parameters. After instantiation of a User Feature, the resulting feature is editable.

Top]


References

[1] Structure of the Part Document
[2] Contents of the Specification Container - Geometrical Features Sets
[3] Contents of the Specification Container - Geometrical Features
[4] Feature Modeler Overview
[5] Creating a User Feature Reference
[6] Instantiating a User Feature Reference
[7] Editing a User Feature
[8] Performing a Replace on a Mechanical Feature
[9] CATIEdit for a User Feature
[Top]

History

Version: 1 [Jan 2000] Document created
Version: 2 [Feb 2005] Document Updated to modify the default icon
Version: 3 [Apr 2006] Document Updated : you can choosen the target instantiation / new dialog box for user feature type
[Top]

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