Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations JAE on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

BOM manipulation

Status
Not open for further replies.

dogarila

Mechanical
Joined
Oct 28, 2001
Messages
594
Location
CA
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?
 
why not just use the excel based BOM still?
 
Apparently SolidWorks will drop support for Excel based BOM so we would like to rewrite the macro.
 
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.
 
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
 
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
 
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 [pc2]
3DVision Technologies

faq731-376
faq559-716 - SW Fora Users
 
Hi, Yogibear:

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

Thanks,

Alex
 
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
 
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
 
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

 
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.
 
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.
 
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
 
Hi, Regg:

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

Alex
 
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 [spin]
Meggitt Airdynamics Inc.
Dell Precision 370
SW2004 Pro SP4.1
XP Pro SP2.0
NIVIDA Quadro FX 1300

 
welcome back macduff![shocked]
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
 
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.
 
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 [spin]
Meggitt Airdynamics Inc.
Dell Precision 370
SW2004 Pro SP4.1
XP Pro SP2.0
NIVIDA Quadro FX 1300

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top