Hello,
I am trying to edit distance mate values in assemblies from an Excel spreadsheet with the help of a macro. It seems to work fine with the following code:
Private Sub Refresh_Click() Set swApp = CreateObject("SldWorks.Application") Set Part = swApp.ActiveDoc Part.Parameter("BevDia2@ snipped-for-privacy@gear.Part").systemvalue = _ Excel.Range("B4") * 0.0254 Part.Parameter("D1@Distance1").systemvalue = _ Excel.Range("E1") * 0.0254 Part.EditRebuild Part.ClearSelection End Sub
This code updates a dimension of a part in the assembly and updates the Dimension Mate. Everything works well untill I drop the assembly into another assembly. I thought that all I would need to change is to add "@assembly name.Part" for it to work.
Part.Parameter("D1@ snipped-for-privacy@Gearbox.Part").systemvalue = _ Excel.Range("E1") * 0.0254
If I drop the assembly into another assembly, the dimensions to individual parts still work fine but I get an error message for the dimension mate:
Object variable or With block variable not set and it highlights this line:
Part.Parameter("D1@ snipped-for-privacy@Gearbox.Part").systemvalue = _ Excel.Range("E1") * 0.0254
What am I missing? Please help!
Thank you,
Vlad