9 Replies Latest reply on Jun 23, 2017 4:38 AM by Eugen Fritz

    How to select the inner edges from a cut

    Eugen Fritz

      Hey guys,

      excuse my English skills, please. I am a student from Germany and i want to write a macro which cuts defined rectangle "windows" in a pipe like the first picture with the corsur. My problem is i can not select only the inner edges with the macro to make a fillet with FeatureFillet3 like the second picture. SelectByID2 is not the right tool for it, i think. Mayby there are other ways to select the edges automatically? I tried a lot but always i got all twelve edges or all faces but not only the inner four.

       

      best regards

        • Re: How to select the inner edges from a cut
          Amen Allah Jlili

          You can start by selecting the cut extrude feature and get the associated faces. Those faces have edges. Now your next problem is filter out the edges on the outside. The edges on the outside are actually shared by the outside face of the cylinder and one the inner faces. That's filtering the critea.

           

          Best,
          Amen
          CADHero.com

          • Re: How to select the inner edges from a cut
            Raghvendra Bhargava

            HI Eugen,

            Select your Cut Extrude Feature and Try this:

             

            Dim swApp As SldWorks.SldWorks

            Dim Part As ModelDoc2

            Dim boolstatus As Boolean

             

            Sub main()

            Set swApp = Application.SldWorks

            Set Part = swApp.ActiveDoc

            'boolstatus = Part.Extension.SelectByID2("Cut-Extrude1", "BODYFEATURE", 0, 0, 0, False, 0, Nothing, 0)

             

            Dim feat As Feature

            Set feat = Part.SelectionManager.GetSelectedObject6(1, -1)

             

            Dim vFaces As Variant

            vFaces = feat.GetFaces

             

            Dim FCnt As Integer

            Dim ECnt As Integer

            Dim swFace As Face2

            Dim vEdges As Variant

            Dim swEdge As Edge

            Dim swCurve As Curve

            Dim Param As Variant

            Dim swEnt As Entity

            Dim EdgeLen As Double

             

             

            For FCnt = 0 To UBound(vFaces)

             

                Set swFace = vFaces(FCnt)

                vEdges = swFace.GetEdges

               

                For ECnt = 0 To UBound(vEdges)

               

                    Set swEdge = vEdges(ECnt)

                    Set swCurve = swEdge.GetCurve

                    Param = swEdge.GetCurveParams2

                    EdgeLen = Round(swCurve.GetLength2(Param(6), Param(7)), 4) 'Getting Edge Length

                    

                    Set swEnt = swEdge

                    swEnt.Select False ' Selecting Edge

             

                Next ECnt  

            Next FCnt

             

            End Sub

             

             

            This will select all Edges in Cut Extrude Feature now You need to Find out the Filter as I have added by getting Length.

            • Re: How to select the inner edges from a cut
              Eugen Fritz

              Hey guys,

              thank you for your quick response, i will try the code and your ideas tomorrow. Today i am in college.

               

              Regards

              Eugen

               

                • Re: How to select the inner edges from a cut
                  Raghvendra Bhargava

                  I am agree with Amen Allah Jlili  .

                   

                  So try now this:

                  Dim swApp As SldWorks.SldWorks

                  Dim Part As ModelDoc2

                  Dim boolstatus As Boolean

                   

                  Sub main()

                  Set swApp = Application.SldWorks

                  Set Part = swApp.ActiveDoc

                  'boolstatus = Part.Extension.SelectByID2("Cut-Extrude1", "BODYFEATURE", 0, 0, 0, False, 0, Nothing, 0)'Replace with your Cut extrude

                   

                  Dim feat As Feature

                  Set feat = Part.SelectionManager.GetSelectedObject6(1, -1)

                   

                  Dim vFaces As Variant

                  vFaces = feat.GetFaces

                   

                  Dim FCnt As Integer

                  Dim ECnt As Integer

                  Dim swFace As Face2

                  Dim vEdges As Variant

                  Dim swEdge As Edge

                  Dim swCurve As Curve

                  Dim Param As Variant

                  Dim swEnt As Entity

                  Dim EdgeLen As Double

                  Dim vEdgeFaces As Variant

                  Dim Cnt As Integer

                  Dim EdgeFace As Face2

                  Dim FaceFeat As Feature

                  Dim FeatName(1) As String

                   

                   

                  For FCnt = 0 To UBound(vFaces)

                   

                      Set swFace = vFaces(FCnt)

                      vEdges = swFace.GetEdges

                     

                      For ECnt = 0 To UBound(vEdges)

                     

                          Set swEdge = vEdges(ECnt)

                         

                          vEdgeFaces = swEdge.GetTwoAdjacentFaces2

                         

                          For Cnt = 0 To UBound(vEdgeFaces)

                         

                              Set EdgeFace = vEdgeFaces(Cnt)

                              Set FaceFeat = EdgeFace.GetFeature

                              FeatName(Cnt) = FaceFeat.Name

                         

                          Next Cnt

                         

                  '        Set swCurve = swEdge.GetCurve

                  '        Param = swEdge.GetCurveParams2

                  '        EdgeLen = Round(swCurve.GetLength2(Param(6), Param(7)), 4) 'Getting Edge Length

                   

                          If FeatName(0) = FeatName(1) Then 'if Two adjacent faces of edge, will belong to same Feature then only it will select.

                              Set swEnt = swEdge

                              swEnt.Select False ' Selecting Edge

                          End If

                      Next ECnt

                     

                  Next FCnt

                   

                  End Sub