Excel Driven Dimension Mates

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

formatting link
it says D1@Sketch1 in the code, I would like to replace that with the dimention mate name. Would that be the correct way to go about doing this, or does anyone have any other ideas as to how I can get this to work.

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

Reply to
haleswd
Loading thread data ...

Have you tried this:

1) Double-click the distance mate in the Feature Tree that you are trying to control. 2) The distance value should now show up in the graphics area. Right-mouse-button the value and choose Properties. 3) The variable name for that value will be here (just like normal dimensions). I would thik that you could use this variable in the same fashion as you used "excel to drive dimension in a part" Yes...No...?

Ken

Reply to
Tin Man

Have you tried this:

1) Double-click the distance mate in the Feature Tree that you are trying to control. 2) The distance value should now show up in the graphics area. Right-mouse-button the value and choose Properties. 3) The variable name for that value will be here (just like normal dimensions). I would thik that you could use this variable in the same fashion as you used "excel to drive dimension in a part" Yes...No...?

Ken

Reply to
Tin Man

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.