3 Replies Latest reply on Aug 20, 2013 10:55 PM by Artem Taturevych

    Selecting outer edge of face

    Chris Johnson

      Hi All,

       

      so basically Im trying to create a macro that  changes the selection from the pre-selected (circular) face to its outer edge.

       

      I kinda think it may be done with .getedges but i dont know how to implement it.

       

      does anyone have an example of how this could be done?

       

      thank you

       

      Chris

        • Re: Selecting outer edge of face
          Artem Taturevych

          Hi Chris,

           

          Here is the macro:

           

          Dim swApp As SldWorks.SldWorks

          Dim swModel As SldWorks.ModelDoc2

          Dim swSelMgr As SldWorks.SelectionMgr

          Dim swFace As SldWorks.Face2

           

          Sub main()

           

              Set swApp = Application.SldWorks

           

              Set swModel = swApp.ActiveDoc

             

              Set swSelMgr = swModel.SelectionManager

             

              Set swFace = swSelMgr.GetSelectedObject6(1, -1)

             

              If Not swFace Is Nothing Then

             

                  Dim vLoops As Variant

                  vLoops = swFace.GetLoops

                 

                  Dim i As Integer

                 

                  swModel.ClearSelection2 True

                 

                  For i = 0 To UBound(vLoops)

                      Dim swLoop As SldWorks.Loop2

                      Set swLoop = vLoops(i)

                      If swLoop.IsOuter() Then

                          Dim vEdges As Variant

                          vEdges = swLoop.GetEdges

                          Dim j As Integer

                          For j = 0 To UBound(vEdges)

                              Dim swEdge As SldWorks.Entity

                              Set swEdge = vEdges(j)

                              swEdge.Select4 True, Nothing

                          Next

                      End If

                  Next

                 

              End If

             

          End Sub

          ____________________________________________________

          Regards,

          Artem Taturevych, Application Engineer at Intercad (Australia)

           

          translationXpert – add-in to translate SolidWorks models

          myIntercad an integrated tool for SolidWorks Professionals

          LinkedIn SolidWorks API Education Group