 |
CAASfdMidDist-MidDist includes five steps:
- Prolog
- Retrieving the Factory and Two Managers (Contour
Manager and Position Strategy Manager)
- Selecting the Contour and Set Contour Parameters
- Defining the Position Strategy and Preparing Lists
for U References and V References
- Creating a Standard Opening by Setting PositionStrategyParms

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)
...
|
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")
...
|
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
...
|
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
...
|
- An intermediate list for U references is created (URefListint).
- Inside the For loop, this intermediate list will hold first two
U references. The For loop moves in step of 2.
- SetPosParamData Method is called on PositonStrategyParams to set
the data
- Create Standard Opening by defining required parameters. It is called
on Factory.
- 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
...
|
|