2 Replies Latest reply on Aug 29, 2016 5:08 AM by Hrituc Alexandru

    Get center of circles

    Hrituc Alexandru

          Hi everyone,

       

      How I can get the centre of selected circles with API so that to result as in Picture 2?

       

      1.jpgPicture 1

       

       

      2.jpgPicture 2

       

      Thank you

        • Re: Get center of circles
          Ivana Kolin
          Option Explicit
          
          
          Sub main()
              Dim swApp                                     As SldWorks.SldWorks
              Dim swModel                                   As SldWorks.ModelDoc2
              Dim swSelMgr                                  As SldWorks.SelectionMgr
              Dim swSkArc                                   As SldWorks.SketchArc
              Dim i                                         As Integer
              Dim skPoints()                                As SketchPoint
              Dim x                                         As Integer
          
          
              Set swApp = Application.SldWorks
              Set swModel = swApp.ActiveDoc
              Set swSelMgr = swModel.SelectionManager
          
          
              x = swSelMgr.GetSelectedObjectCount2(-1)
              If x = 0 Then Exit Sub
          
          
              ReDim skPoints(x)
              For i = 1 To x
                  Select Case swSelMgr.GetSelectedObjectType3(i, -1)
                  Case swSelEXTSKETCHSEGS, swSelSKETCHSEGS
                      Set swSkArc = swSelMgr.GetSelectedObject6(i, -1)
                      Set skPoints(i) = swSkArc.GetCenterPoint2
                  Case Else
                      Debug.Print "SelType: "; swSelMgr.GetSelectedObjectType3(i, -1)
                  End Select
              Next i
              swModel.ClearSelection2 True
              For i = 1 To x
                  If Not skPoints(i) Is Nothing Then
                      skPoints(i).Select4 True, Nothing
                  End If
              Next i
          End Sub