3 Replies Latest reply on Sep 21, 2017 4:30 AM by Gil K.

    edge selection

    Gil K.

      Hello All.

      I have an imported surface body and it is selected by its name: "Surface-Imported1"

      with the help of SelectByID2.

      how do I carry on in order to select the bounding Edges of this surface body.

      remark: the geometry of the surface body is un predicted and could be split.

      the picture shows the wanted result.

      thank you.

      select boundry.png

        • Re: edge selection
          Amen Allah Jlili

          If that's a planar surface than you can traverse the largest face and get the outer most loop of edges.


          CADHERO consulting SUARL – CAD Design Automation & Training – SOLIDWORKS API

          • Re: edge selection
            Manikandan Babu

            Hi Gil,


            Lets try this code...


            Dim swApp As SldWorks.SldWorks

            Dim swmodel As SldWorks.ModelDoc2

            Dim swselmgr As SldWorks.SelectionMgr

            Dim swbody As SldWorks.Body

            Dim swfeat As SldWorks.Feature

            Dim swsurf As Object

            Dim boolstatus As Boolean

            Dim swface As SldWorks.Face2

            Dim myLoop As Loop2

            Dim vEdges As Variant

            Dim myEdge As SldWorks.Edge

            Dim swent As SldWorks.Entity


            Sub main()

            Set swApp = Application.SldWorks

            Set swmodel = swApp.ActiveDoc

            Set swselmgr = swmodel.SelectionManager

            boolstatus = swmodel.Extension.SelectByID2("Surface-Imported1", "REFSURFACE", 0, 0, 0, False, 0, Nothing, 0)

            Set swfeat = swselmgr.GetSelectedObject6(1, -1)

            swmodel.ClearSelection2 True

            Set swbody = swfeat.GetBody

            Set swface = swbody.GetFirstFace

            While Not swface Is Nothing

            Set myLoop = swface.GetFirstLoop

            While Not myLoop Is Nothing

            edgeCount = myLoop.GetEdgeCount()

            outer = myLoop.IsOuter()

            If outer <> 0 Then

            vEdges = myLoop.GetEdges()

            For K = LBound(vEdges) To UBound(vEdges)

            Set myEdge = vEdges(K)

            Set swent = myEdge

            swent.Select True

            Next K

            End If

            Set myLoop = myLoop.GetNext()


            Set swface = swface.GetNextFace


            End Sub