Help combining VBA scripts

Hello,

I have these two pieces of code that work on their own. There are elements from one I would like implemented in the other one. The first code successfully selects all the circles in my part using getpolylines7. The second code takes all the curves in the part and prints the center point locations in the debug menu. I was hoping that someone can take the part from the second code that collects all the circle centers and use it in the first code.

 

Essentially, I would like to have the code select all the circles on my part, and have it output the circle centers in the debug menu.

I understand that I don't sound very technical. I am not a coder. Thank you for your help:

 

First Code:

Sub Main()

   Dim swApplication As SldWorks.SldWorks
   Dim swModel As SldWorks.ModelDoc2
   Dim swView As SldWorks.View
   Dim swCurve As SldWorks.Curve
   Dim swEdges() As SldWorks.Edge
   Dim swSelectData As SldWorks.SelectData
   Dim vbPolylines As Variant
   Dim vbPolyline As Variant
   Dim vbBoolean As Boolean

   Set swApplication = Application.SldWorks
   Set swModel = swApplication.ActiveDoc
   Set swView = swModel.GetFirstView
   Set swView = swView.GetNextView
   swView.FocusLocked = True
   vbBoolean = True

   'Clear selections
   swModel.ClearSelection2 True

   'Loop first view
   vbPolylines = swView.GetPolylines7(1, swEdges)
   

   For Each vbPolyline In vbPolylines
       'If polyline is a circle
       If vbPolyline.GetCurve.IsCircle = True Then
           Set swCurve = vbPolyline.GetCurve
           If vbBoolean = True Then
               vbPolyline.Select4 True, swSelectData
               vbBoolean = False
           End If
           If vbBoolean = False Then
               vbPolyline.Select4 True, swSelectData
           End If
       End If
   Next vbPolyline
   
End Sub
 

 

Second Code:

Option Explicit

Dim swApp As SldWorks.SldWorks
Sub GetCircleCenters()
   Dim swModel As SldWorks.ModelDoc2
   Dim swDrawing As SldWorks.DrawingDoc
   Dim swView As SldWorks.View
   Dim swSheetView As SldWorks.View
   Dim vPolyLinesBuffer As Variant
   Dim lBufferSize As Long, lBufferIdx As Long
   Dim lItemType As Long, lGeomDataSize As Long
   Dim dGeomData(11) As Double
   
   ' Get SOLIDWORKS application
   Set swApp = Application.SldWorks
   
   ' Get active document
   Set swModel = swApp.ActiveDoc
   If swModel Is Nothing Then Exit Sub
   
   ' Downcast to drawing document
   Set swDrawing = swModel
   
   ' Get the first view (drawing sheet)
   Set swSheetView = swDrawing.GetFirstView
   
   ' Get the first "real" view on the sheet
   Set swView = swSheetView.GetNextView
   
   Do While Not swView Is Nothing
       ' Get polylines with edges (no cross-hatch lines)
       swView.GetPolylines7 1, vPolyLinesBuffer
       
      
       If Not IsEmpty(vPolyLinesBuffer) Then
           lBufferSize = UBound(vPolyLinesBuffer) - LBound(vPolyLinesBuffer) + 1
           lBufferIdx = 0
           
           Do While lBufferIdx < lBufferSize
               lItemType = vPolyLinesBuffer(lBufferIdx)
               lBufferIdx = lBufferIdx + 1
               
               If lItemType <> 0 Then ' If it's an arc/circle
                   lGeomDataSize = vPolyLinesBuffer(lBufferIdx)
                   lBufferIdx = lBufferIdx + 1
                   
                   ' Retrieve center point
                   dGeomData(0) = vPolyLinesBuffer(lBufferIdx)
                   dGeomData(1) = vPolyLinesBuffer(lBufferIdx + 1)
                   dGeomData(2) = vPolyLinesBuffer(lBufferIdx + 2)
                   
                   Debug.Print "Center Point: (" & dGeomData(0) * 1000# & ", " & dGeomData(1) * 1000# & ", " & dGeomData(2) * 1000# & ") mm"
                   
                   ' Move buffer index past geometry data
                   lBufferIdx = lBufferIdx + (lGeomDataSize - 1)
               End If
           Loop
       End If
       
       ' Get next view
       Set swView = swView.GetNextView
   Loop
   
End Sub