3 Replies Latest reply on Nov 19, 2014 3:40 PM by Brandon Massoni

    How to select faces created by cut feature?

    Brandon Massoni

      I am measuring the cross sectional area as it changes along a part in the X-direction. How do I select faces created by cut feature? Or maybe, select all the faces normal to the front plane, with some x-coordinate?


      Currently, I do the following, but it is unreliable (faces lose material data when they are cut) and computationally expensive (selects every face and checks material properties for each cut):


      Select all faces

      Color all the faces red

      For loop (stepping in increments)

           Cut the part

           Select all the non-red faces                          'The faces created by a cut feature do not have a color

           Measure the area of all the selected faces




      Brandon Massoni

        • Re: How to select faces created by cut feature?
          Daniel Andersson

          Perhaps this could give you an alternative idea.



          I think that is how I would have started to do the things you describe.

          1 person found this helpful
          • Re: How to select faces created by cut feature?
            Brandon Massoni



            'Brandon Massoni

            'Date Published:



            ' Preconditions:

            ' 1. Open a part document.

            ' 2. Select a feature in the FeatureManager design

            '    tree.

            ' 3. Run the macro.


            ' Postconditions:

            ' 1. Prints the area of the faces created by the feature.

            '    (e.g. cross sectional area of faces created by a cut






            Sub Main()


                Dim swApp As SldWorks.SldWorks

                Dim swModel As SldWorks.ModelDoc2

                Dim swPart As SldWorks.PartDoc

                Dim swFeat As SldWorks.Feature

                Dim swFaceFeat As SldWorks.Feature

                Dim swSelMgr As SldWorks.SelectionMgr

                Dim swFace As SldWorks.Face2

                Dim swEnt As SldWorks.Entity

                Dim faceArr As Variant

                Dim oneFace As Variant

                Dim status As Boolean

                Dim Area As Double

                Dim TotalArea As Double





                'Initial Setup

                Set swApp = Application.SldWorks

                Set swModel = swApp.ActiveDoc

                Set swPart = swModel

                Set swSelMgr = swModel.SelectionManager



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

                    faceArr = swFeat.GetFaces: If IsEmpty(faceArr) Then Exit Sub

                    For Each oneFace In faceArr

                        Set swFace = oneFace

                        Set swEnt = swFace

                        Set swFaceFeat = swFace.GetFeature


                    ' Check to see if face is owned by multiple features

                        If swFaceFeat Is swFeat Then

                            'status = swEnt.Select4(True, swSelData): Debug.Assert (status)


                    'Measures area of current face

                            Area = swFace.GetArea



                    'Adds up areas from each selected

                             TotalArea = TotalArea + Area

                        End If





                    TotalArea = Round(TotalArea, 5)

                    MsgBox "Cross Sectional Area of Feature " & TotalArea & " m^2"


            End Sub