3D PLM PPR Hub Open Gateway |
Product Modeler |
Adding Existing External Components FunctionImporting an existing external component |
Use Case |
AbstractThis article accompanies the AddExternalComponent function found in the CAAPstComponentServices utility program. It explains how to add an existing external component to a product structure. |
This function is intended to help you program importing an existing external component into a product structure. But before we get to the function itself, it is important to get an understanding of the Product Structure model by reading the referenced article [1].
AddExternalComponent is a global function called by the samples found in the CAAProductStructure.edu framework that illustrates ProductStructure framework capabilities.
The goal of AddExternalComponent is to add an existing component to a product structure. Here are its input and output parameters:
INPUT:
*iThisProd
- the importing
CATProduct document's root product*iDocument
- the component
to be importedOUTPUT:
*oNewProduct
- the product instance
of the imported component under iThisProd
AddExternalComponent is a global function that is called from the CAAPstAddComponent [2] and CAAPstMovable [3] use cases. It is not an independently executable sample itself.
[Top]
AddExternalComponent code is located in the CAAPstComponentServices.m shared library of the CAAProductStructure.edu framework:
Windows | InstallRootDirectory/CAAProductStructure.edu/CAAPstComponentServices.m |
Unix | InstallRootDirectory\CAAProductStructure.edu\CAAPstComponentServices.m |
where InstallRootDirectory
is the root directory of your CAA V5
installation. It is made of a unique source file named CAAPstAddServices.cpp.
There are two logical steps in AddExternalComponent:
We will now comment each of these steps by looking at the code.
HRESULT rc = E_FAIL; if ( NULL != iDocument) { // Get RootProduct of the document to import. CATIDocRoots *piDocRootsOnDoc = NULL; rc = iDocument->QueryInterface(IID_CATIDocRoots, (void**) &piDocRootsOnDoc); if ( FAILED(rc) ) { cout << "** QI on CATIDocRoots failed " << endl<< flush; return rc; } CATListValCATBaseUnknown_var *pRootProducts = piDocRootsOnDoc->GiveDocRoots(); CATIProduct_var spRootProduct = NULL_var; if ( NULL != pRootProducts) if (pRootProducts->Size()) { // the root product is first element of // the list of root elements. spRootProduct = (*pRootProducts)[1]; delete pRootProducts; pRootProducts = NULL; } piDocRootsOnDoc->Release(); piDocRootsOnDoc=NULL; |
If the pointer to the document to be imported is valid, we first get a CATIDocRoots
handle on it in order to retrieve its root product using the GiveDocRoots
method. The root product of the document is the first element in the list
returned by this method. Note that if the document to be imported is neither a
CATPart nor a CATProduct document, it will not have a root product.
if (NULL_var != spRootProduct) { // We have the root product from which one // will be agregated in "this" spProduct = iThisProd->AddProduct (spRootProduct); } |
If a root product was actually retrieved from the document to be
imported, we simply execute the AddProduct
method of CATIProduct
in order to create a new product instance of the imported document under the
root product of the importing CATProduct document..
else { CATUnicodeString docName = iDocument-> StorageName(); iThisProd->AddShapeRepresentation(CATUnicodeString("model"), docName); return 3; } |
If the document to be imported is a V4 model, we use the AddShapeRepresentation
method of CATIProduct in order to import this model into the product
structure under the root product. We pass as input the string
"model" and the entire storage path name of the document that we
retrieve using the StorageName
method of CATDocument.
Then, we simply exit the function.
rc = spProduct->QueryInterface(IID_CATIProduct, (void**) &*oNewProduct); |
If we have actually imported a document having a root product, we retrieve the CATIProduct instance of this root product to return to the calling program.
This function has demonstrated how to import an existing document into a product structure Specifically, it has illustrated:
GiveDocRoots
method of CATIDocRootsAddProduct
method of CATIProduct in the case of a CATPart or CATProduct or using
the AddShapeRepresentation
of CATIProduct in the case of
a V4 model.[1] | The Product Structure Model |
[2] | Adding Components to a Product Structure |
[3] | Positioning Products in a Product Structure |
Version: 1 [Apr 2000] | Document created |
[Top] |
Copyright © 2000, Dassault Systèmes. All rights reserved.