Structure Functional Design

Editing Openings


This macro shows you how to edit openings.

CAASfdEditOpening is launched in CATIA [1]. First open CAASfdEditOpening.CATPart in the samples directory.

CAASfdEditOpening.CATScript is located in the CAAScdSfdUseCases. Execute macro (Windows only).

CAASfdEditOpening includes three steps:

  1. Prolog
  2. Retrieving the Opening Objects
  3. Editing the Opening Objects

Prolog

Opens the CAASfdEditOpening.CATPart in CATIA.

Sub CATMain()
  Dim part1 As Part
  Set part1 = CATIA.ActiveDocument.Part
  ...

Retrieving the Opening Objects

This step describes how to get Structure Functional Modeler factory object.

  ...
  '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")
  ...

Editing the 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

  Dim Sketch As Sketch
  Set Sketch = part1.FindObjectByName("Sketch.11")
  Dim sketchref As Reference
  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

  Dim SketchAsDir As Sketch
  Set SketchAsDir = part1.FindObjectByName("Sketch.14")
  Dim PutDir As Reference
  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
  ...

[Top]


In Short

This use case has shown how to edit openings.


References

[1] Replaying a Macro
[2] Opening an Existing CATIA Document
[Top]

Copyright © 1999-2011, Dassault Systèmes. All rights reserved.