AnsweredAssumed Answered

How to modify this short sort folder code?

Question asked by Marco Wu on Jun 8, 2017

I found the following sortfolder code online. I need to sort folder using vendor name & part no. How to modify the code to do this?

 

Thanks

 

 

 

 

 

 

 

======================================================

 

 

Function SORTFOLDERS(SWMODEL As SldWorks.ModelDoc2, featfldr As SldWorks.FeatureFolder)

 

 

        Dim Features As Variant

        Dim FOLDERFILES As Object

        Dim swassemblydoc As SldWorks.assemblydoc

        Set swassemblydoc = SWMODEL

        Dim TEMPCOMP As SldWorks.Component2

         

    Set FOLDERFILES = CreateObject("System.Collections.ArrayList")

       

        Features = featfldr.GetFeatures

                    For j = 0 To featfldr.GetFeatureCount - 1

                        tempstring = (Features(j).Name)

                        FOLDERFILES.Add (tempstring)

               

                    Next

                    FOLDERFILES.Sort

                    For i = 0 To FOLDERFILES.Count - 1

 

 

Set TEMPCOMP = swassemblydoc.GetComponentByName(FOLDERFILES(i))

 

 

                    If i < FOLDERFILES.Count Then

        

                        boolstatus = swassemblydoc.ReorderComponents(TEMPCOMP, featfldr, 3)

                    End If

                Next

 

 

       

End Function

Outcomes