Mechanical Design |
Structure |
Creating the Structure Plate and Member ObjectsHow to create the plate and member objects |
Use Case |
AbstractThis article discusses the CAAStrCreateObjects use case. |
This use case is intended to show you how to initialize CATIA session, create a new product, get the root product and create the structure plates and members under the root, and save the created design document.
[Top]
CAAStrRetrieveObjectData is a use case of the CAAStructureInterfaces.edu framework that illustrates StructureInterfaces framework capabilities.
[Top]
The goal of CAAStrCreateObjects is to show you how to use the StructureInterfaces methods to create the structure plate and member objects.
[Top]
To launch CAAStrCreateObjects, you will need to set up the build time environment, then compile CAAStrCreateObjects 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]
CAAStrCreateObjects code is located in the CAAStrCreateObjects.m use case module of the CAAStructureInterfaces.edu framework:
Windows | InstallRootDirectory\CAAStructureInterfaces.edu\CAAStrCreateObjects.m |
Unix | InstallRootDirectory/CAAStructureInterfaces.edu/CAAStrCreateObjects.m |
where InstallRootDirectory
is the root directory of your CAA V5
installation. It is made of one unique source files named
CAAStrCreateStructureObjects.cpp.
[Top]
There are seven logical steps in CAAStrCreateObjects :
[Top]
In this use case, we create an new document to hold the newly created structure plate and member objects.
[Top]
The CAAStrCreateObjectsMain is a standalone batch program . The initialization of the CATIA session and retrieving pointer of the root product involves the following code
CATSession *pSession = NULL; rc = ::Create_Session("CAA2_Sample_Session", pSession ); CATDocument *pDoc = NULL; rc = CATDocumentServices::New("Product", pDoc); CATIDocRoots *piDocRootsOnDoc = NULL; rc = pDoc->QueryInterface(IID_CATIDocRoots, (void**) &piDocRootsOnDoc); |
This code performs the following functions:
[Top]
Retrieving the default or customized project resource setting from the XML file.
// GetRootContainer from the document in the current session CATInit_var spInit = pDoc; CATIContainer *piRootCont = NULL; if (!! spInit) { piRootCont = (CATIContainer *)spInit->GetRootContainer(CATIContainer::ClassName()); } CATIPspResource *piResource = NULL; CATObject *piObj = new CATObject("CATStructureDesign"); if ( NULL != piObj ) { // initialize the application CATIPspApplication *piApplication = NULL; rc = piObj->QueryInterface(IID_CATIPspApplication,(void **)&piApplication); if (piApplication) { piApplication->Initialization(piRootCont); piApplication->Release(); piApplication = NULL; } // Get CATIPspResource interface pointer for your application rc = piObj->QueryInterface(IID_CATIPspResource,(void **)&piResource); if ( FAILED(rc) ){ cout << "ERROR in getting CATIPspResource pointer" << endl << flush; return 3; } piObj->Release(); piObj = NULL; } if (NULL != piResource) { // retrieve the Structure Materials Catalog path from Project Resource (XML) File CATUnicodeString StructureMaterials = "StructureMaterialsCatalog"; rc = piResource->GetResourcePath(StructureMaterials, MaterialFilePath); if ( FAILED(rc) ){ cout << "ERROR in getting material catalog path" << endl << flush; return 3; } } if (NULL != piRootCont) { piRootCont->Release(); piRootCont = NULL; } |
This code performs the following functions:
[Top]
Retrieving the material information from a give material catalog path. The detail about how to browse the catalog please refer to the catalog modeler documentation under the document modeler.
// Get material feature from catalog CATIMaterialFeature *piMaterialFeature = NULL; CATDocument *pMaterialDocument = NULL ; rc = CATDocumentServices::Open(MaterialFilePath, pMaterialDocument); if (pMaterialDocument) { CATIMaterialDocument *pIMaterialDoc = NULL ; rc = pMaterialDocument->QueryInterface(IID_CATIMaterialDocument,(void **) &pIMaterialDoc); if (pIMaterialDoc) { CATILibraryFeature *pILibraryFeature = NULL ; rc = pIMaterialDoc->GetMaterialLibrary(&pILibraryFeature); if (pILibraryFeature) { int NbFamily = pILibraryFeature->GetFamilyCount(); // Get the first family feature CATIFamilyFeature * pIFamilyFeature = NULL ; if (NbFamily >= 1) pIFamilyFeature = pILibraryFeature->GetFamily(1); if (pIFamilyFeature) { // Get the first material of the first family feature piMaterialFeature = pIFamilyFeature->GetMaterial(1); pIFamilyFeature->Release(); pIFamilyFeature = NULL; } pILibraryFeature->Release(); pILibraryFeature = NULL; } pIMaterialDoc->Release(); pIMaterialDoc = NULL; } } |
[Top]
Creating the structure plate with thickness, orientation and material attributes. The same SetSupport, SetThickness, SetInternalOffset and SetMaterial methods can be used to edit an existing plate also, and the compute method does not needed to use when editing the plate. The compute method is only useful when creating an empty plate.
// --------------------------------------------------------- // // Get factory pointer from the root product // // --------------------------------------------------------- // CATIStructureFactory *piFactory = NULL; piProductOnRoot->QueryInterface(IID_CATIStructureFactory, (void**) &piFactory); if (piFactory) { CATIStructurePlate *pFlatPlate = NULL; //Create empty plate rc= piFactory->CreatePlate(&pFlatPlate); //Set Support pFlatPlate ->SetSupport(piSupport); //Set Thickness pFlatPlate ->SetThickness(Thickness); //Set Offset pFlatPlate ->SetInternalOffset(Offset); //Set Material pFlatPlate ->SetMaterial(piMaterialFeature); //Compute pFlatPlate ->Compute(); } |
[Top]
Creating the structure member form two given points with angle and material attributes. The ReplaceMemberSection, SetCurrentSetPoint, SetAngle and SetMaterial methods can be used to edit an existing member object, and the compute does not needed to use when editing the member. The compute, SetSection, SetStartCoord and SetEndCoord methods are only useful when creating an empty member.
CATUnicodeString AnchorName = "catStrTopLeft"; double Angle = 0.0; CATIStructureMember *piStraightMember1 = NULL; CATMathPoint PointStart1(1700.,-400.0,0.0); CATMathPoint PointEnd1(100.0,-400.0,0.0); //Create empty straight member rc = piFactory->CreateMember(&piStraightMember1); if (SUCCEEDED(rc) && piStraightMember1) { //Set section piStraightMember1->SetSection(SectionDoc); //Set start point piStraightMember1->SetStartCoord(PointStart1); //Set end point piStraightMember1->SetEndCoord(PointEnd1); //Set anchor point piStraightMember1->SetCurrentSetPoint(AnchorName); //Set Angle piStraightMember1->SetAngle(Angle); //Set Material piStraightMember1->SetMaterial(piMaterialFeature); //Compute rc = piStraightMember1->Compute(); } |
[Top]
Creating the structure member form a given support with angle and material attributes. The ReplaceMemberSection, SetCurrentSetPoint, SetAngle, SetMemberSupport and SetMaterial methods can be used to edit an existing member object, and the compute does not needed to use when editing the member. The compute and SetSection methods are only useful when creating an empty member.
CATUnicodeString AnchorName = "catStrTopLeft"; double Angle = 0.0; CATIStructureMember *piCurvedMember= NULL; //Create a curved member rc = piFactory->CreateMember(&piCurvedMember); CATISpecObject* piSketchMember = NULL; rc = spSketchMember ->QueryInterface(IID_CATISpecObject,(void**) &piSketchMember); if(piSketchMember) { //Set Support piCurvedMember->SetMemberSupport(piSketchMember); //Set Section piCurvedMember->SetSection(SectionDoc); //Set Anchor point piCurvedMember->SetCurrentSetPoint(AnchorName); //Set Angle Angle = 6.2831853/4; piCurvedMember->SetAngle(Angle); //Set Material piCurvedMember->SetMaterial(piMaterialFeature); //Compute rc = piCurvedMember->Compute(); } |
[Top]
Never forget to delete a created session and save the opened documents after the usage .
// --------------------------------------------------------- // // Save all the open document and delete the session. // // --------------------------------------------------------- // rc = CATDocumentServices::SaveAs(*pDoc,TargetFilePath); rc = ::Delete_Session("CAA2_Sample_Session"); |
[Top]
This use case has demonstrated how to use the Structure interfaces to create the structure objects with proper attribute value. Specifically, it has illustrated:
[Top]
[1] | Building and Launching a CAA V5 Use Case |
Version: 1.1 [February 2004] | Retrieving Project Resource Setting Added |
Version: 1.0 [December 2003] | Document created |
[Top] |
Copyright © 2003, Dassault Systèmes. All rights reserved.