Automate download of CAD files to send to Supplier

Good evening, my Purchasing team is constantly getting Suppliers to quote building a certain assembly. In order to prepare the quote, the Supplier needs all of the SolidWorks CAD files from Aras. This means the parent SLDASM and all related child SLDPRT files. Currently, the Purchasing team is downloading these files 1-by-1 from Aras, before emailing them to the Supplier.

This seems like a fairly common industry task. Has anyone done any development to automate this, specifically the recursive file download? I've seen a GitHub project to download multiple file attachments via a single action, but this is a slight different use case.

Thanks in advance!

Paul Sheehy

  • Hi Paul,

    The Download Multiple Files community project works by downloading the files a user has selected in the grid, but you can use the same general process for downloading multiple files from a structure.

    You can split this into a couple smaller problems.

    1. Do a recursive call to get all of the items in the CAD Structure
    2. Get a list of Files that need to be downloaded
    3. Download all of the Files in the list to the server

    The first problem of performing a recursive call can be solved by using the GetItemRepeatConfig action described in this blog post. We use the Part -> Part BOM structure as the example in that blog post, but you can easily rewrite the AML to work with CAD -> CAD Structure.

    The second is to get a list of all of the Files that need to be downloaded. You can do this pretty simply by using an XPath selector like //native_file/text() to avoid manually iterating through the entire structure. Depending on your exact AML query, this will get you a list of IDs for the Files that exist in your CAD Structure.

    For the last step of downloading all the files, you can look at the Create Zip on Server method of the Download Multiple Files project for some sample code that uses the Aras.IOME.CheckoutManager class to download a collection of File items to a location on the server. You can find a full reference of this class in the API guide available by logging into Aras Innovator as an admin and selecting Admin > API Reference (.NET) in the user menu. Once the files are in a common location on the server, you can package them up however you want to deliver them to the supplier.


    Chris

    Christopher Gillis

    Aras Labs Software Engineer

  • Chris, thanks for the great feedback! I've got the AML query working to get all the child items:

    <Item type='CAD' select='item_number, native_file' action='GetItemRepeatConfig' id='{CAD parent id here}'>

    <Relationships>

    <Item type='CAD Structure' select='related_id' repeatProp='related_id' repeatTimes='0'></Item>

    </Relationships>

    </Item>

    But my xPath skills aren't very good. In trying to take those results and get a list of FileIDs, via:

    Item fileIds = qryResults.getItemsByXPath("//Item[@type='CAD']/native_file/text()");

    I get an error that the xPath does not resolve to Item nodes. Do I use another function instead of getItemsByXPath?

    Thanks!

    Paul