FurthestPoints

From scripting
Jump to: navigation, search
Function FurthestPoints(Point1A As Variant, Point2A As Variant, Point1B As Variant) As Variant
 
Dim SmallestDist As Double
SmallestDist = 0
Dim WinHH, WinJJ As Integer
WinHH = 0: WinJJ = 0
 
CATIA.ActiveDocument.Part.UpdateObject Point1A
CATIA.ActiveDocument.Part.UpdateObject Point2A
 
Dim MeasuredDist() As Double
ReDim MeasuredDist(1)
Dim CMeas1
Set CMeas1 = TheSPAWorkbench.GetMeasurable(Point1A)
MeasuredDist(0) = CMeas1.GetMinimumDistance(Point1B)
Dim CMeas2
Set CMeas2 = TheSPAWorkbench.GetMeasurable(Point2A)
MeasuredDist(1) = CMeas2.GetMinimumDistance(Point1B)
 
For cM = 0 To 1
    If MeasuredDist(cM) > SmallestDist Then
        SmallestDist = MeasuredDist(cM)
        WinNum = cM
    End If
Next cM
 
If WinNum = 0 Then
    Set FurthestPoints = Point1A
ElseIf WinNum = 1 Then
    Set FurthestPoints = Point2A
End If
End Function