BOM Experts - Possible to export SW BOM?

Discussion in 'SolidWorks' started by jjs, Dec 21, 2005.

  1. jjs

    jjs Guest

    Still in two minds about sw BOM or Excel BOM

    The Excel BOM can be exported but is a 'pig' to work with on screen
    within SW. I seem to remember before 2006 that you could work on a
    Excell BOM outside SW and so save on all the graphic problems of
    scalling it to be visible on a screen oir am I dreaming.


    SW BOM easier to use on screen - but can I export it so I can import
    data into a seperate word file or excell file for documentation?


    Thanks in advance for any pointers

    TTFN



    Jonathan
     
    jjs, Dec 21, 2005
    #1
  2. jjs

    TOP Guest

    I wrote a macro that generates the data I need apart from any SW
    functionality.
     
    TOP, Dec 21, 2005
    #2
  3. jjs

    jjs Guest


    Would you be willing to share it ?

    Does it export it as a form that can be easily tabulated in another
    common programme and can be used by a non computer literate person
    like myself?


    TTFN

    Jonathan
     
    jjs, Dec 21, 2005
    #3
  4. jjs

    rider89 Guest

    in sw2005 you could save the BOM as ".txt" file, then import that into
    Excel.
    Everything is fine except column widths, and text justification, both of
    which
    just takes a few seconds to redo in Excel.
    I would assume sw2006 still does this.

    bill
     
    rider89, Dec 21, 2005
    #4
  5. jjs

    jjs Guest


    Thanks for that Bill - I learn something everyday - It worked fine
    and as you say it takes no time to layout the excel once the data is
    imported.

    TTFN

    Jonathan
     
    jjs, Dec 21, 2005
    #5
  6. jjs

    George Guest

    Just last week there was a similiar thread.

    Search for:

    TIP: Import SW native BOM into Excel

    simply highlight the BOM table then
    File/SaveAs (defaults to template but pull down for .csv or .txt
     
    George, Dec 21, 2005
    #6
  7. jjs

    George Guest

    Just last week there was a similiar thread.

    Search for:

    TIP: Import SW native BOM into Excel

    simply highlight the BOM table then
    File/SaveAs (defaults to template but pull down for .csv or .txt
     
    George, Dec 21, 2005
    #7
  8. jjs

    Matze Guest

    Below you find the macro is use for exporting directly into excel for
    further processing.
    It is snatched from from the api help and just slightly modified. All it
    does is open excel
    and copy the bom into a new sheet (SWX2005).

    Matze

    ==============================================

    Option Explicit

    Public Enum swBOMConfigurationAnchorType_e
    swBOMConfigurationAnchor_TopLeft = 1
    swBOMConfigurationAnchor_TopRight = 2
    swBOMConfigurationAnchor_BottomLeft = 3
    swBOMConfigurationAnchor_BottomRight = 4
    End Enum

    Public Enum swBomType_e
    swBomType_PartsOnly = 1
    swBomType_TopLevelOnly = 2
    swBomType_Indented = 3
    End Enum

    Public Enum swTableSplitDirection_e
    swTableSplit_None = 0
    swTableSplit_Horizontal = 1
    swTableSplit_Vertical = 2
    End Enum

    Dim xlApp As Object

    Sub main()
    Dim swApp As SldWorks.SldWorks
    Dim swModel As SldWorks.ModelDoc2
    Dim swDraw As SldWorks.DrawingDoc
    Dim swSheet As SldWorks.Sheet
    Dim swFeat As SldWorks.Feature
    Dim swBomFeat As SldWorks.BomFeature
    Dim sPathName As String
    Dim nNumSheet As Long
    Dim nRetval As Long
    Dim i As Long
    Dim bIsFirstSheet As Boolean
    Dim bRet As Boolean

    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc
    Set swDraw = swModel
    bIsFirstSheet = True

    Set xlApp = Nothing
    On Error Resume Next
    Set xlApp = GetObject(, "Excel.Application")
    On Error GoTo 0
    If xlApp Is Nothing Then
    Set xlApp = CreateObject("Excel.Application")
    End If

    xlApp.Visible = True
    xlApp.Workbooks.Add

    Set swFeat = swModel.FirstFeature
    Do While Not swFeat Is Nothing
    If "BomFeat" = swFeat.GetTypeName Then
    Set swBomFeat = swFeat.GetSpecificFeature2
    ProcessBomFeature swApp, swModel, swBomFeat
    End If
    Set swFeat = swFeat.GetNextFeature
    Loop
    For i = 1 To 5
    xlApp.ActiveWorkbook.ActiveSheet.Columns(i).AutoFit
    Next i
    Set xlApp = Nothing
    End Sub

    Sub ProcessBomFeature(swApp As SldWorks.SldWorks, swModel As
    SldWorks.ModelDoc2, _
    swBomFeat As SldWorks.BomFeature)

    Dim swFeat As SldWorks.Feature
    Dim vTableArr As Variant
    Dim vTable As Variant
    Dim swTable As SldWorks.TableAnnotation
    Set swFeat = swBomFeat.GetFeature

    vTableArr = swBomFeat.GetTableAnnotations
    For Each vTable In vTableArr
    Set swTable = vTable
    ProcessTableAnn swApp, swModel, swTable
    Next vTable
    End Sub

    Sub ProcessTableAnn(swApp As SldWorks.SldWorks, swModel As
    SldWorks.ModelDoc2, _
    swTableAnn As SldWorks.TableAnnotation)

    Dim nNumRow As Long
    Dim nNumCol As Long
    Dim nNumHeader As Long
    Dim sHeaderText() As String
    Dim i As Long
    Dim j As Long
    Dim k As Long
    Dim nIndex As Long
    Dim nCount As Long
    Dim nStart As Long
    Dim nEnd As Long
    Dim nSplitDir As Long

    nNumHeader = swTableAnn.GetHeaderCount
    nSplitDir = swTableAnn.GetSplitInformation(nIndex, nCount, nStart, nEnd)
    If swTableSplit_None = nSplitDir Then
    nNumRow = swTableAnn.RowCount
    nNumCol = swTableAnn.ColumnCount
    nStart = nNumHeader
    nEnd = nNumRow - 1
    Else
    nNumCol = swTableAnn.ColumnCount
    If 1 = nIndex Then
    nStart = nStart + nNumHeader
    End If
    End If

    ReDim sHeaderText(nNumCol - 1)
    For j = 0 To nNumCol - 1
    xlApp.ActiveWorkbook.ActiveSheet.Cells(1, j + 1).Value =
    swTableAnn.GetColumnTitle(j)
    sHeaderText(j) = swTableAnn.GetColumnTitle(j)
    Next j

    For j = nStart To nEnd
    For k = 0 To nNumCol - 1
    xlApp.ActiveWorkbook.ActiveSheet.Cells(j + 1, k + 1).Value =
    swTableAnn.Text(j, k)
    Next k
    Next j
    End Sub
     
    Matze, Dec 21, 2005
    #8
  9. Jonathan,

    I had this problem a while back and our local dealer had to scatch his head for
    a while.
    It's somewhere you would never think to look,
    For the life of me I cannot see why programmers do this sort of shit to the
    users??

    Right click on BOM Table Header at top
    Choose Save as Template,
    Under save as type there are options for

    *.sldbomtbt
    *.txt
    *.csv
     
    Neville Williams, Dec 22, 2005
    #9
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.