ClosestPoints

From scripting
Revision as of 05:14, 22 April 2017 by Nickpisca (talk | contribs) (Created page with " Sub ClosestPoints(Point1 As Variant, Point2 As Variant) Dim SmallestDist As Double SmallestDist = 100000000 Dim WinHH, WinJJ As Integer WinHH = 0: WinJJ = 0 For...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Sub ClosestPoints(Point1 As Variant, Point2 As Variant)
 
Dim SmallestDist As Double
SmallestDist = 100000000
Dim WinHH, WinJJ As Integer
WinHH = 0: WinJJ = 0
 
For HH = 0 To 1
    For jj = 0 To 1
        Point1.Ratio.Value = HH
        Point2.Ratio.Value = jj
        CATIA.ActiveDocument.Part.UpdateObject Point1
        CATIA.ActiveDocument.Part.UpdateObject Point2
        
        Dim MeasuredDist As Double
        Dim CMeas
        Set CMeas = TheSPAWorkbench.GetMeasurable(Point1)
        MeasuredDist = CMeas.GetMinimumDistance(Point2)
        
        If MeasuredDist < SmallestDist Then
            SmallestDist = MeasuredDist
            WinHH = HH
            WinJJ = jj
        End If
    Next jj
Next HH
 
Point1.Ratio.Value = WinHH
Point2.Ratio.Value = WinJJ
End Sub