Difference between revisions of "ClosestPoints"

From scripting
Jump to: navigation, search
(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...")
 
(No difference)

Latest revision as of 05:14, 22 April 2017

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