Mechanical Modeler |
Editing a User FeatureUsing CATIUdfFeatureInstance |
|
Use Case |
AbstractThis article shows how to edit a User Feature. |
The goal of this article is to show how to edit a User Feature.
On a User Feature you can modify:
Before reading this article, see the technical article about Power Copy and User Feature [1].
[Top]
CAAMcaUdfEdition is a use case of the CAAMechanicalCommands.edu framework that illustrates MechanicalCommands framework capabilities.
[Top]
In the CAAUdfModelWithInstances
Part document we have two
instances of the User Feature reference CAAUserFeatureSample
. This
User Feature reference has been created by the use case "Creating a User
Feature Reference" [2], and the two instances
have been created thanks to the use case "Instantiating a User Feature
Reference" [3].
On the first instance CAAUserFeatureSample.1
we will change the
inputs. Its inputs are Point.3
and Point.1
and will
become Point.1
and Point.2
respectively.
On the second instance "The Loft With Point2 and Point3",
we will change the value of the first published parameter "Radius of
the circle placed at the first input"
. This value is 10mm and will
become 50mm.
Image after modifications:
The interactive scenario:
Launch CATIA, When the application is ready :
[Top]
To launch CAAMcaUdfEdition , you will need to set up the build time environment, then compile CAAMcaUdfEdition along with its prerequisites, set up the run time environment, and then execute the use case [4]. To launch the use case execute the command:
mkrun -c CAAMcaUdfEdition InputPath [OutputPath]
CAAUdfModelWithInstances.CATPart
included in the directory CAAMechanicalCommands.edu/InputData
InstallRootDirectory/CAAMechanicalCommands.edu/InputData
InstallRootDirectory\CAAMechanicalCommands.edu\InputData
CAAUdfModelWithInstancesModified.CATPart
.
If this path is empty, the output file is created in the current directory.[Top]
The CAAMcaUdfEdition use case is made of one main program located in the CAAMcaUdfEdition.m module of the CAAMechanicalCommands.edu framework:
Windows | InstallRootDirectory\ CAAMechanicalCommands.edu\ CAAMcaUdfEdition.m\ |
Unix | InstallRootDirectory/ CAAMechanicalCommands.edu/ CAAMcaUdfEdition.m/ |
where InstallRootDirectory
is the directory where the CAA CD-ROM
is installed.
In the CAAMcaUtilities.m module of the same framework, there is a global
function to retrieve data from the input Part, named CAAMcaGetGeometry. It is
located in CAAMcaGetGeometry.cpp
. The header of this function, CAAMcaGetGeometry.h,
is set in the PrivateInterfaces directory of the framework.
[Top]
This section does not follow exactly the use case code. We have chosen to show, from the use case, the main steps of one edition.
[Top
CAAMcaUdfEdition begins creating a session, and opening the
CAAUdfModelWithInstances Part document. Next it retrieves the root container of
this Part.
This is the usual sequence for loading a Part document [5].
Thanks to the GetPart
method on the root container we retrieves
the Mechanical Part. This part is handled by the smart pointer spSpecObjectCAAUdfModelPart
.
This piece of code is almost the same for the first and the second User
Feature to modify. For the first User Feature, the second argument of CAAMcaGetGeometry
is CAAUserFeatureSample.1
, and for the second feature it is The
Loft With Point2 and Point3
.
CATBaseUnknown * pOnInstance = NULL ; CATIUdfFeatureInstance * pIUdfFeatInstance = NULL ; rc = ::CAAMcaGetGeometry(spSpecObjectCAAUdfModelPart,"CAAUserFeatureSample.1",&pOnInstance); if ( FAILED(rc) ) return 1 ; rc = pOnInstance->QueryInterface(IID_CATIUdfFeatureInstance,(void **) &pIUdfFeatInstance); if ( FAILED(rc) ) return 1; ... |
The goal of this section is to find in the CAAUdfModelWithInstances
Part
document the feature CAAUserFeatureSample.1
(i.e The
Loft With Point2 and Point3
).
CAAMcaGetGeometry
is a function which returns a pointer, pOnInstance
,
on the object whose name is the second argument. This object is a User Feature
which implements CATIUdfFeatureInstance. pIUdfFeatInstance
is the pointer to this interface.
[Top]
rc = pIUdfFeatInstance->Init(); if ( FAILED(rc) ) return 1; ... |
This step is mandatory for any modification on the instance. Only after
calling the Init
method you can modify the instance.
[Top]
This step is done on the first User Feature instance CAAUserFeatureSample.1
.
This User Feature has two inputs.
Modification of the first input:
CATBaseUnknown * pInput = NULL ; rc = ::CAAMcaGetGeometry(spSpecObjectCAAUdfModelPart,"Point.1",&pInput); if ( FAILED(rc) ) return 1 ; CATPathElement * pPathFirstInput = new CATPathElement(pInput); rc = pIUdfFeatInstance->SetNewInput(1,pPathFirstInput); if ( FAILED(rc) ) return 1 ; ... |
The feature associated with the first input is Point.3
. (See the
use case Instantiating a User Feature Reference [3]).
We change it to the Point.1 feature.
Point.1
is found in the CAAUdfModelWithInstances
Part document thanks to the CAAMcaGetGeometry
function. This
function returns a pointer to this feature, pInput
.
We create a path, pPathFirstInput,
with the pointer pInput
.
At last, we use the SetNewInput
method on the pIUdfFeatInstance
to modify the first input of the User Feature. The first argument of this method
is the number of the input, here it is 1 and the second argument is the
complete path of the new input, pPathFirstInput.
Note: pIUdfFeatInstance
is the CATIUdfFeatureInstance
interface pointer of the first instance defined in the Retrieving
the User Feature step.
For the second input:
rc = ::CAAMcaGetGeometry(spSpecObjectCAAUdfModelPart,"Point.2",&pInput); if ( FAILED(rc) ) return 1 ; CATPathElement * pPathSecondInput = new CATPathElement(pInput); rc = pIUdfFeatInstance->SetNewInput(2,pPathSecondInput); if ( FAILED(rc) ) return 1 ; ... |
The feature associated with the second input is Point.1
. (See
the use case Instantiating a User Feature Reference [3]).
We change it by the Point.2 feature.
Point.2
is found in the CAAUdfModelWithInstances
Part document thanks to the CAAMcaGetGeometry
function. This
function returns a pointer on this feature, pInput
.
We create a path, pPathSecondInput ,
with the pointer pInput
.
At last, we use the SetNewInput
method on the pIUdfFeatInstance
to modify the second input of the User Feature. The first argument of this
method is the number of the input, here it is 2 and the second argument
is the complete path of the new input, pPathSecondInput .
[Top]
This step consists in modifying the value of the published parameters of the User Feature instance.
This step has been done on the second User Feature instance The Loft
With Point2 and Point3
.
CATListValCATBaseUnknown_var * pListParam = NULL ; rc = pIUdfFeatInstance->GetParameters(pListParam) ; if ( FAILED(rc) ) return 1 ; CATICkeParm_var spCkeParm = (*pListParam)[1] ; if ( NULL_var != spCkeParm) { spCkeParm->Valuate(0.050f); } ... |
pIUdfFeatInstance
is the CATIUdfFeatureInstance interface
pointer of the instance.The GetParameters
method retrieves the list
of all the published parameters.
In this use case, the value of the first parameter, (*pListParam)[1]
has been changed by using the valuate method of CATICkeParm interface.
[Top]
rc = pIUdfFeatInstance->Reset(); if ( FAILED(rc) ) return 1; ... |
This step is mandatory after any modification on the instance. After the Reset
call you cannot modify the instance any longer.
The last actions of the CAAMcaUdfEdition use case are the following: save the CAAUdfModelWithInstances.CATPart as CAAUdfModelWithInstancesModified.CATPart, close it and delete the session. It is also described in the Loading a Document use case [5].
[Top]
This use case has demonstrated how to edit a User Feature:
Init
method[Top]
[1] | Power Copy and User Features Overview |
[2] | Creating a User Feature Reference |
[3] | Instantiating a User Feature Reference |
[4] | Building and Launching a CAA V5 Use Case |
[5] | Loading a Document |
[Top] |
Version: 1 [Nov 2001] | Document created |
[Top] |
Copyright © 2001, Dassault Systèmes. All rights reserved.