3 Replies Latest reply on Mar 18, 2014 7:50 PM by Gustavo Oliveira

    Select edges of a part

    Hesamoddin Yavari

      Hi

      I was wondering if any one can tell me how I can select only the top edges of the part below to do fillet.

      Part of the code that I wrote is as below, but it does not work.

       

      Dim swPart As SldWorks.PartDoc

      Dim swBody As SldWorks.Body2

      Dim vEdges As Variant

      Dim swEdge As SldWorks.Edge

       

      Set swPart = swModel

      Set swBody = swPart.Body

      vEdges = swBody.GetEdges()

      Set swEdge = vEdges(???)

      swEdge.Select2 True, Nothing

       

      Regards

      Hesam

       

      Untitled.jpg

        • Re: Select edges of a part
          Gustavo Oliveira

          Try this:

           

          Dim swApp As SldWorks.SldWorks

          Dim swModel As SldWorks.ModelDoc2

          Dim swPart As SldWorks.PartDoc

          Dim vBodies As Variant

          Dim vBody As Variant

          Dim swBody As SldWorks.Body2

          Dim vEdges As Variant

          Dim vEdge As Variant

          Dim swEdge As SldWorks.Edge

          Dim swFeature As SldWorks.Feature

          Dim swRefPlane As SldWorks.RefPlane

          Dim swEntity As SldWorks.Entity

          Dim distance As Double

           

          Sub main()

                 

              Set swApp = Application.SldWorks

              Set swModel = swApp.ActiveDoc

              Set swPart = swModel

              Set swBody = swPart.Body

           

              'Clear selection

              swPart.ClearSelection2 True

           

              'Get Front Plane Object

              Set swFeature = swPart.FeatureByName("FRONT")

              Set swRefPlane = swFeature.GetSpecificFeature2

           

              'Get Bodies

              vBodies = swPart.GetBodies(0)

              For Each vBody In vBodies

                 

                  'Get Body

                  Set swBody = vBody

                 

                  'Get Edges

                  vEdges = swBody.GetEdges

                  For Each vEdge In vEdges

                 

                      'Get Edge

                      Set swEdge = vEdge

                     

                      'Check if is the top edge

                      distance = swModel.ClosestDistance(swEdge, swRefPlane, Nothing, Nothing)

                      If distance > 0 Then

                         

                          'Select Edge

                          Set swEntity = swEdge

                          swEntity.Select True

                         

                         

                      End If

                 

                  Next

                 

                  'Create Fillet

                  swModel.FeatureManager.FeatureFillet 195, 0.001, 0, 0, 0, 0, 0

             

              Next

             

          End Sub