FilletStabilizer

From scripting
Jump to: navigation, search


Function FilletStabilizer(CurveBefore As Variant, CurveAfter As Variant, InPlane As Variant, FilletRad As Double, GeomSet As HybridBody, SurfName As String) As Boolean
FilletStabilizer = True
 
Dim MyPart As Part
Set MyPart = CATIA.ActiveDocument.Part
Dim MyHSFactory As HybridShapeFactory
Set MyHSFactory = MyPart.HybridShapeFactory
 
Dim FilletObj As HybridShapeCircleBitangentRadius
Set FilletObj = MyHSFactory.AddNewCircleBitangentRadius(CurveBefore, CurveAfter, Nothing, FilletRad, 1, 1)
FilletObj.DiscriminationIndex = 1
'DestSet.AppendHybridShape FilletObj
FilletObj.BeginOfCircle = 2
FilletObj.SetLimitation 2
FilletObj.TrimMode = 0
'FilletObj.EndAngle = 180
'FilletObj.StartAngle = 0
GeomSet.AppendHybridShape FilletObj
FilletObj.Name = SurfName & "Fillet_edge_line"
 
Dim FC As Boolean
FC = False
 
Dim SuperMatrix
ReDim SuperMatrix(15)
SuperMatrix(0) = Array(1, 1, 1, 1)
SuperMatrix(1) = Array(-1, 1, 1, 1)
SuperMatrix(2) = Array(1, -1, 1, 1)
SuperMatrix(3) = Array(-1, -1, 1, 1) '
SuperMatrix(4) = Array(1, 1, -1, 1)
SuperMatrix(5) = Array(-1, 1, -1, 1)
SuperMatrix(6) = Array(1, -1, -1, 1)
SuperMatrix(7) = Array(-1, -1, -1, 1) '
SuperMatrix(8) = Array(1, 1, 1, -1)
SuperMatrix(9) = Array(-1, 1, 1, -1)
SuperMatrix(10) = Array(1, -1, 1, -1)
SuperMatrix(11) = Array(-1, -1, 1, 1) '
SuperMatrix(12) = Array(1, 1, -1, -1)
SuperMatrix(13) = Array(-1, 1, -1, -1)
SuperMatrix(14) = Array(1, -1, -1, -1)
SuperMatrix(15) = Array(-1, -1, -1, -1)
 
Dim FCCounter As Integer
FCCounter = 0
While FC = False And FCCounter < 16
    FC = FilletCheck(FilletObj, SuperMatrix(FCCounter)(0),  SuperMatrix(FCCounter)(1),SuperMatrix(FCCounter)(2), SuperMatrix(FCCounter)(3))
    FCCounter = FCCounter + 1
Wend
 
If FC = False Then
    FilletStabilizer = False
    Exit Function
End If
  
'FilletObj.Support = inplane
 
MyPart.InWorkObject = FilletObj
MyPart.UpdateObject FilletObj
 
End Function