Hello
I have just made a macro, that is exporting an Indented BOM table from any 3D file, and that works :-)
I what the Indented BOM to be with detailing index numbering and to do what i found some other thread that lead me to:
2013 SOLIDWORKS API Help - NumberingTypeOnIndentedBOM Property (IBomFeature)
But when I'm running this I end up with a Compile error... I have tried to uncheck the library files and recheck them, but I still gets the compile error:
My references:
My code:
'Get create an Indented BOM list and export it in fileformat .txt, from any 3D file.
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swBOMTable As SldWorks.BomTableAnnotation
Dim swTable As SldWorks.TableAnnotation
Dim swAnn As SldWorks.Annotation
Const BOMTemplate As String = ""
Const OutputPath As String = "C:\Tempfile\"
Dim ConfigName As String
Dim sModelName As String
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
'Create the direktory if it dosn't exit
If Len(Dir(OutputPath, vbDirectory)) = 0 Then
MkDir (OutputPath)
End If
If Len(Dir(OutputPath, vbDirectory)) = 0 Then
MkDir (OutputPath)
End If
''''''''******This part of the code is copy paste from SolidWorks API help (NumberingTypeOnIndentedBOM Property (IBomFeature))*****''''''''''
Dim instance As IBomFeature
Dim value As System.Integer
instance.NumberingTypeOnIndentedBOM = value
value = instance.NumberingTypeOnIndentedBOM
''''''''***********************************''''''''''''''''''''''******************************'''''''''''''''
'Choose Configuration
ConfigName = swModel.GetActiveConfiguration.name
'Generate and choose BOM type
Set swBOMTable = swModel.Extension.InsertBomTable(BOMTemplate, 0, 0, swBomType_e.swBomType_Indented, ConfigName)
Set swTable = swBOMTable
'Gets name from 3D file and remove extension
sModelName = Left(swModel.GetTitle, InStrRev(swModel.GetTitle, ".") - 1)
'Save file in path and create filename
swTable.SaveAsText OutputPath & "BOMTable_Indented_" & sModelName & ".txt", vbTab
Set swAnn = swTable.GetAnnotation
swAnn.Select3 False, Nothing
swModel.EditDelete
End Sub
The error message:
I'm running, SolidWorks 2013 sp3
Any idea of what I doing wrong or missing?
Thanks
/Bo
SolidworksApi macros