Difference between pages "CleanOGS" and "ClosestPoints"

From scripting
(Difference between pages)
Jump to: navigation, search
(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 CleanOGS(CurOGS As OrderedGeometricalSet)
+
  Dim SecondPart As Part
+
  Sub ClosestPoints(Point1 As Variant, Point2 As Variant)
  Set SecondPart = GetContainingPart(CurOGS)
+
 
  If CATIA.ActiveDocument.Selection.Count <> 0 Then
+
  Dim SmallestDist As Double
    CATIA.ActiveDocument.Selection.Clear
+
  SmallestDist = 100000000
  End If
+
Dim WinHH, WinJJ As Integer
For X = 1 To CurOGS.Bodies.Count
+
  WinHH = 0: WinJJ = 0
    CATIA.ActiveDocument.Selection.Add CurOGS.Bodies.Item(X)
+
 
    CATIA.ActiveDocument.Selection.Delete
+
  For HH = 0 To 1
Next
+
    For jj = 0 To 1
For X = 1 To CurOGS.HybridShapes.Count
+
        Point1.Ratio.Value = HH
    SecondPart.HybridShapeFactory.DeleteObjectForDatum CurOGS.HybridShapes.Item(1)
+
        Point2.Ratio.Value = jj
  Next
+
        CATIA.ActiveDocument.Part.UpdateObject Point1
  For X = 1 To CurOGS.OrderedSketches.Count
+
        CATIA.ActiveDocument.Part.UpdateObject Point2
    CATIA.ActiveDocument.Selection.Add CurOGS.OrderedSketches.Item(X)
+
       
    CATIA.ActiveDocument.Selection.Delete
+
        Dim MeasuredDist As Double
Next
+
        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