You need to be logged in to view this content. Please login or become a member.


  1. doylerules


    I am using the API to automate the pack and go process but I have multiple part files in different folders. This is a rather large assembly so it makes organizing all the parts to have specific folder names.

    Unfortunately, the default set with the Pack and go API is for the “Flatten to single folder” option to be turned on. Does Solidworks have any instructions to turn this option off through the API? My code currently works to use the pack and go process but it copies all the files to a single folder which is not what I want.


    • I don’t see anything in the API Help about it. If there’s a trick that let’s you maintain folder structure, I am not aware of it.

      If you’re using .NET, you might consider packing your assembly into a ZIP file using their file compression libraries rather than using the SolidWorks API.

  2. jhaws1001

    It seems that strSetPathNames becomes irrelevant when the assembly contains virtual components. I can change the path, but not the file name using the above method in assemblies with virtual components. The file name also becomes all-lowercase.

    Is there a work-around to use assemblies that contain virtual components?

  3. JJohnson

    I wrote a vba macro using the Solidworks example and did not see anywhere to limit the pack and go list.

    I searched a few Pack and go api threads on the Solidworks forums and found a reference to this site and thought I would look at your script.

    I still haven’t found what I am looking for.

    Keith, do you know of a way to limit certain files?
    I have a pack and go process pulling file locations from multiple places – what I want to do is ignore everything in the list except files that match a certain filepath.

    All files from this file path will get packed and sent to my “save to” folder.

    I don’t need prefixes, suffixes, assembies or drawings / sim data to be saved with these files, just the sldprt’s

    • JJohnson

      Nvm – Figured it out.

      I simply had to build a collection and fill it with only the filenames I wanted to use. I could have used an array, but I’m not a big fan of adding and removing elements of arrays.

      Much easier to use collection.add or .remove

  4. JJohnson

    Ok here is a little issue I ran into..

    The Get and Set SaveToName methods apparently need to match in order for the Pack and GO to work.

    I keep getting an error because my SetSavetoName list of filenames has X elements in it, and the GetSavetoName method contains the full unfiltered list of all filenames in the assembly…

    In the normal Pack and Go GUI users would normally use, there are check boxes allowing the user to unselect unwanted files. I can’t seem to locate that same functionality in the API…. frustrating….

    • JJohnson,

      It sounds you like you might benefit from converting the array to collection, removing the undesirable elements, and then converting the collection back to an array. There is an example of collections in the macro library that is free.

      There are several ways to accomplish this, but using collections might be the simplest if you’re a beginner.

    • If you want to un-select unwanted files, pass an empty string in the array position of the file to leave behind.

  5. awkwardengineer

    I ran this with Solidworks 2017 SP3. The files were placed in the specified directory, but the Revision didn’t attach. The Revision field is populated in the assembly and in the components.

    • awkwardengineer

      whoops. it only added the rev for the assembly level document. not the components.

    • Sam said he got this working by making this changes:

      “First, I had to make sure I set “custom fields” vs “configuration specific” fields. Second, I think there was a GET4 method that has been deprecated, I think I replaced it.”

  6. chrisc

    Hi keith,
    I tried this macro and it works great
    Setting strCustProp as “Revision”, all assembly and part files names end up with a letter of revision but not the drawing (.slddrw)
    how to change the code so all the drawing files names also end of with strCusProp
    Thank you

  7. jglassford

    The script seems to work fine as long as you aren’t trying to pack and go an assembly with sub-assemblies. If there are any sub-assemblies, then none of the files get renamed and you just get a verbatim copy of the original filenames.

Questions and Comments

You must be logged in to post a comment.