Equipment & Systems |
Distributive Systems |
Accessing Part Properties and ID DataHow to access properties and ID data |
Use Case |
AbstractThis article discusses the CAAPspProperties use case. |
This use case is intended to show you how to obtain properties and ID data information for a physical part.
[Top]
CAAPspProperties is a use case of the CAAPlantShipInterfaces.edu framework that illustrates CATPlantShipInterfaces framework capabilities.
[Top]
The goal of CAAPspProperties is to show you how to use the CATPlantShipInterfaces methods to query and obtain part properties and ID information.
[Top]
To launch CAAPspProperties , you will need to set up the build time environment, then compile CAAPspProperties along with its prerequisites, set up the run time environment, and then execute the sample. This is fully described in the referenced article [1]. When launching the use case, you must pass the following arguments:
[Top]
CAAPspProperties code is located in the CAAPspProperties .m use case module of the CAAPlantShipInterfaces.edu framework:
Windows | InstallRootDirectory\CAAPlantShipInterfaces.edu\ CAAPspProperties
.m |
Unix | InstallRootDirectory/CAAPlantShipInterfaces.edu/ CAAPspProperties
.m |
where InstallRootDirectory
is the root directory of your CAA V5
installation. It is made of two unique source files named
CAAPspPropertiesMain.cpp and CAAPspProperties .cpp.
Additional prerequisite code is located in the CAAPspUtilities.m directory of the same framework.
[Top]
There are five logical steps in CAAPspProperties :
[Top]
In this use case, we open an input document containing some Equipment and Piping Design objects.
[Top]
The CAAPspProperties code is derived from the CAAPspBaseEnv base class. The base class contains functionality common to the other CAAPsp samples. Initializing the environment involves the following methods:
CAAPspBaseEnv::CreateCATProductEnv CAAPspBaseEnv::ApplicationInit |
This method performs the following functions:
[Top]
The CATIPspAttribute interface is used to get a list of domains for a part and a list of properties for a part in a given domain. In this sample, the CATIPspAttribute interface pointer is obtained from a physical part in the document.
int NumOfDomains = 0; //---------------------------------------------------------------------- // List Domain Names //---------------------------------------------------------------------- if( SUCCEEDED( piAttribute->ListDomainNames ( &pDomainNameList)) && ( NULL != pDomainNameList )) { cout << "Succeeded in getting a list of domains for a part" << endl; delete pDomainNameList; pDomainNameList = NULL; } //---------------------------------------------------------------------- // List Attributes for CATPIP domain //---------------------------------------------------------------------- if( SUCCEEDED( piAttribute->ListAttributes ( "CATPIP", &pAttrNameList )) && ( NULL != pAttrNameList) ) { cout << "Succeeded in getting a list of attributes" << endl; // // Querying attribute values and discrete values // QueryAttributeValues( piAttribute, pAttrNameList ); } |
[Top]
The CATIPspAttribute interface pointer is also used to get the following additional information for each property:
for( int iAttr =1; iAttr <= numAttr; iAttr++ ) { CATUnicodeString uPropertyName = (*pAttrNameList)[iAttr]; // // Getting type of the attribute // CATAttrKind eAttrKind; if( SUCCEEDED(piAttribute->GetType ( uPropertyName , eAttrKind )) ) cout << "Succeeded in getting attribute type" << endl; // // Get Literal interface // if( SUCCEEDED(piAttribute->GetLiteral ( uPropertyName, &pCkeParm )) ) cout << "Succeeded in getting literal" << endl; if( NULL != pCkeParm ) { pCkeParm->Release(); pCkeParm = NULL; } // // Checking if attribute is discrete or not // CATBoolean bDiscrete = FALSE; int iDiscreteType = 0; if( FAILED(piAttribute->IsDiscrete ( uPropertyName, bDiscrete, iDiscreteType )) ) cout << "Failed to get a discrete type status. Attribute is not discrete" << endl; else { // // Getting Discrete Values ( Normal discrete attribute) // if ( bDiscrete && (iDiscreteType == 1) ) { if( eAttrKind == tk_string ) { CATListOfCATUnicodeString DiscreteValuesList; if ( SUCCEEDED(piAttribute->ListStringDiscreteValues( uPropertyName, DiscreteValuesList)) ) { cout << "Succeeded in getting string discrete values." << endl; } } else if ( eAttrKind == tk_integer) { CATListOfInt iListofInt; if( SUCCEEDED(piAttribute->ListIntegerDiscreteValues( uPropertyName, iListofInt)) ) { cout << "Succeeded in getting integer discrete values." << endl; } } else if (eAttrKind == tk_double ) { CATListOfDouble dListofDouble; if( SUCCEEDED(piAttribute->ListDoubleDiscreteValues( uPropertyName, dListofDouble)) ) { cout << "Succeeded in getting double discrete values." << endl; } } } if ( bDiscrete && (iDiscreteType == 2) ) { cout << "Discrete type is " << iDiscreteType << endl; CATListOfCATUnicodeString ShortDiscreteValuesList; CATListOfCATUnicodeString DiscreteValuesList; if ( FAILED(piAttribute->ListDiscreteValues( uPropertyName, ShortDiscreteValuesList, DiscreteValuesList)) ) { cout << "FAILED to get encoded discrete values" <<endl; } } // // Check if attribute is derived from logical line // CATBoolean Derived = FALSE; if( SUCCEEDED(piAttribute->IsDerived ( uPropertyName, &Derived )) && Derived ) { cout << uPropertyName.ConvertToChar() << " is derived" << endl; // Reset derived attribute if( SUCCEEDED(piAttribute->ResetDerivedAttr ( uPropertyName)) ) cout << "Succeeded in resetting derived attribute" << endl; } } } |
[Top]
The CATIPspID interface is used to get ID data . In this sample, the CATIPspID interface pointer is obtained from a physical part in the document. The CATIPspID interface is used to obtain the following information from an object:
//---------------------------------------------------------------------- // Generate ID without generating a new sequence number //---------------------------------------------------------------------- CATUnicodeString oGeneratedID; if( SUCCEEDED( piID->GenIDNoGenSeqNum ( oGeneratedID ) )) cout << "ID generated without a sequence number: " << oGeneratedID.ConvertToChar() << endl; //---------------------------------------------------------------------- // Generate and store ID without a sequence number //---------------------------------------------------------------------- if( SUCCEEDED( piID->GenAndPutIDNoGenSeqNum ( oGeneratedID ) )) cout << "Succeeded in generating and storing ID without a sequence number" << endl; //---------------------------------------------------------------------- // Generate and store ID with a sequence number //---------------------------------------------------------------------- if( SUCCEEDED( piID->GenAndPutID ( oGeneratedID ) )) cout << "Succeeded in generating and storing ID with a sequence number" << endl; //---------------------------------------------------------------------- // GetID //---------------------------------------------------------------------- if( SUCCEEDED( piID->GetID ( oGeneratedID ) )) cout << "Succeeded in getting ID: " << oGeneratedID.ConvertToChar() << endl; //---------------------------------------------------------------------- // Check if the ID is generated as per the schema //---------------------------------------------------------------------- CATBoolean bIsGeneratedID = FALSE; if( SUCCEEDED( piID->IsIDGenerated ( bIsGeneratedID ) )) cout << "Succeeded in checking: IsIDGenerated" << endl; //---------------------------------------------------------------------- // GetLocalID //---------------------------------------------------------------------- CATUnicodeString oLocalID; if( SUCCEEDED( piID->GetLocalID ( oLocalID ) )) cout << "Succeeded in getting Local ID" << endl; |
[Top]
This use case has demonstrated how to use the Psp interfaces to obtain part ID and properties information. Specifically, it has illustrated:
[Top]
[1] | Building and Launching a CAA V5 Use Case |
Version: 1 [March 2003] | Document created |
[Top] |
Copyright © 2003, Dassault Systèmes. All rights reserved.