Difficulty linking dimensions from API

With our sheet metal parts, we often use equations that are derived from the sheet metal thickness or bend radius; for instance, we have a permanent variable called trim, which is the sum of the two. This way we can dimension something based on the overall size and allow space for any aditional flanges added later. To access these, we have two global variables, Thickness and BendRadius. Before SW was modified to allow for multibody sheet metal parts, our template had these permanently linked, but this hasn't worked for the last few years. So we re-wrote one of the macros we use to link the thickness and bend radius to these variables. This stops working every so often as SW changes, so we re-modify it.

The most recent update to SW has broken our tool and I'm having trouble fixing it. The main problem is that the API doesn't seem to be letting me link the variables using the DisplayDimension.SetLinkedText command. The basic macro I've been using is listed below - all you should need to test it is a file containing a sheet metal feature. Any suggestions to get around this problem are welcome!

' Link sheet metal thickness and Bend Radius to already existing global

' variables named Thickness and BendRadius respectively.

'

' Requires an open part with the sheet metal feature already existing,

' and two global variables, one called Thickness, one called BendRadius


Sub main()

    Dim swApp As SldWorks.SldWorks

    Dim swModel As ModelDoc2

    Dim swFeat As Feature

    Dim dispDimension As DisplayDimension


    Set swApp = Application.SldWorks

    Set swModel = swApp.ActiveDoc


    ' Iterate over all features looking for sheetmetal, then iterate over

    ' dimensions that feature contains

    Set swFeat = swModel.FirstFeature

    Do While Not swFeat Is Nothing

        If swFeat.GetTypeName2 = "SheetMetal" Then

            Set dispDimension = swFeat.GetFirstDisplayDimension

            Do While Not dispDimension Is Nothing

                ' D7 seems to be the thickness in all the new sheetmetal

                ' features I've tried

                If dispDimension.GetDimension2(0).Name = "D7" Then

                    dispDimension.SetLinkedText "Thickness"  ' Doesn't work!

                End If

                ' Similarly, D1 seems to be the BendRadius

                If dispDimension.GetDimension2(0).Name = "D1" Then

                    dispDimension.SetLinkedText "BendRadius"  ' Doesn't work again!

                End If

                Set dispDimension = _

                    swFeat.GetNextDisplayDimension(dispDimension)

            Loop

        End If

        Set swFeat = swFeat.GetNextFeature

    Loop

End Sub

Thanks for any help,

Daniel

SolidworksApi macros