Mechanical Design |
Structure |
Retrieving the Structure Plate and Member dataHow to retrieve the plate and member data |
Use Case |
AbstractThis article discusses the CAAStrRetrieveObjectData use case. |
This use case is intended to show you how to initialize CATIA session, get the root product and query the structure plates and members under the root, and get the plate and member data from a design document.
[Top]
CAAStrRetrieveObjectData is a use case of the CAAStructureInterfaces.edu framework that illustrates StructureInterfaces framework capabilities.
[Top]
The goal of CAAStrRetrieveObjectData is to show you how to use the StructureInterfaces methods to query and obtain structure plate and member information from the objects in a design document.
[Top]
To launch CAAStrRetrieveObjectData, you will need to set up the build time environment, then compile CAAStrRetrieveObjectData 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]
CAAStrRetrieveObjectData code is located in the CAAStrRetrieveObjectData.m use case module of the CAAStructureInterfaces.edu framework:
Windows | InstallRootDirectory\CAAStructureInterfaces.edu\CAAStrRetrieveObjectData.m |
Unix | InstallRootDirectory/CAAStructureInterfaces.edu/CAAStrRetrieveObjectData.m |
where InstallRootDirectory
is the root directory of your CAA V5
installation. It is made of one unique source files named
CAAStrRetrieveObjectDataMain.cpp.
[Top]
There are seven logical steps in CAAStrRetrieveObjectData :
[Top]
In this use case, we open an input document containing some Equipment and Piping Design objects.
[Top]
The CAAStrRetrieveObjectDataMain is a standalone batch program . The initialization of the CATIA session and retrieving pointer of the root product involves the following code
/* ----------------------------- */ /* Initialize the CATIA session */ /* ----------------------------- */ CATSession* pSession = NULL; rc = ::Create_Session("CAA2_Sample_Session", pSession); /* ------------------------------------- */ /* Load an existing CATProduct document */ /* ------------------------------------- */ CATDocument* pDoc = NULL; rc = CATDocumentServices::Open(argv[1], pDoc); /* ------------------------------------ */ /* Retrieve pointer of the root Product */ /* ------------------------------------ */ CATIDocRoots* piDocRootsOnDoc = NULL; rc = pDoc->QueryInterface(IID_CATIDocRoots, (void**) &piDocRootsOnDoc); CATListValCATBaseUnknown_var* pRootProducts = piDocRootsOnDoc->GiveDocRoots(); CATIProduct_var spRootProduct = NULL_var; if (pRootProducts && pRootProducts->Size()) { spRootProduct = (*pRootProducts)[1]; delete pRootProducts; pRootProducts = NULL; } if (NULL != piDocRootsOnDoc) piDocRootsOnDoc->Release(); // Get CATIProduct handle on the root product. CATIProduct *piProductOnRoot = NULL; rc = spRootProduct->QueryInterface(IID_CATIProduct,(void**)&piProductOnRoot); |
This code performs the following functions:
[Top]
Retrieves plates and their characteristics
/* ------------------------------------------- */ /* Retrieves plates and plate data */ /* ------------------------------------------- */ CATListValCATBaseUnknown_var* ListPlate = piProductOnRoot->GetAllChildren("CATIStructurePlate"); if(NULL != ListPlate) { int numberOfChildren = ListPlate->Size(); /* ------------------------------------------ */ /* For each plate, get its information */ /* ------------------------------------------ */ CATIProduct_var spChild = NULL_var; for (int i = 1; i <= numberOfChildren; i++) { CATIProduct_var spChild = (*ListPlate)[i]; if (NULL_var != spChild) { CATIStructurePlate *piStrPlate = NULL; spChild->QueryInterface(IID_CATIStructurePlate, (void**)&piStrPlate); if (piStrPlate) { //----------------------- // Get Plate's material //----------------------- CATIMaterialFeature *oMatFeat = NULL; rc = piStrPlate->GetMaterial(&oMatFeat); if (FAILED(rc)) { cout << " CAAStrRetrieveObjectDataMain : "; cout << " Failed to get Plate's material " << endl << flush; } if (NULL != oMatFeat) { oMatFeat->Release(); oMatFeat = NULL; } //---------------------- // Get Plate's thickness //---------------------- double Thickness = 0.0; rc = piStrPlate->GetThickness(Thickness); if (FAILED(rc)) { cout << " CAAStrRetrieveObjectDataMain : "; cout << " Failed to get Plate's thickness " << endl << flush; } //---------------------- // Get Plate's offset //---------------------- double Offset = 0.0; rc = piStrPlate->GetInternalOffset(Offset); if (FAILED(rc)) { cout << " CAAStrRetrieveObjectDataMain : "; cout << " Failed to get Plate's offset " << endl << flush; } //---------------------------- // Get Plate's support //---------------------------- CATISpecObject *pSupport = NULL; rc = piStrPlate->GetSupport(&pSupport); if (FAILED(rc)) { cout << " CAAStrRetrieveObjectDataMain : "; cout << " Failed to get Plate's support type " << endl << flush; } if (NULL != pSupport) { pSupport->Release(); pSupport = NULL; } //------------------------------ // Get Plate's extrusion vector //------------------------------ CATMathDirection ExtrusionVector; rc = piStrPlate->GetExtrusionDirection(ExtrusionVector); if (FAILED(rc)) { cout << " CAAStrRetrieveObjectDataMain : "; cout << " Failed to get Plate's extrusion vector " << endl << flush; } //----------------------- // Get Plate's vertices //----------------------- CATListValCATMathPoint ListOfVertices; rc = piStrPlate->GetListOfVertices(ListOfVertices); if (FAILED(rc)) { cout << " CAAStrRetrieveObjectDataMain : "; cout << " Failed to get Plate's vertices " << endl << flush; } //----------------------------- // Get List Attribute Names //----------------------------- CATListValCATUnicodeString *oListOfAttributeNames = NULL; rc = piStrPlate->ListAttributeName(&oListOfAttributeNames); if (FAILED(rc)) { cout << " CAAStrRetrieveObjectDataMain : "; cout << " Failed to get Plate's list attribute names" << endl << flush; } else { if (oListOfAttributeNames) { int ListSize = oListOfAttributeNames->Size(); for (int j = 1; j <= ListSize; j++) { CATUnicodeString uName = (*oListOfAttributeNames)[j]; cout << " ATTRIBUTE NAME : " << uName << endl << flush; } } } //----------------------------- // Get Plate's Attribute Value //----------------------------- if (oListOfAttributeNames) { int ListSize = oListOfAttributeNames->Size(); for (int i = 1; i <= ListSize; i++) { CATICkeParm *opParm = NULL; CATUnicodeString ipName = (*oListOfAttributeNames)[i]; rc = piStrPlate->GetAttribute(ipName, &opParm); if (FAILED(rc)) { cout << " CAAStrRetrieveObjectDataMain : "; cout << " Failed to get Plate's attribute " << endl << flush; } if (NULL != opParm) { opParm->Release(); opParm = NULL; } } oListOfAttributeNames->RemoveAll(); delete oListOfAttributeNames; oListOfAttributeNames = NULL; } piStrPlate->Release(); piStrPlate= NULL; } } } delete ListPlate; ListPlate=NULL; } |
[Top]
To retrieve the data on each structure member object, it involves the following code.
/* ---------------------------------------------------------- */ /* Retrieves all the member object under the root */ /* ---------------------------------------------------------- */ CATListValCATBaseUnknown_var* ListMember = piProductOnRoot->GetAllChildren("CATIStructureMember"); if(NULL != ListMember) { int numberOfChildren = ListMember->Size(); /* ------------------------------------------ */ /* For each member, get its information */ /* ------------------------------------------ */ CATIProduct_var spChild = NULL_var; for (int i = 1; i <= numberOfChildren; i++) { CATIProduct_var spChild = (*ListMember)[i]; if (NULL_var != spChild) { CATIStructureMember *piStrMember = NULL; spChild->QueryInterface(IID_CATIStructureMember, (void**)&piStrMember); if (piStrMember) { //----------------------------- // Get List Attribute Names //----------------------------- CATListValCATUnicodeString *oListOfAttributeNames = NULL; rc = piStrMember->ListAttributeName(&oListOfAttributeNames); if (FAILED(rc)) { cout << " CAAStrRetrieveObjectDataMain : "; cout << " Failed to get member's list attribute names" << endl << flush; } //------------------------ // Get Member's Attribute //------------------------ if (oListOfAttributeNames) { int ListSize = oListOfAttributeNames->Size(); for (int i = 1; i <= ListSize; i++) { CATICkeParm *opParm = NULL; CATUnicodeString ipName = (*oListOfAttributeNames)[i]; rc = piStrMember->GetAttribute(ipName, &opParm); if (FAILED(rc)) { cout << " CAAStrRetrieveObjectDataMain : "; cout << " Failed to get member's attribute " << endl << flush; } if (NULL != opParm) { opParm->Release(); opParm = NULL; } } oListOfAttributeNames->RemoveAll(); delete oListOfAttributeNames; oListOfAttributeNames = NULL; } //---------------------- // Get Member's Section //---------------------- CATDocument *oCATDocument = NULL; rc = piStrMember->GetSection(oCATDocument); if (FAILED(rc)) { cout << " CAAStrRetrieveObjectDataMain : "; cout << " Failed to get member's section " << endl << flush; } oCATDocument = NULL; //--------------------------- // Get Member's Section Name //--------------------------- CATUnicodeString oName; rc = piStrMember->GetSectionName(oName); if (FAILED(rc)) { cout << " CAAStrRetrieveObjectDataMain : "; cout << " Failed to get member's section name " << endl << flush; } //-------------------------- // Get Member's Family Name //-------------------------- oName = ""; rc = piStrMember->GetFamilyName(oName); if (FAILED(rc)) { cout << " CAAStrRetrieveObjectDataMain : "; cout << " Failed to get member's family name " << endl << flush; } //--------------------------- // Get Member's Catalog Name //--------------------------- oName = ""; rc = piStrMember->GetCatalogName(oName); if (FAILED(rc)) { cout << " CAAStrRetrieveObjectDataMain : "; cout << " Failed to get member's catalog name " << endl << flush; } //--------------------------- // Get Member's Profile Type //--------------------------- oName = ""; rc = piStrMember->GetProfileType(oName); if (FAILED(rc)) { cout << " CAAStrRetrieveObjectDataMain : "; cout << " Failed to get member's profile type " << endl << flush; } //---------------------------- // Get Member's Start Cutback //---------------------------- CatStrCutbackType oCutbackType; CATICkeParm *oCutback = NULL; rc = piStrMember->GetStartCutback(oCutbackType, &oCutback); if (FAILED(rc)) { cout << " CAAStrRetrieveObjectDataMain : "; cout << " Failed to get member's start cutback type " << endl << flush; } if (NULL != oCutback) { oCutback->Release(); oCutback = NULL; } //-------------------------- // Get Member's End Cutback //-------------------------- CatStrCutbackType oECutbackType; CATICkeParm *oECutback = NULL; rc = piStrMember->GetEndCutback(oECutbackType, &oECutback); if (FAILED(rc)) { cout << " CAAStrRetrieveObjectDataMain : "; cout << " Failed to get member's end cutback type " << endl << flush; } if (NULL != oECutback) { oECutback->Release(); oECutback = NULL; } //------------------------------- // Get Member's Current SetPoint //------------------------------- CatStrPlacementPoint oSetPoint; rc = piStrMember->GetCurrentSetPoint(oSetPoint); if (FAILED(rc)) { cout << " CAAStrRetrieveObjectDataMain : "; cout << " Failed to get member's current set point(CatStrPlacementPoint) " << endl << flush; } //------------------------------ // GetMember's Current SetPoint //------------------------------ CATUnicodeString uSetPoint; rc = piStrMember->GetCurrentSetPoint(uSetPoint); if (FAILED(rc)) { cout << " CAAStrRetrieveObjectDataMain : "; cout << " Failed to get member's current set point(CATUnicodeString)" << endl << flush; } //-------------------- // Get Member's Angle //-------------------- CATICkeParm *oAngleParm = NULL; rc = piStrMember->GetAngle(&oAngleParm); if (FAILED(rc)) { cout << " CAAStrRetrieveObjectDataMain : "; cout << " Failed to get member's angle " << endl << flush; } if (NULL != oAngleParm) { oAngleParm->Release(); oAngleParm = NULL; } //--------------------------------- // Get Member's Section Orientation //--------------------------------- CatStrMaterialOrientation oSectionOrientation; rc = piStrMember->GetSectionOrientation(oSectionOrientation); if (FAILED(rc)) { cout << " CAAStrRetrieveObjectDataMain : "; cout << " Failed to get member's section orientation(CatStrMaterialOrientation) " << endl << flush; } //--------------------------------- // Get Member's Section Orientation //--------------------------------- CATMathVector oU; CATMathVector oV; rc = piStrMember->GetSectionOrientation(oU, oV); if (FAILED(rc)) { cout << " CAAStrRetrieveObjectDataMain : "; cout << " Failed to get member's section orientation" << endl << flush; } //--------------------------------- // Get Member's Side Orientation //--------------------------------- CatStrMaterialOrientation oSideOrientation; rc = piStrMember->GetSideOrientation(oSideOrientation); if (FAILED(rc)) { cout << " CAAStrRetrieveObjectDataMain : "; cout << " Failed to get member's side orientation" << endl << flush; } //-------------------------------- // Get Member's Start Coordinates //-------------------------------- CATMathPoint oStartMath; rc = piStrMember->GetStartCoord(oStartMath); if (FAILED(rc)) { cout << " CAAStrRetrieveObjectDataMain : "; cout << " Failed to get member's start coordinates" << endl << flush; } //------------------------------ // Get Member's End Coordinates //------------------------------ CATMathPoint oEndMath; rc = piStrMember->GetEndCoord(oEndMath); if (FAILED(rc)) { cout << " CAAStrRetrieveObjectDataMain : "; cout << " Failed to get member's end coordinates" << endl << flush; } //--------------------------- // Get Member's Start Offset //--------------------------- CATICkeParm *oStartOffset = NULL; rc = piStrMember->GetStartOffset(&oStartOffset); if (FAILED(rc)) { cout << " CAAStrRetrieveObjectDataMain : "; cout << " Failed to get member's start offset " << endl << flush; } if (NULL != oStartOffset) { oStartOffset->Release(); oStartOffset = NULL; } //------------------------- // Get Member's End Offset //------------------------- CATICkeParm *oEndOffset = NULL; rc = piStrMember->GetEndOffset(&oEndOffset); if (FAILED(rc)) { cout << " CAAStrRetrieveObjectDataMain : "; cout << " Failed to get member's end offset " << endl << flush; } if (NULL != oEndOffset) { oEndOffset->Release(); oEndOffset = NULL; } //------------------------- // Get Member's support //------------------------- CATISpecObject *oMemSupport = NULL; rc = piStrMember->GetMemberSupport(&oMemSupport); if (FAILED(rc)) { cout << " CAAStrRetrieveObjectDataMain : "; cout << " Failed to get member's support " << endl << flush; } if (NULL != oMemSupport) { oMemSupport->Release(); oMemSupport = NULL; } //-------------------------- // Get Member's section axis //-------------------------- CATMathAxis oMemberSectionAxis; rc = piStrMember->GetMemberSectionAxis(oMemberSectionAxis); if (FAILED(rc)) { cout << " CAAStrRetrieveObjectDataMain : "; cout << " Failed to get member's section axis " << endl << flush; } else { cout << " Get member's reference object OK " << endl << flush; CATMathVector oFirstVector; oMemberSectionAxis.GetFirstDirection(oFirstVector); CATMathVector oSecondVector; oMemberSectionAxis.GetSecondDirection(oSecondVector); CATMathVector oThirdVector; oMemberSectionAxis.GetThirdDirection(oThirdVector); } //------------------------- // Get Member's reference //------------------------- CATISpecObject *oMemReference = NULL; rc = piStrMember->GetMemberReference(&oMemReference); if (FAILED(rc)) { cout << " CAAStrRetrieveObjectDataMain : "; cout << " Failed to get member's reference " << endl << flush; } if (NULL != oMemReference) { oMemReference->Release(); oMemReference = NULL; } //----------------------- // Get Member's Material //----------------------- CATIMaterialFeature *oMatFeat = NULL; rc = piStrMember->GetMaterial(&oMatFeat); if (FAILED(rc)) { cout << " CAAStrRetrieveObjectDataMain : "; cout << " Failed to get member's material " << endl << flush; } if (NULL != oMatFeat) { oMatFeat->Release(); oMatFeat = NULL; } piStrMember->Release(); piStrMember = NULL; } } } delete ListMember; ListMember=NULL; } } |
[Top]
Never forget to delete a created session and removes the opened documents after the usage .
/* -------------------------------------------- */ /* Ends the session */ /* -------------------------------------------- */ // remove opened document rc = CATDocumentServices::Remove (*pDoc); if (!SUCCEEDED(rc)) return 6; rc = ::Delete_Session("CAA2_Sample_Session"); if (SUCCEEDED(rc)) cout << " Delete Session Succeeded " << endl << flush; |
[Top]
This use case has demonstrated how to use the Structure interfaces to query the data on the structure objects on a design document. Specifically, it has illustrated:
[Top]
[1] | Building and Launching a CAA V5 Use Case |
Version: 1 [August 2003] | Document created |
Version: 2 [March 2004] | Added method GetMemberReference, GetMemberSupport and GetMemberSectionAxis |
[Top] |
Copyright © 2003, Dassault Systèmes. All rights reserved.