7 Replies Latest reply on Jul 23, 2018 7:26 PM by Solid Air

    VBA  feature tree loop finds extra cutlist items... but why?

    Josh Hixon

      My macro is finding cutlist folders that I have not a clue where they are. I can not physically find them in the feature tree. The only way I see them is if the loop finds them. Someone, please help me understand why these extras are there and how to get rid of them.

      Here are the part and my macro that I am using.

       

      You will see that the BOM spits out two raw material numbers when there is only one weldment material selected.

      Cut list item 6 is the first one that comes up that has no feature that I can find in SolidWorks.

      Thoughts?

       

      PS I have made excel visible and commented out the saving portion to better serve the purpose of seeing what is going on.

        • Re: VBA  feature tree loop finds extra cutlist items... but why?
          Christian Chu

          Josh Hixon wrote:

           

          My macro is finding cutlist folders that I have not a clue where they are. I can not physically find them in the feature tree. The only way I see them is if the loop finds them. Someone, please help me understand why these extras are there and how to get rid of them.

          Here are the part and my macro that I am using.

           

          You will see that the BOM spits out two raw material numbers when there is only one weldment material selected.

          Cut list item 6 is the first one that comes up that has no feature that I can find in SolidWorks.

          Thoughts?

           

          PS I have made excel visible and commented out the saving portion to better serve the purpose of seeing what is going on.

          Josh,

          I don't have SW2018 so I can't open your part (still running 2017) however, you can find it by

          If swFeat.GetTypeName() = "CutListFolder" Then

          dim CutListFolderString as string = """SW-CutListItemName@" & swModel.GetTitle + ".SLDPRT"""

          end if

           

          • Re: VBA  feature tree loop finds extra cutlist items... but why?
            Solid Air

            The funny part about your code is that you are finding the second set of cut list folders that are present in models.  The cut list folders you are looking for are actually sub features under the cut list folder.  The second set of folders seem to always be present in weldment models and I have no idea what they except they remind me of an XML end tag.  There are six hidden cut list folders which would  normally indicate there are differences between the as welded and as machined configuration but I do not immediately see any differences between them (more research).  Below is my code to traverse sub features so you can see what I am talking about.

             

            Dim swApp As SldWorks.SldWorks
            Dim swDoc As SldWorks.ModelDoc2
            Dim swFeat As SldWorks.Feature
            Dim swSubFeat As SldWorks.Feature
            
            
            Sub TraverseAgain()
            
            
                Set swApp = Application.SldWorks
                Set swDoc = swApp.ActiveDoc
                
                Set swFeat = swDoc.FirstFeature
                
                Do Until swFeat Is Nothing
            
            
                    Debug.Print swFeat.Name, swFeat.GetTypeName2
                        
                    Set swSubFeat = swFeat.GetFirstSubFeature
            
            
                    Do Until swSubFeat Is Nothing
            
            
                        Debug.Print "..... "; swSubFeat.Name, swSubFeat.GetTypeName2
                            
                        Set swSubFeat = swSubFeat.GetNextSubFeature
            
            
                    Loop
            
            
                    Set swFeat = swFeat.GetNextFeature
            
            
                Loop
                
                Set swFeat = Nothing
                Set swSubFeat = Nothing
                Set swDoc = Nothing
                Set swApp = Nothing
                
            End Sub
            
            • Re: VBA  feature tree loop finds extra cutlist items... but why?
              Solid Air

              I did more research and found if I delete the existing cut list folders (first un-checking Create Cut List Automatically and Update Automatically) then recreating the cut list folders by checking Create Cut List Automatically, only 8 folders are created.  If I had to guess, you probably made changes to your model after creating the cut list and those changes re-arranged which folders which bodies were in.  Unfortunately SolidWorks sometimes hides these no longer used folders instead of deleting them.  Do not know if I answered your questions but welcome to the world under the SolidWorks hood.  There are all kinds of hidden features lurking in SolidWorks models, assemblies and drawings which may explain why they are unstable at times.