2 Replies Latest reply on Jul 14, 2015 6:20 AM by Hrituc Alexandru

    Cosmetic Threads

    Hrituc Alexandru



      How can find the number of Cosmetic Threads from a part???  I need a macro to sum up all and add a properties with the result..

      If is not possible, then how can I add a search filter in the attached macro?

      I want to look in the search for cosmetic thread, to extract the max number from the tail and add  a property with him!.....Those are the steps that I was thinking!


        • Re: Cosmetic Threads
          Padaka Lingam

          Hi Hrituc,

               the below changes would works for requirements

          i changed the textbox into listbox for showing the list of cosmetic threads.

          i hope this will helpful for u




          ''module code

          Public swApp As SldWorks.SldWorks

          Public swMathUtility As SldWorks.MathUtility

          Public myModel As SldWorks.ModelDoc2

          Public thisFeature As SldWorks.Feature

          Public thisSubFeature As SldWorks.Feature

          Public count As Integer



          Sub main()





          End Sub


          ''form code

          Private Sub cmdExit_Click()


          End Sub



          Private Sub cmdExport_Click()

              Dim featureText As String

              featureText = ""

              For i = 0 To ListBox1.ListCount - 1

                  featureText = featureText & ListBox1.List(i) & "," & vbCr

              Next i


              Dim filePath As String

              filePath = txtFileOutput.Text + " List features.csv"


              Open filePath For Output As #1

                  Print #1, featureText

              Close #1


              MsgBox ("Exported")

          End Sub



          Private Sub cmdGetFeatureList_Click()


              Set swApp = Application.SldWorks

              Set swMathUtility = swApp.GetMathUtility()

              Set myModel = swApp.ActiveDoc

              myModel.ClearSelection2 True

              count = 0

              ' Traverse features and subfeatures of this model and look for cosmetic threads

              Set thisFeature = myModel.FirstFeature

              While Not thisFeature Is Nothing

                  Debug.Print "Processing " & thisFeature.Name

                  Set thisSubFeature = thisFeature.GetFirstSubFeature()

                  While Not thisSubFeature Is Nothing

                      Debug.Print "   Processing sub " & thisSubFeature.Name

                      If (thisSubFeature.GetTypeName() = "CosmeticThread") Then

                          count = count + 1

                          ListBox1.AddItem thisSubFeature.GetNameForSelection(thisSubFeature.GetTypeName), count - 1

                      End If

                      Set thisSubFeature = thisSubFeature.GetNextSubFeature()


                  Set thisFeature = thisFeature.GetNextFeature()



          End Sub

            • Re: Cosmetic Threads
              Hrituc Alexandru

              HI Lingam


              1. The macro works fine but I would like to ask you it's possible to give me the total of it?...  Or a numbering from wich decrease of those suppressed

              2. How can put the > supressed < if the thread is supressed?

              if it's possible i will make 11-1 (supressed) =10 and with this 10 i will make a properties