Structure Functional Design

Creating Standard Openings


This macro shows you how to create a standard opening on an SDD plate. Here we will use "Rect" profile and the MidDist-MidDist strategy.

Note: Scripts for creation of Standard Openings using other positioning strategies are also provided in the CAAScdSfdUseCases/macros directory:

  • CAASfdHalfHeight_MidDist.CATScript
  • CAASfdHalfHeight_Offset.CATScript
  • CAASfdMidDist_Offset.CATScript
  • CAASfdOffset_Offset.CATScript

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

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

CAASfdMidDist-MidDist includes five steps:

  1. Prolog
  2. Retrieving the Factory and Two Managers (Contour Manager and Position Strategy Manager)
  3. Selecting the Contour and Set Contour Parameters
  4. Defining the Position Strategy and Preparing Lists for U References and V References
  5. Creating a Standard Opening by Setting PositionStrategyParms

Prolog

Opens in CATIA the CAASfdCreateStdOpening.CATPart located in the samples directory.

Sub CATMain()

  Dim Part1 As Part
  Set Part1 = CATIA.ActiveDocument.Part
  Dim plate As SfmSuperPlate
  Set plate = Part1.FindObjectByName("Deck_002")
  Dim plateref As Reference
  Set plateref = Part1.CreateReferenceFromObject(plate)
  ...

Retrieving the Factory and Two Managers (Contour Manager and Position Strategy Manager)

First retrieve the factory from the part. Then retrieve the SfmOpeningContoursMgr and SfmPositioningStrategyManager objects.

  ...
  Dim Factory As SfmFunctionFactory
  Set Factory = Part1.GetCustomerFactory("SfmFunctionFactory")

  Dim ObjSfmContourMgr As SfmOpeningContoursMgr
  Set ObjSfmContourMgr = Factory.GetOpeningMgr(Part1, "SfmOpeningContoursMgr")
 
  Dim ObjSfmPosStrategyMgr As SfmPositioningStrategyManager
  Set ObjSfmPosStrategyMgr = Factory.GetOpeningMgr(Part1, "SfmPositioningStrategyManager")
  ...

Selecting the Contour and Set Contour Parameters

Use ObjSfmContourMgr to get the list of the entire contour Names available. Out of the list "Sfm_Rect" is selected. To set its parameters, use the GetStdOpeningContourParams method.

  ...
  'Define the Contour

  Dim oListContourNames() As Variant
  ObjSfmContourMgr.GetAvailableStdOpeningContours oListContourNames

  Dim NbOfContour As Long
  NbOfContour = UBound(oListContourNames)

  'Display List of contours
  Dim i As Integer
  For i = 0 To NbOfContour
    MsgBox oListContourNames(i)
  Next

  'Set the Required Contour and Set its Contour Parameters
  Dim oListCkeParms As SfmStandardContourParameters
  Set oListCkeParms = ObjSfmContourMgr.GetStdOpeningContourParams("Sfm_Rect")

  Dim NbOfParam As Long
  NbOfParam = oListCkeParms.Count

  Dim ContourParam As Parameter
  Dim ContourParamName As String

  For i = 1 To NbOfParam
    Set ContourParam = oListCkeParms.Item(i)
    ContourParamName = oListCkeParms.Item(i).Name
    'MsgBox ContourParamName

    If ContourParamName = "Sfm_Width" Then
      ContourParam.ValuateFromString ("1000mm")
    End If
    If ContourParamName = "Sfm_Height" Then
      ContourParam.ValuateFromString ("2000mm")
    End If
    If ContourParamName = "Sfm_CornerRadius" Then
      ContourParam.ValuateFromString ("10mm")
     End If
  Next
  ...

Defining the Position Strategy and Preparing Lists for U References and V References

Use ObjSfmPosStrategyMgr to GetPositioningStrategyParams.

Since MidDist-MidDist strategy is selected, you need to prepare List of U References and V References. Both these lists will contain even number of reference Planes.

  ...
  'Define the Position Strategy
  Dim PositionStrategyParms As SfmStandardPosStrategyParameters
  Set PositionStrategyParms = ObjSfmPosStrategyMgr.GetPositioningStrategyParams("CATSfmPosMidDistMidDist")

  'Prepare a List of U & V Reference
  Dim UrefList As SfmReferences
  Dim Uref1, Uref2, Uref3, Uref4 As Reference
  Set Uref1 = Part1.FindObjectByName("CROSS.95")
  Set Uref2 = Part1.FindObjectByName("CROSS.50")
  Set Uref3 = Part1.FindObjectByName("CROSS.25")
  Set Uref4 = Part1.FindObjectByName("CROSS.40")
  Set UrefList = Factory.SfmReferences
  UrefList.Add Uref1
  UrefList.Add Uref2
  UrefList.Add Uref3
  UrefList.Add Uref4
 
  Dim VrefList As SfmReferences
  Dim Vref1, Vref2 As Reference
  Set Vref1 = Part1.FindObjectByName("LONG.0")
  Set Vref2 = Part1.FindObjectByName("LONG.10")
  Set VrefList = Factory.SfmReferences
  VrefList.Add Vref1
  VrefList.Add Vref2
 
  Dim NbofURef As Long
  NbofURef = UrefList.Count
 
  Dim NbofVRef As Long
  NbofVRef = VrefList.Count
  ...

Creating a Standard Opening by Setting PositionStrategyParms

  1. An intermediate list for U references is created (URefListint).
  2. Inside the For loop, this intermediate list will hold first two U references. The For loop moves in step of 2.
  3. SetPosParamData Method is called on PositonStrategyParams to set the data
  4. Create Standard Opening by defining required parameters. It is called on Factory.
  5. Clear the current intermediate list. It will be populated again with next two elements in next loop.
  ...
  Dim StdOpening As SfmStandardOpening
  Dim URefListint As SfmReferences
  Set URefListint = Factory.SfmReferences

  Dim nUrefCnt As Integer
  For nUrefCnt = 1 To NbofURef Step 2
    If (nUrefCnt + 1) <= NbofURef Then
      URefListint.Add UrefList.Item (nUrefCnt)
      URefListint.Add UrefList.Item (nUrefCnt + 1)
      PositionStrategyParms.SetPosParamData "CATSfmPosMidDistMidDist", 20, URefListint, 1, VrefList, 2
      Set StdOpening = Factory.CreateStandardOpening ("FunctionalOpening", "Sfm_Rect", oListCkeParms, "CATSfmPosMidDistMidDist", PositionStrategyParms, plateref)
      URefListint.ClearList
    End If
  Next

  Part1.Update
  ...

[Top]


In Short

This use case has shown how to create a standard opening using the MidDist-MidDist strategy.


References

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

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