macro sample?

Discussion in 'SolidWorks' started by Zander, Feb 22, 2007.

  1. Zander

    Zander Guest

    Hi all,

    I have a macro that I wish to expand on. I need to embed the existing
    code in a loop that will create a selection set of part files in a
    specified folder, then execute the macro on each file. I was hoping
    to find an existing macro sample that demonstrates parsing a folder,
    creating a selection set and sequentially opening each part in
    solidworks and executing the existing code that I have.

    I've searched the solidworks site sample code and my own macros but no
    existing macros demonstrate this ability. If you've come across this
    before - I'd appreciate it!

    Thanks,

    Zander
     
    Zander, Feb 22, 2007
    #1
  2. Zander

    fcsuper Guest

    Zander,

    If you don't find your answers here or the other forums, I would
    suggest contacting your VAR to see if they can ID that function. If
    they don't know, you can put in an enhancement request to add control
    over folders in VB.

    Matt
    http://sw.fcsuper.com
     
    fcsuper, Feb 22, 2007
    #2
  3. Zander

    fcsuper Guest

    Zander,

    This macro might help you figure out how to control folders:

    http://sw.fcsuper.com/index.php?name=UpDownload&req=viewdownloaddetails&lid=31

    It has the ability to ID them and give control on whether they are
    viewable or not. Seems to me that if it can control that, it can show
    you how to control items within a particular folder.

    Matt
    http://sw.fcsuper.com
     
    fcsuper, Feb 22, 2007
    #3
  4. Zander

    Tin Man Guest

    For operation *not* SolidWorks specific, try looking up help for Excel
    VBA. There's a lot more of that out there. This should do the trick
    for you. "folderspec" must be the full path and filename.

    Ken

    Sub ShowFileList(folderspec)
    Dim fso, f, f1, fc, s
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set f = fso.GetFolder(folderspec)
    Set fc = f.Files
    For Each f1 In fc
    Debug.Print f1.Name
    Next
    End Sub
     
    Tin Man, Feb 28, 2007
    #4
  5. Zander

    Zander Guest

    Thanks for the info everyone. The idea here is to automate the
    creation of flat pattern dxf files from a folder of parts (there are
    over 200 parts for this project) that need to be laser cut. I found
    the dxf export portion in the customer portal so the idea is: create a
    selectionset of parts in folder, then open each part one at a time,
    create dxf, close file and repeat. I'll let you know how it works.

    Zander
     
    Zander, Mar 1, 2007
    #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.