Editing Assembly Part Linear pattern

Hello, another newbie question here.  I have came up to a similar problem which I just encountered in the past.

I am trying to edit the dimensions D1 and D3  of a linear pattern that is on a part that is in an assembly.

The name of the part names always change.

The assembly has about 20 parts in it. If I run this code alone on just the part it works great.

I cannot seam to get it to work while I am inside of the assembly though. I also would not prefer the user to find or preselect the pattern. I plan on rolling this into a form after I get this working. Please help.

Dim swApp as sldworks.sldworks

Dim swPart as sldworks.ModelDoc2

Dim swDim as Variant

Dim swDim2 as Variant

Sub main ()

Set swApp = Application.sldworks

Set swPart = swApp.ActiveDoc

Set swDim = swPart.Parameter("D1@LPattern1")

swDim.Value = 2

Set swDim = swPart.Parameter("D3@LPattern1")

swDim2.Value = 2

swPart.ForceRebuild3 (True)

End Sub

SolidworksApi/macros