Equipment & Systems |
Distributive Systems |
Define User computed propertiesHow to define computed properties |
Use Case |
AbstractThis article discusses the CAAPspDefineUserProperties use case. |
This use case is intended to show you how to define a computed property for an exposed (knowledgeware) type in Distributive System document.
A Computed property (attribute) is an exposed knowledgeware attribute whose value is computed based on values of other attributes (static attributes that are Feature Dictionary defined, internal or other computed attributes) or by use of specific application interface methods. This use case will allow users to define their own computed attributes so that they can be used in such tools as "Edit + Search", "Report generator" command and other knowledgeware tools.
[Top]
CAAPspDefineUserProperties is a use case of the CAAPlantShipInterfaces.edu framework that illustrates CATPlantShipInterfaces framework capabilities.
[Top]
The goal of CAAPspDefineUserProperties is to show you how to define a computed property for an exposed (knowledgeware) type in Distributive System document. This use case defines an attribute "TotalWallThickness" for "PipingPart" exposed type in "PipingLayout" package.
Additionally this use case defines attributes that compute their value from Enovia based attributes. These additional computed attributes demonstrate the usefulness of using computed attributes to obtain information from the Enovia data base that can be listed in reports or searches. To successfully use this part of the use case, you must be running within an Enovia environment, enable Attribute Mapping for interoperability, and know the exact attribute names of the Enovia attributes you wish to retrieve.
[Top]
To use CAAPspDefineUserProperties, you will need to set up the build time environment, then compile CAAPspDefineUserProperties along with its prerequisites, set up the run time environment. In addition you may want to
if (CATGetEnvValue("RunSample",0) ...
And/Or
[Top]
CAAPspDefineUserProperties code is located in the CAAPspDefineUserProperties .m use case module of the CAAPlantShipInterfaces.edu framework:
Windows | InstallRootDirectory\CAAPlantShipInterfaces.edu\ CAAPspDefineUserProperties
.m |
Unix | InstallRootDirectory/CAAPlantShipInterfaces.edu/ CAAPspDefineUserProperties
.m |
where InstallRootDirectory
is the root directory of your CAA V5
installation. It is made of a unique source file named
CAAPspDefineUserProperties.cpp.
[Top]
There are five logical steps in CAADefineUserPspProperties :
[Top]
To define computed attributes this use case provides an implementation for CATIPspKweUserAttr. The implementation derives from adaptor class CATPspKweUserAttrAdapter.
[Top]
CAAPspDefineUserAttributes is an implementation on late type "PipingLayout" to implement interface CATIPspKweUserAttr. It should always derive from base adaptor class CATPspKweUserAttrAdapter.
...
class CAAPspDefineUserAttributes: public CATPspKweUserAttrAdapter {
...
CATIPspKweUserAttr can also be implemented on following Latetypes (corresponding to Knowledgeware exposed Package names) to define computed attributes on types exposed by them.
|
Package Late type names |
1 |
PlantShipLayout |
2 |
PipingLayout |
3 |
InstrLayout |
4 |
HVACLayout |
5 |
EquipLayout |
6 |
TubingLayout |
7 |
WaveguideLayout |
8 |
RacewayLayout |
9 |
ConduitLayout |
10 |
HangerLayout |
11 |
CompAccessLayout |
12 |
ElectricalShipbuilding |
CATImplementClass(CAAPspDefineUserAttributes, DataExtension, CATBaseUnknown, PipingLayout); #include "TIE_CATIPspKweUserAttr.h" TIEchain_CATIPspKweUserAttr(CAAPspDefineUserAttributes); |
[Top]
CAAPspDefineUserAttributes::DefineKweUserAttr is used to define computed attribute. It takes in two parameters. First parameter isTypeName is the name of exposed type while other olAttrInfos is the output list of attributes ( collection of CATAttributeInfos).
HESULT CAAPspDefineUserAttributes::DefineKweUserAttr(const CATString &isTypeName, CATListValCATAttributeInfos &olAttrInfos) { ... |
First get Type dictionary returned by CATGlobalFunctions::GetTypeDictionary and a dictionary of types returned by calling CATCkeGlobalFunctions::GetParmDictionary.
... cout<<"Entering DefineKweUserAttr!!!!"<<endl; CATITypeDictionary_var spDico = CATGlobalFunctions::GetTypeDictionary(); // Get Dictionary of types CATIParmDictionary_var spParmDictionary = CATCkeGlobalFunctions::GetParmDictionary(); ... |
Use spParmDictionary to get type of an real type spCkeReal.
Then for the exposed type "PipingPart", create an attribute ( object infoAttr of class CATAttributeInfos with computed attribute name "TotalWallThickness" and of real type spCkeReal) . Append infoAttr to the output collection parameter olAttrInfos.
... if(!!spDico && !!spParmDictionary) { if( isTypeName == "PipingPart" ) { cout<<"Defining computed attribute for PipingPart "<< endl; // // Define Real type computed attribute TotalWallThickness // CATUnicodeString uAttrInternalName("TotalWallThickness"); CATUnicodeString uAttrNLSName("Total Wall Thickness"); CATICkeType_var spCkeReal = spParmDictionary->GetRealType(); CATIType_var spTypeReal(spCkeReal); CATAttributeInfos infoAttr(spTypeReal, uAttrInternalName, uAttrNLSName); olAttrInfos.Append(infoAttr); } |
[Top]
CAAPspDefineUserAttributes::GetValue method is used to define calculation method for user computed attribute. Its function signature takes in two parameters; ipiObject is the CATIInstance pointer to an exposed object, iKey is the name of the attribute for which calculation method is to be defined. It returns pointer to CATIValue interface that manages the value of the computed attribute.
CATIValue* CAAPspDefineUserAttributes::GetValue (CATIInstance* ipiObject, const CATUnicodeString& iKey) { ... |
Get a volatile factory of values spVolFactory using the function CATCkeGlobalFunctions::GetVolatileFactory(). A Length parameter spResultParm (of handler to interface CATICkeParm) is created for "TotalWallThickness" computed attribute by using the function CreateLength of spVolFactory.
... CATUnicodeString uAttrInternalName("TotalWallThickness"); if (iKey == uAttrInternalName) { CATICkeParm_var spResultParm; // Get volatile factory of values CATICkeParmFactory_var spVolFactory = CATCkeGlobalFunctions::GetVolatileFactory(); if (!!spVolFactory) spResultParm = spVolFactory->CreateLength(iKey, 0.0); ... |
Then it computes the grand total of the values for the computed attributes "WallThickness", "WallThickness2", "WallThickness3" and "WallThickness4" and stores the value in dTotWallThickness.
double dTotWallThickness = 0.0; // Get values for the other exposed attributes that // will be used in calculating total of WallThickness* attributes CATListOfCATUnicodeString LWallThicknessAttr; LWallThicknessAttr.Append("WallThickness"); LWallThicknessAttr.Append("WallThickness2"); LWallThicknessAttr.Append("WallThickness3"); LWallThicknessAttr.Append("WallThickness4"); for( int idx =1; idx< LWallThicknessAttr.Size(); idx++ ) { piVal = ipiObject->GetValue (LWallThicknessAttr[idx]); if( NULL != piVal ) { double dVal; HRESULT rc1 = piVal->AsReal(dVal); if( SUCCEEDED(rc1) ) { dTotWallThickness = dTotWallThickness + dVal; } } |
spResultParm is valuated with grand total ( dTotWallThickness) of various Wall thickness attributes by using the function Valuate(). Then get CATIValue interface pointer (piResultValue) to spResultParm. Use piResultValue to return from CATIPspKweUserAttr::GetValue implementation method.
if (!! spResultParm) { spResultParm->Valuate(dTotWallThickness); spResultParm->QueryInterface(IID_CATIValue, (void **)&piResultValue); } ... if (piResultValue) { cout << "Returning value for TotalWallThickness:" << (piResultValue->Show()).ConvertToChar(); } cout<<"Exit CAAPspDefineUserAttributes::GetValue!!!!"<<endl; return piResultValue; |
[Top]
Declare implementation of CATIPspKweUserAttr in the CAAPlantShipInterfaces.edu.dico file as shown below:
#====================================================================== #CAAPlantShipInterfaces.edu #====================================================================== PipingLayout CATIPspKweUserAttr libCAAPspDefineUserProperties |
[Top]
Optional steps can be performed in order to understand how to access Enovia attributes using the knowlegeware interface for computed attribues.
[Top]
If you are running in an Enovia enviroment, you may wish to experiment with retrieving attributes from the Enovia data base for a given object. To do this, you must first define an attribute mapping file. A sample mapping file is located within comments at the end of the file CAAPspDefineUserProperties.cpp.
See the VPM Navigator guide, chapter on Interoperability, for details of the format of this file.
You will need to set the proper tools option to point to this file:
This extract shows the mapping of Enovia attributes V_status and V_user to the CATIA attributes Life Cycle Status and User In Enovia.
<!-- Attributes for Part Domain --> <AttributesMapping EntityType="Part" DomainName="PRODUCT"> <!-- Part Attribute 2 --> <Attribute Name="Status" Type="STRING"> <CATIAInfo Name="Life Cycle Status" Editable="No" Visible="Yes" /> <DBInfo Name="V_status" LCASubEntity="PV" Editable="Yes" Visible="Yes" /> </Attribute> <!-- Part Attribute 3 --> <Attribute Name="DBUser" Type="STRING"> <CATIAInfo Name="User In Enovia" Editable="No" Visible="Yes" /> <DBInfo Name="V_user" LCASubEntity="PM" Editable="Yes" Visible="Yes" /> </Attribute> |
The properties dialog will show the values of these mapped attributes as added properties.
This extract shows the mapping of Enovia attributes V_version and V_status to the CATIA attributes with internal names ENOVIA5.DocumentRevision and ENOVIA5.DocumentStatus.
<!-- Attributes for Document Domain --> <AttributesMapping EntityType="Document" DomainName="DOCDIR"> <!-- Document Attribute 1 --> <Attribute Name="DocumentRevision" Type="STRING"> <CATIAInfo Name="ENOVIA5.DocumentRevision" Editable="No" Visible="Yes" /> <DBInfo Name="V_version" LCASubEntity="DV" Editable="Yes" Visible="Yes" /> </Attribute> <!-- Document Attribute 2 --> <Attribute Name="Status" Type="STRING"> <CATIAInfo Name="ENOVIA5.DocumentStatus" Editable="No" Visible="Yes" /> <DBInfo Name="V_status" LCASubEntity="DV" Editable="Yes" Visible="Yes" /> </Attribute> </AttributesMapping> |
The user names displayed in the PLM tab of the properties dialog will be "DocumentRevision" and "DocumentStatus".
[Top]
Computed attributes are defined the same way as for "TotalWallThickness" in the standard steps. To use the optional code within the use case, locate the line listed below and change the '0' to '1', recompile and link the module.
#define
CAA_PSP_OPTIONAL 0[Top]
There are two types of mapped Enovia attributes in this use case. Both types return string information. However, the method of finding and retrieving the value is different.
For mapped attributes found on the Product tab of the properties dialog, the method GetUserStringValue is used. It uses the CATIPrdProperties interface to find the desired attribute. For mapped attributes found on the PLM Document attributes tab of the properties dialog, the method GetPLMStringValue is used. This method retrieves the mapped attribute value from the document using the CATOmbDocPropertyServices utility.
[Top]
This use case has demonstrated how to Define a computed property "TotalWallThickness" for "PipingPart" exposed type in "PipingLayout" package. It has also shown how to define and compute values for mapped attributes. It has illustrated:
Top]
[1] | Building and Launching a CAA V5 Use Case |
[2] | Access user computed properties |
[3] | VPM Navigator guide - chapter on Interoperability |
Version: 1 [January 2005] | Document created |
Version: 2 [August 2005] | Optional steps added |
[Top] |
Copyright © 2005, Dassault Systèmes. All rights reserved.