• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    Autodesk Inventor

    Reply
    Active Member
    Herve_l
    Posts: 6
    Registered: ‎12-01-2010
    Accepted Solution

    Populating an existing spreadsheet with BOM data using iLogic

    399 Views, 3 Replies
    12-06-2010 12:33 PM

    I already have a cut list  template in Excel that calculates my stock material,  volume,  etc when I populate the appropriate fields. It is also connected to an access database that has various information that automatically generates the final price of my product based on various suppliers prices and data with whom I do business with and so on.

     

    I would like to know if there was a way with iLogic to make Inventor populate specific cells with information found in the BOM such as: description; Qty and custom iProperties value like dimensions, etc?

     

    The reason why I'm making a new topic out of this is that I have read previous post about the issue, but they were regarding "exporting the BOM to an excel". I, on the other hand, would like to populate an already existing spreadsheet with data from the BOM

    After exploring the iLogic snippets, I've only found the "export" option. It referenced the API snippets, but with limited programming knowledge there is not much I can understand.

     

     

    Thank you in advance. 

     

    Please use plain text.
    Employee
    Posts: 932
    Registered: ‎02-24-2009

    Re: Populating an existing spreadsheet with BOM data using iLogic

    12-06-2010 06:26 PM in reply to: Herve_l

    You should be able to use code from this sample rule:

     


    Dim bomFileName As String = ThisDoc.ChangeExtension(".xls")
    ThisBOM.Export("Parts Only", bomFileName, kMicrosoftExcelFormat)

    GoExcel.Open(bomFileName, "Sheet1")
    Dim excelSheet = GoExcel.Application.ActiveWorkbook.ActiveSheet
    Dim valArray As Array = CType(excelSheet.UsedRange.Value, Array)
    GoExcel.Close()

    Dim outputFileName As String = IO.Path.Combine(ThisDoc.Path, "CopiedBom.xls")

    GoExcel.Open(outputFileName, "Sheet1")
    For row As Integer = 1 To valArray.GetUpperBound(0)
    If (valArray(row,1) = Nothing) Then Exit For
    For columnIndex As Integer = 1 To valArray.GetUpperBound(1)
    Dim column As String = Chr(Asc("A"c) + columnIndex-1)
    'Trace.WriteLine("column = " & column)
    GoExcel.CellValue(outputFileName, "Sheet1", column & row) = valArray(row, columnIndex)
    Next
    Next
    GoExcel.Save()
    GoExcel.Close()

    This will export the BOM and then read all the data and copy it to another Excel file (CopiedBom.xls, which must already exist).  You can adapt it to extract the data you want (from valArray) and copy it to specific cells in the output sheet.

     



    Mike Deck
    Software Developer
    DLS - Mechanical Design
    Autodesk, Inc.

    Please use plain text.
    Active Member
    Herve_l
    Posts: 6
    Registered: ‎12-01-2010

    Re: Populating an existing spreadsheet with BOM data using iLogic

    12-06-2010 10:39 PM in reply to: MjDeck

    Thank you.

    I understand the general process now

    Please use plain text.
    New Member
    Posts: 1
    Registered: ‎08-22-2012

    Re: Populating an existing spreadsheet with BOM data using iLogic

    12-12-2012 04:12 AM in reply to: MjDeck

    I would like to do exactly the same, but as i'm a complete newby in writing code, and so i have problems with adjusting the code to my preferances.

     

    I need to be able to write from the BOM-list only the 'Partnumbers' from 'assembly A' to 'row 4, column E' on 'Sheet1', and 'Assembly B' to the same cells, only on 'Sheet2'.

     

    I tried multiple times to adjust this myself, but the lack of experiance gets me nowhere right now.

     

    Could you point me in the right direction?

     

     

    Please use plain text.