Excel Driven Dimension Mates

Discussion in 'SolidWorks' started by haleswd, Dec 8, 2004.

  1. haleswd

    haleswd Guest

    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 http://nhcad.com/old/html/excel.html
    Where 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
     
    haleswd, Dec 8, 2004
    #1
  2. haleswd

    Tin Man Guest

    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
     
    Tin Man, Dec 9, 2004
    #2
  3. haleswd

    Tin Man Guest

    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
     
    Tin Man, Dec 9, 2004
    #3
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.