Equipment & Systems |
Distributive Systems |
Accessing Group and Groupable DataHow to create, delete and access Group and Groupable data |
Use Case |
AbstractThis article discusses the CAAPspGroup use case. |
This use case is intended to show you how to create or instanciate a group, such as logical line or spools, delete a group, query a group, and query groupable data of a part.
[Top]
CAAPspGroup is a use case of the CAAPlantShipInterfaces.edu framework that illustrates CATPlantShipInterfaces framework capabilities.
[Top]
The goal of CAAPspGroup is to show you how to use the CATPlantShipInterfaces methods to create, delete and query and obtain group and part groupable information.
[Top]
To launch CAAPspGroup , you will need to set up the build time environment, then compile CAAPspGroup 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]
CAAPspGroup code is located in the CAAPspGroup .m use case module of the CAAPlantShipInterfaces.edu framework:
Windows | InstallRootDirectory\CAAPlantShipInterfaces.edu\ CAAPspGroup
.m |
Unix | InstallRootDirectory/CAAPlantShipInterfaces.edu/ CAAPspGroup
.m |
where InstallRootDirectory
is the root directory of your CAA V5
installation. It is made of two unique source files named CAAPspGroupMain.cpp and
CAAPspGroup .cpp.
Additional prerequisite code is located in the CAAPspUtilities.m directory of the same framework.
[Top]
There are four logical steps in CAAPspGroup :
Top]
In this use case, we open an input document containing some Equipment and Piping Design objects.
[Top]
The CAAPspGroup 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 CATIPspGroup interface is used to get a list of group members, to remove members from and add members to a group. In this sample, the CATIPspGroup interface pointer is obtained from a Logical Line in the document.
//---------------------------------------------------------------------- // List Members //---------------------------------------------------------------------- if ( SUCCEEDED(piGroup->ListMembers ( NULL, &pListMembers )) && ( NULL != pListMembers)) { cout << "Succeeded in getting group's members" << endl; unsigned int LUnknownSize = 0; int NumOfUnknowns = 0; if (pListMembers > 0) pListMembers->Count (&LUnknownSize); NumOfUnknowns = LUnknownSize; cout << "Number of members is " << NumOfUnknowns << endl; if (NumOfUnknowns > 0) { for (int iUK=1; iUK <= NumOfUnknowns; iUK++) { if (SUCCEEDED(pListMembers->Item (iUK-1,&piUKMember)) && piUKMember ) { // // Getting CATIPspGroupable interface pointer // rc = piUKMember->QueryInterface (IID_CATIPspGroupable, (void **)&piGroupable); piUKMember->Release(); piUKMember = NULL; if ( NULL != piGroupable ) break; } } } pListMembers->Release(); pListMembers = NULL; } if ( NULL != piGroupable ) { //-------------------------------------------------------------------- // Remove a member //-------------------------------------------------------------------- if ( SUCCEEDED(piGroup->RemoveMember(piGroupable)) ) cout << "Succeeded in removing a member from the group" << endl; //-------------------------------------------------------------------- // Add a member //-------------------------------------------------------------------- if ( SUCCEEDED(piGroup->AddMember(piGroupable)) ) cout << "Succeeded in adding a member to the group" << endl; } |
[Top]
The CATIPspGroupable interface pointer is obtained from one of the group members and is used to get the following information:
//---------------------------------------------------------------------- // List groups that the groupable belongs to //---------------------------------------------------------------------- if ( SUCCEEDED( piGroupable->ListGroups( NULL, &pListGroups)) && (NULL != pListGroups) ) { cout << "Succeeded in getting list of groups" << endl; } |
[Top]
The CATIPspAppFactory interface is used to get a list of groups in the current document; to instanciate or create a logical line, compartment or group; to delete a logical line, compartment or group. The CATIPspAppFactory interface pointer is obtained from the root product of the document.
//---------------------------------------------------------------------- // Instanciate a PipingLine from the PipingLine catalog //---------------------------------------------------------------------- CATUnicodeString PipingLineID = "U1-P103-6in-CS150R-FG"; if ( SUCCEEDED(piAppFactory->GetLogicalLine(piCurrentProduct, PipingLineID, &piLogicalLine)) && (NULL != piLogicalLine) ) { cout << "Succeeded in instanciating a Piping Line" << endl; |
if ( SUCCEEDED(piAppFactory->ListLogicalLines(piCurrentProduct,&pListLogicalLines)) && (NULL != pListLogicalLines) ) { unsigned int LUnknownSize = 0; int NumOfUnknowns = 0; pListLogicalLines->Count (&LUnknownSize); NumOfUnknowns = LUnknownSize; cout << "Number of PipingLines in document = " << NumOfUnknowns << endl; pListLogicalLines->Release(); pListLogicalLines = NULL; } |
if ( SUCCEEDED(piAppFactory->DeleteLogicalLine(piLogicalLine)) ) cout << "Succeeded in deleting a PipingLine instance" << endl; |
CATUnicodeString GroupType = "CATPipSpool"; CATUnicodeString GroupID = "PipingSpool"; if ( SUCCEEDED(piAppFactory->CreateGroup(piCurrentProduct, GroupType, GroupID, &piGroup)) && (NULL != piGroup) ) { cout << "Succeeded in creating a Piping Spool" << endl; |
if ( SUCCEEDED(piAppFactory->ListGroups(piCurrentProduct,&pListGroups)) && (NULL != pListGroups) ) { unsigned int LUnknownSize = 0; int NumOfUnknowns = 0; pListGroups->Count (&LUnknownSize); NumOfUnknowns = LUnknownSize; ... ... } |
if ( SUCCEEDED(piAppFactory->DeleteGroup(piGroup)) ) cout << "Succeeded in deleting a Piping spool object" << endl; |
[Top]
This use case has demonstrated how to use the Psp interfaces to obtain Group and part Groupable 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.