×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

BOM manipulation

BOM manipulation

BOM manipulation

(OP)
I have a macro that starts from an Excel file, connects to SW, finds and opens an Excel-based BOM, reads the information, then goes back to Excel and populates the file with the content of the BOM. Obviously this macro doesn't work with the new built in BOM. Is there a way I could achieve the same with this new BOM type? What should I use instead of:

retval = View.GetBomTable ( )


to get the same result?

RE: BOM manipulation

why not just use the excel based BOM still?

RE: BOM manipulation

(OP)
Apparently SolidWorks will drop support for Excel based BOM so we would like to rewrite the macro.

RE: BOM manipulation

They claimed they were going to drop it in 2004 when they added their own table.  There was such an uproar during beta because the new table lacked so much Excel functionality that they left it in.  

I would assume it will stay until their table can do most everything they know customers are using the Excel BOM for.

RE: BOM manipulation

You can always save your BOM as a txt file, and read it again with EXCEL.  Not perfect though.  That is the way I have been using.

Alex

RE: BOM manipulation

I've got an excel macro to read the SW BOM and copy it to excel.  Post back if you want it.  I think I found it somewhere and did some modifications

RE: BOM manipulation

Thanks MElam! I remember that now in SW04, But I agree I don't think they will drop it funtil their BOM has better functionality.


rgrayclamps,

FYI - You can save the BOM as a *.CSV file and open it in Excel. That's better then a txt file.


Regards,

Scott Baugh, CSWP
3DVision Technologies

www.3dvisiontech.com
www.scottjbaugh.com
FAQ731-376
FAQ559-716 - SW Fora Users

RE: BOM manipulation

Hi, Yogibear:

Could you post your Excel macro to read the SW BOM and copy it to Excel?

Thanks,

Alex

RE: BOM manipulation

I'm interested also. We do our BOM's in Access. I am trying to figure out how to import Excel BOM's into Access.
If I can create SW BOM's in Excel base, then import to Access, that would be great.

Chris
Sr. Mechanical Designer, CAD
SolidWorks 05 SP0.1 / PDMWorks 05
ctopher's home site

RE: BOM manipulation

Hi, Chris:

I've switched from Excel based BOM to native SolidWorks table based BOM a year ago.  It is a matter of time that SolidWorks is going to drop the Excel based BOM.

Just my $.02.

Alex

RE: BOM manipulation

Here you go.  We switched cause we heard they SW was dropping Excel as well.  Just wish SW's worked as good as Excel.
Side note.  We do our boms from #1 on bottom.  There is a data sort function in this code so your's might come in upside down.

Hope it works for you.

Option Explicit
Sub main()

    Dim swApp                   As New SldWorks.SldWorks

    Dim swModel                 As SldWorks.ModelDoc2

    Dim swDraw                  As SldWorks.DrawingDoc

    Dim swView                  As SldWorks.View

    Dim swTable                 As SldWorks.TableAnnotation

    Dim bRet                    As Boolean

    

    'Set swApp = Application.SldWorks

    Set swModel = swApp.ActiveDoc

    Set swDraw = swModel

  
    Set swView = swDraw.GetFirstView

    Do While Not swView Is Nothing

        Set swTable = swView.GetFirstTableAnnotation

        Do While Not swTable Is Nothing

            ProcessTable swApp, swModel, swTable
                   
            Set swTable = swTable.GetNext

        Loop
             Set swView = swView.GetNextView

    Loop

End Sub


Sub ProcessTable _
(swApp As SldWorks.SldWorks, swModel As SldWorks.ModelDoc2, swTable As SldWorks.TableAnnotation)

    Dim swAnn                   As SldWorks.Annotation

    Dim nNumCol                 As Long

    Dim nNumRow                 As Long

    
    Dim i                       As Long

    Dim j                       As Long

    Set swAnn = swTable.GetAnnotation

    

    nNumCol = swTable.ColumnCount

    nNumRow = swTable.RowCount

    ' Show the name and type of table

   ' Debug.Print "    " & swAnn.GetName & " <" & swTable.Type & ">"

    

    ' Get the table contents

    For i = 0 To nNumRow - 1

       
        For j = 0 To nNumCol - 1


            Cells(i + 1, j + 1).Value = swTable.Text(i, j)
        Next j

    Next i
    
