2 Replies Latest reply on Sep 16, 2015 11:07 AM by Shawn Tracey

    How do I Suppress a Feature in All Configurations of a Part?

    Shawn Tracey

      So I am re-writing code that will suppress a feature in all configurations of a part instead of just suppressing the feature in the active configuration.

       

      The code I am starting out with to suppress a feature called "Nozzle Hole" in a part is as below:

      boolstatus = swModel.Extension.SelectByID2("Nozzle Hole", "BODYFEATURE", 0, 0, 0, False, 0, Nothing, 1)

      swModel.EditSuppress2

      swModel.ClearSelection2 True

       

      This works great for suppressing the active configuration, but not all configurations like I need.

       

      Any idea's how to change this code to suppress "Nozzle Hole" in all configurations?

        • Re: How do I Suppress a Feature in All Configurations of a Part?
          Deepak Gupta

          You can manually do it by right clicking on feature, select feature properties and set suppressed for all configuration.

           

          With API, you need to traverse thru all configurations.

          • Re: How do I Suppress a Feature in All Configurations of a Part?
            Shawn Tracey

            Okay so I found a solution to my problem.  It might not be the most eloquent way of doing it, so if anyone has another way, please let me know.

             

            So I had to add in the IFeature interface to be able to select all configurations.

             

            Used the SelectByID2 function to mark the feature with a "1".

            Then used the GetSelectedObject6 to selected the marked feature.

            Could now use the SetSuppression2 function to suppress the feature in all configurations.

             

            Like I said, it might not be the best or easiest way to do it, but it works.  If anyone has another solution please post.  I like to see all possible solutions to a problem as it is a great way to learn.

             

            swFeat = SldWorks.Feature

             

            boolstatus = swModel.Extension.SelectByID2("Nozzle Hole", "BODYFEATURE", 0, 0, 0, False, 1, Nothing, 0)

            Set swFeat = swModel.ISelectionManager.GetSelectedObject6(1, 1)

            boolstatus = swFeat.SetSuppression2(0, 2, True)

            swModel.ClearSelection2 True

            swFeat.Deselect

             

            swFeat = Nothing