Hi,
I am trying to insert a fresh BOM table to my drawing with macro.
I am using the code below. But when i run it, it places the table to bottom left and also showing all the configuration i have on that assembly.
How should i modify it so that it will be positioned based on the anchorpoint set on the sheetformat, and also only listed the current configuration of the drawing view?
Thanks for your time and help.
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 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
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
'Select View
swModel.ClearSelection2 True
Set swView = swDraw.GetCurrentSheet.GetViews()(0)
'Insert BOM Table
anchorType = SwConst.swBOMConfigurationAnchorType_e.swBOMConfigurationAnchor_BottomRight
bomType = SwConst.swBomType_e.swBomType_TopLevelOnly
swModel.ClearSelection2 True
configuration = "CLOSED-STD BIFOLD"
tableTemplate = "P:\Data\Engineering\SOLIDWORKS\TEMPLATE\AM BOM TABLE.sldbomtbt" '"C:\KMI-Vault\Admin Files\SW - Templates\TABLES\kTable.sldbomtbt"
Set swBomAnn = swView.InsertBomTable2(False, 0, 0, anchorType, bomType, configuration, tableTemplate)
Set swBomFeat = swBomAnn.BomFeature
Names = swBomFeat.GetConfigurations(False, visible)
visible(0) = True
boolStatus = swBomFeat.SetConfigurations(True, visible, Names)
swFeatMgr.UpdateFeatureTree
End Sub
SolidworksApi macros