Generative Shape Design

Creating a Join Surface


This macro shows how to create geometry from existing geometry in a CATPart document.

The macro opens a CATIA Part Document and creates a Join surface using pre-existing geometry (Fill and Extrude).

CAAGsiCreateJoinSurface is launched in CATIA [1]. No open document is needed.

CAAGsiCreateJoinSurface.CATScript is located in the CAAScdGsiUseCases module.  Execute macro (Windows only).

 

CAAGsiCreateJoinSurface includes five steps:

  1. Opening the Part Document 
  2. Retrieving the Current Open Body
  3. Creating References for Oobjects Used as Input for the Join
  4. Creating the Join
  5. Setting the Created Join as the Current Working Object
  6. Updating the Part Document

Opening the Part Document  

 ' Opening a CATIA Part document  : CAAGsiCreateJoinSurface.CATPart 
  Dim sDocPath As String
  sDocPath=CATIA.SystemService.Environ("CATDocView")

  Dim oPartDocument As PartDocument
  Set oPartDocument = CATIA.Documents.Open(sDocPath & "\online\CAAScdGsiUseCases\samples\CAAGsiCreateJoinSurface.CATPart")

Opens the starting CATIA Part document that is used for creating new wireframe and surface objects (In this test case a join).

Retrieving the Current Open Body

 ' Retrieving the active OpenBody 
  Dim hybridBodies1 As HybridBodies
  Set hybridBodies1 = oPartDocument.Part.HybridBodies

  Dim OpenBody1 As HybridBody
  Set OpenBody1 = hybridBodies1.Item("Open_body.2")

Retrieves the OpenBody containing initial objects. It  will be re-used for creating the  Join 

Creating References for Objects Used as Input for the Join

 ' Creating a reference for the Fill.1 object  
  Dim hybridShapeFill1 As HybridShape
  Set hybridShapeFill1 = OpenBody1.HybridShapes.Item("Fill.1")

  Dim reference1 As Reference
  Set reference1 = oPartDocument.Part.CreateReferenceFromObject(hybridShapeFill1)

' Creating a reference for the Extrude.1 object 
  Dim hybridShapeExtrude1 As HybridShape
  Set hybridShapeExtrude1 = OpenBody1.HybridShapes.Item("Extrude.1")

The Fill and the Extrude surfaces used as input for the Join, are converted into reference.

This operation is required in order to use the objects as input for the Join, all objects used as input in IDL method interfaces are to be converted as references and passed in creation methods .

Creating the Join 

' Retrieving Wireframe and Shape Design Factory 
  Dim hybridShapeFactory1 As Factory
  Set hybridShapeFactory1 = oPartDocument.Part.HybridShapeFactory

' Creating a Join (also named assemble) between Fill.1 and Extrude.1 
  Dim hybridShapeAssemble1 As HybridShapeAssemble
  Set hybridShapeAssemble1 = hybridShapeFactory1.AddNewJoin(reference1, reference2)
' Inserting the join in the current OpenBody 
  OpenBody1.AppendHybridShape hybridShapeAssemble1

The Method AddNewJoin is a method of the HybridShapeFactory IDL Interface

Once created,  the join has to be inserted  in an OpenBody. In the test case,  the OpenBody containing the input geometry is re-used. . 
Note : A new OpenBody should have been  created in order to insert the join in a separate OpenBody.

Setting the Created Join as the Current Working Object 

 ' Making Join as active object in CATIA Part  
  oPartDocument.Part.InWorkObject = hybridShapeAssemble

Updating the Part Document

 ' Updating CATIA Part Document  
  oPartDocument.Part.Update

The Part has to be updated to  generate  the geometrical representation of the created objects. 
Once this done , the updated objects are visible in the 3D window and in the specification tree 
Note: It is recommended to launch the Part update once all new objects have been created and inserted in an OpenBody

[Top]


In Short

This use case has shown how to create geometry in a Macro starting from existing geometry in a CATPart.

[Top]


References

[1] Replaying a Macro
[2] Hybrid Shapes Automation Objects

[Top]


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