I'll help you write a VB macro for CATIA V5 that analyzes faces for circular features. Here's the code:
Sub FindCircularFeatures()
Dim partDoc As PartDocument
Dim part As Part
Dim bodies As Bodies
Dim body As Body
Dim faces As Faces
Dim face As Face
Dim circles As New Collection
' Get active document and part
Set partDoc = CATIA.ActiveDocument
Set part = partDoc.Part
Set bodies = part.Bodies
' Loop through all bodies
For Each body In bodies
Set faces = body.Faces
' Loop through all faces
For Each face In faces
' Check if face is cylindrical or planar
If face.Type = catCylindricalSurface Or face.Type = catPlanarSurface Then
Dim curves As Curves
Set curves = face.Curves
' Loop through curves on the face
Dim curve As Curve
For Each curve In curves
' Check if curve is a circle
If curve.Type = catCircle Then
Dim circle As Circle
Set circle = curve
' Get circle center coordinates
Dim center As Point
Set center = circle.CenterPoint
' Add coordinates to collection
circles.Add Array(center.X, center.Y, center.Z)
End If
Next
End If
Next
Next
' Display results
If circles.Count > 0 Then
MsgBox "Found " & circles.Count & " circular features"
' Print coordinates
Dim i As Integer
For i = 1 To circles.Count
Dim coords As Variant
coords = circles(i)
Debug.Print "Circle " & i & " center: X=" & coords(0) & ", Y=" & coords(1) & ", Z=" & coords(2)
Next
Else
MsgBox "No circular features found"
End If
End Sub
This macro:
- Gets the active part document
- Iterates through all bodies in the part
- Checks each face of each body
- Looks for cylindrical or planar faces that might contain circles
- Analyzes the curves on those faces to find circles
- Stores the center coordinates of any circles found
- Displays the total number of circles found in a message box
- Prints the coordinates of each circle to the Immediate window
To use this macro:
- Open the VBA editor in CATIA (Tools > Macro > Visual Basic Editor)
- Create a new module
- Paste the code
- Run the macro while your part is active
Note that this looks for perfect circles - if you need to find approximate circles or arcs, the code would need to be modified. Let me know if you need any adjustments or have questions about implementing it.