I can get excel to drive dimension in a part, so that when I change the excel value, the part dimensions update, and so does the model. I cannot figure out how to make it drive distance mates in an assembly. I want to enter for example 20 on the spreadsheet and that update the distance mate to a 20 in the assembly. I am using the code that I got off of this web site
This is the code that is being used is not in a solidworks macro, it is in the VB editor in excel, and here it is.
Public swApp, Model As Object Public massprops As Variant Public Busy As Boolean
Private Sub Worksheet_Change(ByVal Target As Excel.Range) If Not Busy Then ' Disable this code from change event while it is running Busy = True Set swApp = CreateObject("SldWorks.Application") Set Model = swApp.ActiveDoc
' Width retval = Model.Parameter("D1@Sketch1").SetValue2(Sheet1.Range("B1").Value, 1) ' Height retval = Model.Parameter("D2@Sketch1").SetValue2(Sheet1.Range("B2").Value, 1) ' Length retval = Model.Parameter("D1@Base-Extrude").SetValue2(Sheet1.Range("B3").Value,
1)' Rebuild the part with new dimensions Model.EditRebuild
massprops = Model.GetMassProperties ' volume cu ft Range("B5").Value = massprops(3) * 35.314 ' surface area sq ft Range("B6").Value = massprops(4) * 10.764 ' Enable this code for next change Busy = False End If End Sub