Sw 2013 Cut list marco problem

Hi,

The problem is that my macro searches for fist feature called "Cut-list-item1", but sometimes if i open a older part the cut list is called "Cut-list-item2" or even "Cut-list-item6".

i tried to filter the name so if it contains "Cut-list-Item''  it will grab that one, but i can figure it out.

Thanks in advance,

Pieter Tessel.

Solidworks 2013 Cut list macro:

Sub main()

    Dim swApp As SldWorks.SldWorks

    Dim swModel As SldWorks.ModelDoc2

    Dim swFeat As SldWorks.Feature

    Dim swCustPropMgr As SldWorks.CustomPropertyManager

   

    Dim retval As String

   

    Set swApp = Application.SldWorks

    Set swModel = swApp.ActiveDoc

    Set swFeat = swModel.FirstFeature

   

    retval = swModel.AddCustomInfo3("", "Stocksize", swCustomInfoText, "")

   

    Dim strValue As String

   

    Set swApp = Application.SldWorks

    Set swModel = swApp.ActiveDoc

    Set swFeat = swModel.FirstFeature

   

    Do While Not swFeat Is Nothing

        If swFeat.Name = "Cut-List-Item1" Then

           Set swCustPropMgr = swFeat.CustomPropertyManager

            swCustPropMgr.Get4 "Description", False, Empty, strValue

            Set swCustPropMgr = swModel.Extension.CustomPropertyManager(Empty)

            swCustPropMgr.Set "Stocksize", strValue

          Exit Do

        End If

       Set swFeat = swFeat.GetNextFeature

       Loop

End Sub

SolidworksApi macros