Part Design

Creating Pocket


This macro shows you how to create a pocket from a sketch.

This macro opens the CAAPriPocket.CATPart document that contains a pad with a sketch on one of its faces. 
 It creates Pocket object from a Sketch object with a ShapeFactory method and a update it.

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

CAAPriPocket.CATScript is located in the CAAScdPriUseCases module. Execute macro (windows only).

 

CAAPriPocket includes the following steps:

  1. Prolog
  2. Creating the Pocket
  3. Modifying the Pocket First Limit

Prolog

The macro first loads CAAPriPocket.CATPart that contains a sketch: Sketch.2 

This object have been created with the Sketcher workbench. 

  ...
' ------------
' Get the part
' ------------
Dim oPart As Part
Set oPart = CATIA.ActiveDocument.Part

' ------------
' Get the part body in the part
' ------------
Dim oBody As Body
Set oBody = oPart.Bodies.Item  ( "PartBody" ) 

' ------------
' Get the sketch in the body
' ------------
Dim oSketch As Sketch
Set oSketch = oBody.Sketches.Item  ( "Sketch.1" ) 
   ...

Once the part document has been loaded, the oPart, oBody and oSketch variables are declared to receive the instance of the part, the partbody and the sketch.

Creating the Pocket

...
' ------------
' Create the pocket with a default first limit
' ------------
MsgBox "Click OK to create the pocket."
Dim oPocket As Pocket
Set oPocket= oPart.ShapeFactory.AddNewPocket    ( oSketch, 20.000000 ) 

' ------------
' Update the part
' ------------
oPart.Update 
...

The Pocket object is created from the oSketch object with a default first limit of 20mm. The Pocket object is created using the AddNewPocket method of the ShapeFactory object.

The Pocket is then updated with the following result.

Modifying the pad first limit

...
' ------------
' Define the pocket first limit
' ------------
MsgBox "Click OK to set the pocket first limit to 30mm."
oPocket.FirstLimit.Dimension.Value = 30.000000

' ------------
' Update the part
' ------------
oPart.Update 
  ...

The FirstLimit property of the Pocket object is set to 30mm.

[Top]


In Short

This use case has shown how to create and modify a pocket using macros.

[Top]


References

[1] Replaying a macro
[Top]

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