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?
retval = View.GetBomTable ( )
to get the same result?






RE: BOM manipulation
RE: BOM manipulation
RE: BOM manipulation
I haven't heard anything myself, but I never asked the question either.
Regards,
Scott Baugh, CSWP
3DVision Technologies
www.3dvisiontech.com
www.scottjbaugh.com
FAQ731-376
FAQ559-716 - SW Fora Users
RE: BOM manipulation
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
Alex
RE: BOM manipulation
RE: BOM manipulation
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
Could you post your Excel macro to read the SW BOM and copy it to Excel?
Thanks,
Alex
RE: BOM manipulation
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
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
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
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
RE: BOM manipulation
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
I tried both format. I found *.txt format easier.
Alex
RE: BOM manipulation
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
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
RE: BOM manipulation
(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
Chris
Sr. Mechanical Designer, CAD
SolidWorks 05 SP0.1 / PDMWorks 05
ctopher's home site
RE: BOM manipulation
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
CODE
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
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