So, I have some code that inserts a BOM into a drawing. I'm using a set of code taken from the solidworks help. It works, except that it formats the BOM oddly. Any ideas why it is ending up so large? Check the picture for comparison.
Thanks Friends,
Trevor
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swSelMgr As SldWorks.SelectionMgr
Dim swFeatMgr As SldWorks.FeatureManager
Dim swView As SldWorks.View
Dim swBomAnn As SldWorks.BomTableAnnotation
Dim swBomFeat As SldWorks.BomFeature
Dim anchorType As Long
Dim bomType As Long
Dim configuration As String
Dim tableTemplate As String
Dim Names As Variant
Dim visible As Variant
Dim boolStatus As Boolean
Dim swDraw As SldWorks.DrawingDoc
Dim swSheet As SldWorks.Sheet
Dim swTableAnn As SldWorks.TableAnnotation
Dim nbrTableAnn As Long
Dim vTableAnn As Variant
Dim nbrRows As Long
Dim rowHeight As Long
Dim i As Long
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swSelMgr = swModel.SelectionManager
Set swFeatMgr = swModel.FeatureManager
Set swDraw = swModel
Set swSheet = swDraw.GetCurrentSheet
Set swSelMgr = swModel.SelectionManager
'Select View
swModel.ClearSelection2 True
Set swView = swDraw.GetCurrentSheet.GetViews()(0)
swView.SetName2 ("Drawing View1")
boolStatus = swDraw.ActivateView("Drawing View1")
Set swView = swDraw.ActiveDrawingView
'Insert BOM Table
anchorType = swBOMConfigurationAnchor_BottomRight
bomType = swBomType_TopLevelOnly
configuration = "Default"
tableTemplate = "C:\KMI-Vault\Admin Files\SW - Templates\TABLES\kTable.sldbomtbt"
Set swBomAnn = swView.InsertBomTable3(True, Empty, Empty, anchorType, bomType, configuration, tableTemplate, False)
swModel.ClearSelection2 True
Set swBomFeat = swBomAnn.BomFeature
Names = swBomFeat.GetConfigurations(False, visible)
visible(0) = True
boolStatus = swBomFeat.SetConfigurations(True, visible, Names)
swFeatMgr.UpdateFeatureTree
'get row information
nbrTableAnn = swBomFeat.GetTableAnnotationCount
vTableAnn = swBomFeat.GetTableAnnotations
For i = 0 To (nbrTableAnn - 1)
Set swTableAnn = vTableAnn(i)
nbrRows = swTableAnn.RowCount - 1
Next i
'For i = 0 To (nbrRows - 1)
' rowHeight = swTableAnn.SetRowHeight((i - 1), 0.003125, swTableRowColChange_TableSizeCanChange)
'Next i
End Sub
SolidworksApi macros