Equipment & Systems Engineering |
Electrical Harness Installation |
Managing a Multi Branchable Bundle SegmentHow to create and manage a multi branchable bundle segment |
Use Case |
AbstractThis article discusses the CAAEhiCreateMultiBranchableBundleSegment use case. This use case explains how to create a geometrical bundle, a multi branchable bundle segment, and how to manage a multi branchable bundle segment, particularly adding or removing a branch, defining the route of each bundle segment belonging to the multi branchable bundle segment. |
This use case is intended to show you how to create geometrical bundle and a multi branchable bundle segment, how to manage this multi branchable bundle segment.
Following operations are detailed is this use case:
[Top]
CAAEhiCreateMultiBranchableBundleSegment is a use case of the CAAElecHarnessItf.edu framework that illustrates the ElecHarnessItf framework capabilities.
[Top]
The goal of CAAEhiCreateMultiBranchableBundleSegment is to create a geometrical bundle in a new CATProduct document. Multi branchable bundle segments are created under geometrical bundle.
[Top]
To launch CAAEhiCreateMultiBranchableBundleSegment, you will need to set up the build time environment, then compile CAAEhiCreateMultiBranchableBundleSegment.cpp along with its prerequisites, set up the run time environment, and then execute the sample. This is fully described in the referenced article [2].
To launch the use case, execute the following command:
mkrun -c "CAAEhiCreateMultiBranchableBundleSegment PathDir Main GbnName MultiBnsName"
[Top]
CAAEhiCreateMultiBranchableBundleSegment code is located in the CAAEhiCreateMultiBranchableBundleSegment.m use case module of the CAAElecHarnessItf.edu framework:
Windows | InstallRootDirectory/CAAElecHarnessItf.edu/ CAAEhiCreateMultiBranchableBundleSegment.m |
Unix | InstallRootDirectory\CAAElecHarnessItf.edu\ CAAEhiCreateMultiBranchableBundleSegment.m |
where InstallRootDirectory
is the root directory of your CAA V5
installation. It is made of a unique source file named CAAEhiCreateMultiBranchableBundleSegment.cpp.
[Top]
There are six main logical steps in CAAEhiCreateMultiBranchableBundleSegment:
We will now comment each of those sections by looking at the code.
[Top]
Once the current session has been created, the CATProduct document is created into the session . pGbnDoc is a pointer to this document.
The root product of the document is retrieved . piRootProduct is a CATIProduct handle to the root product .
Methodology describing how to create a CATProduct document and how to retrieve the root product is described in [1].
[Top]
... CATIEleDocServices * piElecDocServices = NULL; rc = pDoc->QueryInterface(IID_CATIEleDocServices,(void**) &piElecDocServices ); if ( SUCCEEDED(rc) && piElecDocServices ) { rc = piElecDocServices->Initialize(); } ... |
Initializing the electrical environment is mandatory to enable access to electrical objects or electrical attributes .
[Top]
Geometrical Bundle is created using CATEhiFactory interface on root product piGbnRootProduct.
... CATIEhiGeoBundle * piGeoBundle = NULL; // the geometrical bundle // CATIEhiFactory * piEhiFactory = NULL; // the factory // rc = piGbnRootProduct->QueryInterface(IID_CATIEhiFactory,(void**) &piEhiFactory ); // ... rc = piEhiFactory->CreateGeometricalBundle(&piGeoBundle); ... |
piGeoBundle is the pointer to geometrical bundle.
[Top]
First step is the creation of multi branchable bundle segment part.
A new CATPart document is created and added into the product structure. After its creation, the multi branchable bundle segment contains one branchable.
For each branch, a bundle segment is created.
... CATIEhiMultiBranchable * piMultiBranchable = NULL; ... rc = piGeoBundle->CreateMultiBranchable (& piMultiBranchable ); ... |
piMultiBranchable is a pointer on the multi brancahble bundle segment.
Second step is the creation of the branches of the multi branchable bundle segment .
Two branches are successively created :
... CATIEhiBranchable* piNewBranchable=NULL; rc = piMultiBranchable->AddBranchable(&piNewBranchable); ... |
After the last call to AddBranchable, the multi branchable contains three branchables.
Third step is the retrieving of branchables of the multi branchable
Three branchables are retrieved from the multi branchable :
... CATListValCATBaseUnknown_var* pListBranchable = NULL; rc = piMultiBranchable->ListBranchables(&pListBranchable); ... CATIEhiBranchable * piBranchable1 = NULL; CATIEhiBranchable * piBranchable2 = NULL; CATIEhiBranchable * piBranchable3 = NULL; rc = (*pListBranchable)[1]->QueryInterface(IID_CATIEhiBranchable,(void**) &piBranchable1); ... rc = (*pListBranchable)[2]->QueryInterface(IID_CATIEhiBranchable,(void**) &piBranchable2); ... rc = (*pListBranchable)[3]->QueryInterface(IID_CATIEhiBranchable,(void**) &piBranchable3); ... |
Fourth step is the definition of bundle segment computation parameters .
Bundle segment centre curve is computed according geometrical parameters ( minimum bend radius, constraint points, tangency constraints ) and physical parameter ( gravity)
Two design methodologies are available : distributed slack or length mode.
Following attributes have to be defined :
Branchable 1 is created with Slack mode.
... CATUnicodeString mode="Slack"; double slack=2; double length=0.; double bend_radius=15.; double diameter = 3.; rc = SetBranchableAttributes ( piBranchable1, mode, slack, length, bend_radius, diameter ); ... |
Branchable 2 is created with slack mode.
... mode="Slack"; slack = 1.5; length = 0.; bend_radius = 12.; diameter = 2.; rc = SetBranchableAttributes ( piBranchable2, mode, slack, length, bend_radius, diameter ); ... |
Branchable 3 is created with slack mode.
... mode="Slack"; slack = 1; length = 0.; bend_radius = 25.; diameter = 5.; rc = SetBranchableAttributes ( piBranchable3, mode, slack, length, bend_radius, diameter ); ... |
CATIElecAttrAccess interface is used in SetBranchableAttributes ( internal method ) to define bundle segment attribute values.
... HRESULT SetBranchableAttributes ( CATIEhiBranchable * piBranchable, CATUnicodeString & mode, double & slack, double & length, double & bend_radius, double & diameter ) { HRESULT rc = E_FAIL; // if (!piBranchable) return rc; // pointer not valuated : exit E_FAIL if ( mode != "Slack" && mode != "Length" && mode != "Bend" ) return rc; // invalid mode : exit E_FAIL // CATBaseUnknown * pCurve = NULL; rc = piBranchable->GetElecCurve(&pCurve); if (FAILED(rc) || (NULL==pCurve)) return E_FAIL; // CATIElecAttrAccess * piElecAttr = NULL; rc = pCurve->QueryInterface(IID_CATIElecAttrAccess,(void**) &piElecAttr ); pCurve->Release(); pCurve=NULL; if (FAILED(rc) || (NULL==piElecAttr)) return E_FAIL; // CATUnicodeString attribute; // --- set build mode attribute = "Elec_Creation_Mode"; rc = piElecAttr->Set(attribute,mode); if (FAILED(rc)) { piElecAttr->Release(); piElecAttr=NULL; return rc; } // --- build mode = "Slack" : set slack if ( mode == "Slack" ) { attribute = "Elec_Di_Slack"; rc = piElecAttr->Set(attribute,slack); if (FAILED(rc)) { piElecAttr->Release(); piElecAttr=NULL; return rc; } } // double val; // --- build mode = "Length": set length if ( mode == "Length" ) { val = length * 0.001; attribute = "Elec_Length"; rc = piElecAttr->Set(attribute,val); if (FAILED(rc)) { piElecAttr->Release(); piElecAttr=NULL; return rc; } } // --- set bend radius attribute = "Elec_Bend_Radius"; val = bend_radius * 0.001; rc = piElecAttr->Set(attribute,val); // piElecAttr->Release(); piElecAttr=NULL; if (FAILED(rc)) return rc; // // --- set diameter value CATListValCATBaseUnknown_var * pListOfBns = NULL; rc = piBranchable->ListBundleSegments ( &pListOfBns ); if (SUCCEEDED(rc)) { int nb_bns = pListOfBns?pListOfBns->Size():0; for ( int i=1; i<=nb_bns; i++ ) { if (NULL_var != (*pListOfBns)[i]) { rc = (*pListOfBns)[i]->QueryInterface(IID_CATIElecAttrAccess,(void**)&piElecAttr); if (SUCCEEDED(rc) && (NULL!=piElecAttr)) { attribute = "Elec_Diameter"; val = diameter * 0.001; rc = piElecAttr->Set(attribute,val); piElecAttr->Release(); piElecAttr=NULL; if (FAILED(rc)) break; } } } } delete pListOfBns; pListOfBns=NULL; // return rc; } ... |
Fifth step is the definition of bundle route.
Using CATIGSMFactory, points are created in bundle segment part ( points coordinates are given in MKS unit )
EhiRouteCurve is an sample internal method used to create points and add point to bundle segment curve. Input of method is the bundle segment and the coordinates of the points defining bundle segment route.
For example, here is the code to define the route of Branchable 1 :
... rc = piBranchable1->GetElecCurve(&pRoute); rc = pRoute->QueryInterface(IID_CATIGSMSpline,(void**)&pGSMSpline); // int nb_point = 2; double points[9]; // +- P1 points[0]=0.; points[1]=0; points[2]=0.; // // +- P2 points[3]=0.; points[4]=200.; points[5]=0.; rc = EhiRouteCurve (pGSMSpline, nb_point, points ); ... |
Bundle segment curve is retrieved using CATIEhiBranchable::GetElecCurve and points are added to curve with CATIGSMSpline::AddPoint
... // HRESULT EhiRouteCurve ( CATIGSMSpline* pGSMSpline, int nb_point, double* point_coord ) { // HRESULT rc = E_FAIL; // if (!pGSMSpline) return rc; // pointer not valuated : exit E_FAIL if ( nb_point < 2 ) return rc; // number of points < 2 : exit E_FAIL; // // // -- retrieving container CATIContainer_var spCont; // the container CATISpecObject_var spObj = pGSMSpline; if ( NULL_var != spObj ) spCont = spObj->GetFeatContainer(); // // -- retrieving factories : // - litteral feature factory // - GSM factory CATICkeParmFactory_var spCKEfacto = spCont; // litteral feature factory CATIGSMFactory_var spGSMfacto = spCont; // GSM factory if ( NULL_var == spCKEfacto || NULL_var == spGSMfacto ) { return rc; // cannot retrieve factories : exit E_FAIL } // -- create and add points to curve // CATICkeParm_var X; CATICkeParm_var Y; CATICkeParm_var Z; CATIGSMPointCoord_var spPoint; // for ( int i=1; i<=nb_point; i++ ) { // double unit = 0.001; double Px = unit * point_coord[ 3*(i-1)] ; double Py = unit * point_coord[1+3*(i-1)] ; double Pz = unit * point_coord[2+3*(i-1)] ; // X = spCKEfacto->CreateLength ( "X", Px ); Y = spCKEfacto->CreateLength ( "Y", Py ); Z = spCKEfacto->CreateLength ( "Z", Pz ); // spPoint = spGSMfacto->CreatePoint(X,Y,Z); if ( NULL_var != spPoint ) // --- point created { CATIGSMProceduralView_var(spPoint)->InsertInProceduralView(); CATISpecObject_var (spPoint)->Update(); // compute point geometry // --- add constraint point to electrical curve pGSMSpline->Add(spPoint); } } // // -- update curve geometry spObj->Update(); // rc = S_OK; // return rc; // exit S_OK; } ... |
Sixth step is the computation of bundle segment representation.
CATIEhiGeoBundle::ComputeMultiBranchable is used to compute bundle segment shape ( part design RIB ). This method may be used to re-compute shape after parameter modification.
... // + compute multi branchable // rc = piGeoBundle->ComputeMultiBranchable ( piMultiBranchable ); ... |
[Top]
Some methods of CATIEhiBranchable interface are called in the sample, for example GetMultiBranchable which returns the multi branchable from a branchable, GetElecCurve which returns the electrical curve from a branchable or ListBundleSegments which returns the list of bundle segments contained in a branchable.
... CATIEhiMultiBranchable* piMultiBranchableRead=NULL; rc = piBranchable1->GetMultiBranchable(&piMultiBranchableRead); ... |
Then, the method RemoveBranchable of CATIEhiMultiBranchable is used to delete the third branch of the multi branchable.
... rc = piMultiBranchable->RemoveBranchable(piBranchable3); ... |
[Top]
The multi branchable bundle segement is saved first.
... CATIProduct_var spMultiBranchableI = piMultiBranchable; CATIProduct_var spMultiBranchableR = spMultiBranchableI->GetReferenceProduct(); CATILinkableObject_var spLinkable=spMultiBranchableR; CATDocument * pMultiBnsPartDoc = spLinkable->GetDocument(); rc = CATDocumentServices::SaveAs (*pMultiBnsPartDoc , PathOutput+MultiBns1File ); ... |
Then, the geometrical bundle and the main document are saved.
... rc = CATDocumentServices::SaveAs (*pGbnDoc , PathOutput+GbnFile ); rc = CATDocumentServices::SaveAs (*pMainDoc , PathOutput+MainFile ); ... |
Document is removed and session is deleted before exit.
... rc = CATDocumentServices::Remove(*pGbnDoc); ... rc = ::Delete_Session(sessionName); ... |
[Top]
This use case has demonstrated how to create and manage a multi branchable bundle segment
Following operations have been detailed is this use case :
Initialize
method
of CATIEleDocServices.CreateGeometricalBundle
method of CATIEhiFactory.CreateMultiBranchable
of CATIEhiGeoBundle.AddBranchable
of CATIEhiMultiBranchable.ComputeMultiBranchable
of CATIEhiGeoBundle.RemoveBranchable
of CATIEhiMultiBranchable..[Top]
[1] | Adding Components to a Product Structure |
[2] | Building and Launching a CAA V5 Use Case |
[Top] |
Version: 1 [Jan 2003] | Document created |
[Top] |
Copyright © 2002, Dassault Systèmes. All rights reserved.