Range("A1:D12").Select
    Selection.Sort Key1:=Range("A1"), Order1:=xlAscending, Header:=xlGuess, _
        OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom


End Sub

RE: BOM manipulation

(OP)
Is there a way to check the type of the table?

The above piece of code works fine if there is no other table in the drawing but the BOM, or BOM is the last table inserted and has more rows and columns then other tables.

If after the inserting the BOM, the user inserts a revision table, this last one gets processed last and the values in the excel file cells are overwritten. I suppose something similar would happen if a hole table was present in the drawing.

RE: BOM manipulation

Glad you caught that because I haven't tried it w/ another table in it.  If someone know's a way I would be interested as well.  I just found the macro and edited it, not responsible for creating it.

RE: BOM manipulation

Scott,

CSV files do not import correctly if you have a comma in the part description (it creates an extra column) or do you know of a way to get around this?

Regg

RE: BOM manipulation

Hi, Regg:

I tried both format.  I found *.txt format easier.

Alex

RE: BOM manipulation

Where did everyone hear that SW is going to drop the Excel based BOM's. I hope that they don't, because the SW BOM still needs alot of work.

Scott, do you any details on this? Are they dropping Excel in SW2006? Please advise.

Thanks

Macduff
Meggitt Airdynamics Inc.
Dell Precision 370
SW2004 Pro SP4.1
XP Pro SP2.0
NIVIDA Quadro FX 1300

RE: BOM manipulation

welcome back macduff!
I agree, I have not heard it anywhere but here. I hope it does not go away.

Chris
Sr. Mechanical Designer, CAD
SolidWorks 05 SP0.1 / PDMWorks 05
ctopher's home site

RE: BOM manipulation

I don't think they've dropped or are going to drop Excel they are just focusing on developing there own process so they can have more control.  I agree though that the SW bom does need some tweeking still.

RE: BOM manipulation

My biggest complaint is the size of these monster BOM's
(as I call them). I know you can modify the heights and widths, but only to a point. Example: the width of "QTY" doesn't need to be 3/4 of an inch (approx) when you only "1" item for that part. There must be some kind of value around the text for "QTY" that doesn’t allow you to modify the frame narrower. Spent countless hours modifying and saving only to find out when reinserting my save SW BOM templates, they go back to there default size. Until then.............I'm sticking with Excel.

Have a good day all,

Macduff
Meggitt Airdynamics Inc.
Dell Precision 370
SW2004 Pro SP4.1
XP Pro SP2.0
NIVIDA Quadro FX 1300

RE: BOM manipulation

I've has that problem also, inserting templates and they change. I turned it in to my VAR and SW 2 weeks ago, still no reply.

Chris
Sr. Mechanical Designer, CAD
SolidWorks 05 SP0.1 / PDMWorks 05
ctopher's home site

RE: BOM manipulation

We are still using the Excel based BOM because its smaller.  The wide columns are my biggest beef with the SW based BOM.  Drawing space is hard to come by on 11x17 paper so the smaller the BOM the better.

I'm sort of bummed out with the new SW2005 release though because the Excel BOM don't seem to update custom property columns.  We are having to delete the existing Excel BOM and replace it new to get it to update.

RE: BOM manipulation

(OP)
Based on Regg response in this Thread559-119636 I inserted these lines (in blue) in the code:

CODE

 Do While Not swView Is Nothing
        Set swTable = swView.GetFirstTableAnnotation
        Do While Not swTable Is Nothing
          If swTable.Type = 2 Then
            ProcessTable swApp, swModel, swTable
          End If
            Set swTable = swTable.GetNext
        Loop
             Set swView = swView.GetNextView
    Loop

Now my macro processes only BOMs and ignores other type of tables.

RE: BOM manipulation

MrMiller,
I do not know if this will help, but we had the same problem with our Excel BOM not updating. What I had to do was turn on our main view, that was off the sheet, we used to create our BOM. We would put a configuration on the face of the drawing and the full default view hidden off the sheet to create the Excel BOM and fill in the title block.

Bradley

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources