Code:
Function oEdgeFillet(oPartInWork As Part, oTargetGeoset As HybridBody, oFirstSurface As Object, iRadius As Integer) As ObjectDim oShapeFactoryEdgeFillet As Factory
Set oShapeFactoryEdgeFillet = oPartInWork.ShapeFactory
Dim TmpSelection
Set TmpSelection = oPartInWork.Parent.Selection
Dim FirstReferenceObjectName
TmpSelection.Clear
TmpSelection.Add oFirstSurface
TmpSelection.Search ("Topology.Edge,sel")
CountEdges = TmpSelection.Count
Dim ShapeEdges(999)
For U = 1 To CountEdges
Set ShapeEdges(U) = TmpSelection.Item(U).Value
Next
Dim FirstReferenceObject As Object
Dim oFirstSurfaceRef As Reference
Set oFirstSurfaceRef = oPartInWork.CreateReferenceFromObject(oFirstSurface)
iii = 1
Do Until Ready = True Or iii = CountEdges
Set FirstReferenceObject = ShapeEdges(iii)
FirstReferenceObjectName = ""
FirstReferenceObjectName = FirstReferenceObject.Name
FirstReferenceObjectName = Replace(FirstReferenceObjectName, "Selection_", "")
FirstReferenceObjectName = StrReverse(FirstReferenceObjectName)
For i = 1 To 3 Step 1
ii = InStr(FirstReferenceObjectName, ";")
FirstReferenceObjectName = Right(FirstReferenceObjectName, Len(FirstReferenceObjectName) - ii)
Next
FirstReferenceObjectName = StrReverse(FirstReferenceObjectName)
Set oFirstReference = oPartInWork.CreateReferenceFromBRepName(FirstReferenceObjectName & ";WithTemporaryBody;WithoutBuildError;WithSelectingFeatureSupport;MFBRepVersion_CXR15", oFirstSurface)
Set oEdgeFillet = oShapeFactoryEdgeFillet.AddNewSurfaceEdgeFilletWithConstantRadius(Nothing, catTangencyFilletEdgePropagation, iRadius)
oEdgeFillet.AddObjectToFillet oFirstReference
oEdgeFillet.EdgePropagation = catTangencyFilletEdgePropagation
oEdgeFillet.FilletBoundaryRelimitation = catConnectFilletBoundaryRelimitation
oEdgeFillet.FilletTrimSupport = catTrimFilletSupport
On Error Resume Next
oPartInWork.UpdateObject oEdgeFillet
If Err <> 0 Then
'TmpSelection.Clear
'TmpSelection.Add oEdgeFillet
'TmpSelection.Delete
Ready = False
Err.Clear
Else
Ready = True
End If
iii = iii + 1
Loop
End Function