Hi guys, have question about assembly linear component patterns.
I updated my template that has screw-on locating pins.
The locating pins are used in a linear component pattern in the assembly and I renamed it to "LocatingPinPattern". The pins are held in place, with bolts, on a base plate which is another part in the assembly.
On the base plate, I have a linear component pattern for the bolt holes.
I decided to make an api, with a form, for the user to input and adjust the LocatingPinPattern Distance and Number of Instances. Everything works great.
I then decided to take it another step further and made global variables in the assembly for the D3 and D1 dimension of the LocatingPinPattern and called them ComponentPatternDistance and ComponentPatternInstance and linked them to the Bolt Hole Pattern.
Now my code does not work anymore after the linking. I tried changing the variables in the code to different things to get it to work. Does anyone have any idea how to get this to work?
Dim swApp As SldWorks.SldWorks
Dim swPart As SldWorks.ModelDoc2
Dim boolstatus As Boolean
Dim swDim As Object
Dim swDim2 As Object
Private Sub cmdUpdateValues_Click()
Set swApp = Application.SldWorks
Set swPart = swApp.ActiveDoc
'Getting the Assembly pattern
boolstatus = swPart.Extension.SelectByID2("LocatingPinPattern", "COMPPATTERN", 0, 0, 0, False, 0, Nothing, 0)
'Setting the number of instances for the Assembly Pattern
Set swDim = swPart.Parameter("ComponentPatternInstance@LocatingPinPattern")
swDim.Value = txtInstance.Text 'Text taken from user form
'Setting the spacing value for the Assembly Pattern
Set swDim2 = swPart.Parameter("ComponentPatternDistance@LocatingPinPattern")
swDim2.Value = txtDistance.Text 'Text taken from user form
swPart.ForceRebuild3 (True)
End Sub
Private Sub UserForm_Initialize()
Dim swDim As Object
Dim swDim2 As Object
End Sub