Code:
Sub CATMain()
Dim partDocument1 As PartDocument
Set partDocument1 = CATIA.ActiveDocument
Dim Part1 As Part
Set Part1 = partDocument1.Part
Dim shapeFactory1 As ShapeFactory
Set shapeFactory1 = Part1.ShapeFactory
Dim selectionbody As Selection
Set selectionbody = partDocument1.Selection
selectionbody.Clear
Dim InputObject(0)
InputObject(0) = "HybridShape"
Set Bodyforfillet = CATIA.ActiveDocument.Selection
MsgBox "Select Surafece with sharp edges"
Status = Bodyforfillet.SelectElement2(InputObject, "Select Surface with fillets", False) 'Selection
Set bodyname = selectionbody.Item(1).Value
MsgBox bodyname.Name
Dim select_surface As AnyObject
Set select_surface = Bodyforfillet.Item(1).Value
Name = select_surface.Name
Dim Rad As Double
Rad = 0.2
Call Final_Fillet(Part1, select_surface, Rad)
End Sub
Private Function Final_Fillet(Part1 As Part, select_surface As Object, Rad As Double) As AnyObject
Dim Bodyslection As Selection
Set Bodyslection = CATIA.ActiveDocument.Selection
Bodyslection.Search "type=topology.face,sel"
MsgBox Bodyslection.Count2
MsgBox select_surface.Name
Dim Pillows As Integer
Pillows = Bodyslection.Count2
Dim Pillowsref() As Reference
For i = 1 To Pillows
Dim Brep_name As String
Brep_name = Bodyslection.Item(i).Value.Name
Brep_name = Replace(Brep_name, "Selection_", " ")
Brep_name = StrReverse(Brep_name)
For ZZ = 1 To 3 Step 1
ii = InStr(Brep_name, ";")
Brep_name = Right(Brep_name, Len(Brep_name) - ii)
Next
Brep_name = StrReverse(Brep_name)
MsgBox Brep_name
Pillowsref(i) = Part1.CreateReferenceFromBRepName(Brep_name & ");WithTemporaryBody;WithoutBuildError;WithSelectingFeatureSupport;MFBRepVersion_CXR15)", select_surface)
Next
Dim constRadEdgeFillet1 As ConstRadEdgeFillet
Set constRadEdgeFillet1 = shapeFactory1.AddNewSurfaceEdgeFilletWithConstantRadius(Pillowsref(1), 0, 0.2)
For j = 2 To Pillows
constRadEdgeFillet1.AddObjectToFillet Pillowsref(i)
Next
constRadEdgeFillet1.FilletBoundaryRelimitation = 1
constRadEdgeFillet1.EdgePropagation = catTangencyFilletEdgePropagation
constRadEdgeFillet1.FilletBoundaryRelimitation = catConnectFilletBoundaryRelimitation
constRadEdgeFillet1.FilletTrimSupport = catTrimFilletSupport
Bodyslection.Clear
End Function