Structure Detail Design

Editing Openings


Target Icon This macro shows you how to edit opening on an SDD Plate. Here we will modify the creation mode, intersecting element, and direction for already existing openings.

Openings Modified

Information Icon CAASddEditOpening is launched in CATIA [1]. Some documents are needed.
  • CAASddEditOpening.CATScript is located in the CAAScdSddUseCases module. Execute macro (Windows only).
  • The document Product1.CATProduct is located in the CAAScdSddUseCases module in the samples directory. Design_Unit_005.CATPart is linked to the previous document and contains the sketches required for the macro.
  • The CATPart containing the section is located in the samples directory.
CAASddEditOpening includes three steps:
  1. Prolog
  2. Get the Objects of the Three Openings
  3. Edit the Opening Using Opening Objects

Prolog

The macro first loads CAASCH_Detail01.CATProduct that contains three schematic component symbols.

Set documents1 = CATIA.Documents
Set partDocument1 = documents1.Item("Design_Unit_005.CATPart")

Set part1 = partDocument1.Part
 

Get the Objects of the Three Openings

Get the Opening Objects by using the FindObject Method on selection.

'Get the OpeningObject for Opening_038
Dim Opening1 As SfmOpening
Set Opening1 = part1.FindObjectByName("Opening_038")

Dim Sel1 As Selection
Set Sel1 = CATIA.ActiveDocument.Selection
Sel1.Add Opening1

Dim OpeningObject1 As SfmOpening
Set OpeningObject1= Sel1.FindObject("CATIASfmOpening")

'Get the OpeningObject for Opening_040
Dim Opening2 As SfmOpening
Set Opening2 = part1.FindObjectByName("Opening_040")

Dim Sel2 As Selection
Set Sel2 = CATIA.ActiveDocument.Selection
Sel2.Add Opening2

Dim OpeningObject2 As SfmOpening
Set OpeningObject2= Sel2.FindObject("CATIASfmOpening")

'Get the OpeningObject for Opening_043
Dim Opening3 As SfmOpening
Set Opening3 = part1.FindObjectByName("Opening_043")

Dim Sel3 As Selection
Set Sel3 = CATIA.ActiveDocument.Selection
Sel1.Add Opening3

Dim OpeningObject3 As SfmOpening
Set OpeningObject3= Sel3.FindObject("CATIASfmOpening")

Edit the Opening Using Opening Objects

'Get the mode in which Opening_038 and Opening_040 is created
Dim CreationMode1 As Long
CreationMode1 = OpeningObject1.CreationMode
MsgBox CreationMode1

Dim CreationMode2 As Long
CreationMode2 = OpeningObject2.CreationMode
MsgBox CreationMode2

'Get the Intersecting Element for Opening_038
Dim IntersectingElem1 As Reference
Set IntersectingElem1 = OpeningObject1.IntersectingElement

'Modify the creation mode to Sketch Mode for Opening_040.
Then assign a sketch as intersecting element to this opening
OpeningObject2.CreationMode = 1

Set Sketch = part1.FindObjectByName("Sketch.11")
Set sketchref = part1.CreateReferenceFromObject(Sketch)
OpeningObject2.IntersectingElement = sketchref


'Get the current Direction of Opening_043 and then set a new direction
Dim GetDir As Reference
Set GetDir = OpeningObject3.Direction

Set SketchAsDir = part1.FindObjectByName("Sketch.14")
Set PutDir = part1.CreateReferenceFromObject(SketchAsDir)
OpeningObject3.Direction  = PutDir


'GetMathDirection for Opening_043. This will return the direction in Vector Form.

Dim GetMathDir(3)
GetMathDir(3) = OpeningObject3.GetDirection
Dim x1, y1, z1 As Double
x1 = GetMathDir(0)
y1 = GetMathDir(1)
z1 = GetMathDir(2)

part1.Update
  End Icon

[Top]


In Short

This use case has shown how to edit openings.

[Top]


References

[1] Replaying a Macro
[Top]

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