Copieng property values from Excel into SLDASM

Discussion in 'SolidWorks' started by Jan Derk, Oct 3, 2003.

  1. Jan Derk

    Jan Derk Guest

    Hello all,

    At work I have to put 6 values into the custom propertyes of several
    assembly files. These files can have configurations, but the
    properties stay the same within a file. I also have a list in Excel
    which contains the values of each property for each file.

    Now my question:

    Does somebody have a utillity for reading property values from an
    Excel file and put these into a SWX Assembly custom property?

    Thanks in advance for your help,

    JD
     
    Jan Derk, Oct 3, 2003
    #1
  2. Jan Derk

    Sporkman Guest

    No real need for a utility, Jan, unless you just want one. What you do
    is insert a new Design Table in the SLDASM file(s) you want to change,
    then you can Copy/Paste from your Excel file to the Design Table in each
    Assembly. Each custom property column HEADER must be preceded by $PRP@
    just as you would normally do in a Design Table. The entries will show
    up as Configuration Specific custom properties, so if you have more than
    one assembly configuration you need to have a row of values for each
    configuration.

    BTW, you can also drive the part number that ends up in the BOM this way
    by inserting $PARTNUMBER as a column header with the desired value for
    each configuration. It's does the same thing as right-clicking on the
    configuration name (in the Configuration Manager tab) and selecting
    "User Specified Name" under "Part number displayed when used in a bill
    of materials".

    Further BTW, I note that sometimes either Excel or SolidWorks (don't
    know which) refuses to permanently accept the changes made to the Design
    Table. The workaround in to open Excel independently first (open your
    template file with your custom properties in it), then right-click on
    your SolidWorks file's Design Table and choose "Edit Table in Separate
    Window". You'll then have both windows open in Excel and you can
    Copy/Paste from one to the other.

    'Spork'
     
    Sporkman, Oct 3, 2003
    #2
  3. Jan,
    If you still think you'd like to have a utility to do this, I'd be happy to
    make one for you.
    --Brenda
     
    Brenda D. Bosley, Oct 3, 2003
    #3
  4. I've pasted in the text from a thread on another discussion group that looks
    like what you want to do. You might get ahold of Stuart to see where he
    went with this one.

    WT
    Yes that's what I'm trying to do, I made significant progress last night,
    (after I learnt a bit about importing object libraries) I can now read from
    a cell in excel, yay! I was then going to use parts of dereks custom
    properties macro to add the cell contents to the solidworks file, And then I
    was hopefully going to get it to step through all the files populating them
    correctly (provided they have their filenames are spelt correctly.

    Here is my code:
    Sub main()
    Dim appxl As Excel.Application
    Dim partno As String
    Dim myobj As Object
    Set myobj = GetObject("C:\Documents and Settings\Stuart
    Young\MyDocuments\XTRA 2002\parts2.xls")
    Workbooks.Open Filename:="C:\Documents and Settings\Stuart
    Young\MyDocuments\XTRA 2002\parts2.xls"
    Cells(2, 2).Select
    Selection.Copy
    Workbooks.Add
    Cells(1, 1).Select
    ActiveSheet.Paste
    ActiveWorkbook.SaveAs Filename:="C:\Documents and Settings\Stuart
    Young\MyDocuments\XTRA 2002\testfile.xls"
    ActiveWorkbook.Close 'close books
    ActiveWorkbook.Close
    End Sub

    Any guidance would be appreciated

    Stuart Young

    Design Engineer,

    ****************************************

    Gelârt International Ltd/ Medix 21 Ltd
    Box 54117 Mana Paremata
    Wellington New Zealand

    http://www.gelart.co.nz/
    mailto:
    tel +64 4 233 0925
    fax +64 4 233 0982

    ****************************************

    -----Original Message-----

    From: [mailto:]
    Sent: Thursday, September 04, 2003 4:21 AM
    To:
    Subject: RE: [CAD] API tips

    What exactly are you trying to do? What I am seeing is that you want excel
    to populate your custom properties with data from the cells? If so, yes it
    can be done and I will show you what I'm thinking if that is the case. If it
    is, let me know which version of SolidWorks your wanting to do this with
    (2001Plus, 2003, 2004??).

    John

    -----Original Message-----

    From: Stuart Young [mailto:]
    Sent: Tuesday, September 02, 2003 5:18 PM
    To:
    Subject: RE: [CAD] API tips

    Can anyone guide me on how to import data from Excel into a solid works
    macro so that I could then write it into the custom properties using a
    derivative of Derek's macro? Something along the line of

    Open excellfile. "C:\partdata.xls"
    Cells (1, 1).select
    Part number = selection
    Cells (1,2).select
    Description = selection
    Cells (1,3).select
    Cost = selection
    Etc.....

    Can this be done? Code that works in Excel macros doesn't appear to be
    recognized in solidworks macros, Are they slightly different languages?

    Cheers
    Stuart Young
    Design Engineer,

    ****************************************
     
    Wayne Tiffany, Oct 3, 2003
    #4
  5. Make sure you quit excel. I noticed that in the Task Manager that you can
    end up with 8 or so instances of excel that are all hidden.

    appxl.Quit
     
    Corey Scheich, Oct 3, 2003
    #5
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.