Instantiating a User Feature From a VB Macro  

This topic provides you with instructions concerning the instantiation of User Features from VB Macros. Two different protocols are available to instantiate User Features. For more information about these 2 protocols, see Product Knowledge Template User's Guide: Methodology.

First Instantiation Protocol

The first protocol is dedicated to User Feature instantiation only. It is defined by a single method: AddInstance (For more information about this method, See the Automation documentation).

Note that:

  • This method is to be used when you want to perform only one instantiation of the reference.
  • As the document containing the reference is released from the session at the end of the instantiation, it is not recommended to use this method if you want to perform several instantiations of the same reference in a loop. To perform a loop, use the second protocol.
To perform the scenario described below, you will need the following files:
This is the macro. Open this script and edit the path referencing the UserFeatureStartSweep.CATPart file (Line 24).

This is the file that contains the User Feature that is going to be instantiated. Note that the inputs of the User Feature are a point and an extrude.

This is the part that will host the instantiated User Feature. It also contains 2 points (select one of them when instantiating) and an extrude, which are the inputs of the User Feature.
  1. Open the PktDestinationPart.CATPart file. Note that this file is made up of a surface and of 2 points. They are the inputs of the User Feature stored in the UserFeatureStartSweep.CATPart file.

  2. From the Tools>Macro>Macros... command, access the Macros dialog box in CATIA. Click Macro libraries....

  3. In the Macro libraries dialog box, select the Directories option from the Library type scrolling list. Click Add existing library....

  4. In the Open a directory of macros dialog box, select the directory that contains the InstantiateUDFFromVB.CATScript file that you have modified. Click OK when done. Click Close in the Macro libraries dialog box: The macros contained in this directory are displayed in the Macros dialog box.

  5. Select InstantiateUDFFromVB.CATScript (if need be) and click Run. The macro is run and the User Feature is instantiated.

 

 

Second Instantiation Protocol

The second protocol is dedicated to User Features and Power Copies instantiation. It is defined by several methods that must be called in order.

Note that it is recommended to use this protocol to perform several instantiations of the same reference in a loop.

To perform the scenario described below, you will need the following files:
This is the macro. Open this script and edit the paths referencing the UserFeatureStartSweep.CATPart file (Line 25).

This is the file that contains the User Feature that is going to be instantiated. Note that the inputs of the User Feature are a point and an extrude.

This is the part that will host the instantiated User Feature. It also contains 2 points (select one of them when instantiating) and an extrude, which are the inputs of the User Feature.
  1. Open the PktDestinationPart.CATPart file. Note that this file is made up of an Extrude and of 2 points. They can be used as inputs of the User Feature stored in the UserFeatureStartSweep.CATPart file.

  2. From the Tools>Macro>Macros... command, access the Macros dialog box in CATIA. Click Macro libraries....

  3. In the Macro libraries dialog box, select the Directories option from the Library type scrolling list. Click Add existing library....

  4. In the Open a directory of macros dialog box, select the directory that contains the PktInstantiateUserFeatureVB2.CATScript file that you have modified. Click OK when done. Click Close in the Macro libraries dialog box: The macros contained in this directory are displayed in the Macros dialog box.

  5. Select PktInstantiateUserFeatureVB2.CATScript (if need be) and click Run. The macro is run and the User Feature is instantiated.