Product Structure

Adding an External Component


This macro shows you how to create a simple product structure that imports an existing Part from an external Part document. It assumes that the CATDocView has been initialized so that it references the path leading to the part document, CAAPstHull.CATPart. 

Here is an image of the resulting product structure:

 

CAAPstAddExternalComponent is launched in CATIA [1]. No previously opened document is needed.

CAAPstAddExternalComponent.CATScript is located in the CAAScdPstUseCases module. Execute macro (Windows only).

CAAPstAddExternalComponent includes three steps:

  1. Prolog
  2. Open the Part Document
  3. Import the Part Document as a Product in the Collection of Products

Prolog

  ...
      'Create a new product document object by adding a document with the Product
      'type to the document collection of the CATIA application. 
      Dim oProductDoc As Document
      Set oProductDoc = CATIA.Documents.Add("Product") 

      'Retrieve the root product.
      Dim oRoot As Product
      Set oRoot = oProductDoc.Product

      'Retrieve the root product collection of products.
      Dim oRootCol As Products
      Set oRootCol = oRoot.Products      
  ...

A new Product document is created using the Add method of the documents collection (Documents object). Next, the root product of the document is retrieved using the Product property of the ProductDocument object.  Finally, the product's collection is retrieved using the Products property of the Product object.

Open the Part Document

  ...
      'Open the Part Document
      Dim oPartDoc As Document
      Set oPartDoc = CATIA.Documents.Open(sDocPath & "CAAPstHull.CATPart")
  ...

The Part document to be imported is opened using the Open method of the Documents object.

Import the Part Document as a Product in the Collection of Products

  ...
      'Add a new component from the already opened part document.
      Dim oNewComponent As Product
      Set oNewComponent = oRootCol.AddExternalComponent(oPartDoc)
  ...

A new part is imported under the product collection using the AddExternalComponent method of the Products object.

[Top]


In Short

This use case has shown how to create a simple product structure that imports an existing Part from an external Part document. Specifically, it has illustrated using:

[Top]


References

[1] Replaying a macro
[Top]

Copyright © 2001, Dassault Systèmes. All rights reserved.