Difference between pages "CleanOGS" and "ClosestPoints"
From scripting
(Difference between pages)
(Created page with " Sub CleanOGS(CurOGS As OrderedGeometricalSet) Dim SecondPart As Part Set SecondPart = GetContainingPart(CurOGS) If CATIA.ActiveDocument.Selection.Count <> 0 Then CATI...") |
(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...") |
||
Line 1: | Line 1: | ||
− | Sub | + | |
− | Dim | + | 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 | |
− | Next | + | 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 | End Sub | ||
[[Category:CATIA DP VB]] | [[Category:CATIA DP VB]] |
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