I am asking for your help once again. I'm looking for a Macro to insert a Bom SW in our drawings . Ideally, I would like to be able to indicate the path where to look for the BOM and indicate which BOM to take from the directory.
What for? We are implementing DriveWorks within our company and we want to use as much as possible of what is already done to speed up the process and our BOMs are part of it. If you have something that I can adapt to our needs it would be appreciated.
When you say "Ideally I would like to be able to indicate the path where to look for the BOM and indicate which BOM to take from the directory", is it the BOM template (.sldbomtbt file) or a BOM already filled?
In the link below, you will find how to integrate a BoM into your plan via macro: https://help.solidworks.com/2015/english/api/sldworksapi/Insert_BOM_Table_Example_VB.htm
Otherwise I recently wrote this code to position a general table at a specific location according to the size of the plan, if it can help you:
Sub InsertRevisionTable()
Dim swApp As SldWorks.SldWorks Dim swModel As SldWorks.ModelDoc2 Dim swDrawing As SldWorks.DrawingDoc Dim swTable As SldWorks.TableAnnotation Dim swSheet As SldWorks.Sheet Dim vSheetNames as Variant Dim vSheetProperties as Variant Dim sTemplateName As String Dim i as Integer Dim lErrors As Long Dim lWarnings As Long Dim height As Single Dim width As Single
Set swApp = Application.SldWorks Set swModel = swApp.ActiveDoc Set swDrawing = swModel
'Verify Sheet Format Set swSheet = swDrawing.GetCurrentSheet vSheetProperties = swSheet.GetProperties If vSheetProperties(0) = 12 Then 'Format A3 height = 0.015985 width = 0.010362 ElseIf vSheetProperties(0) = 7 Then ' A4 Format height = 0.015 width = 0.057 ElseIf vSheetProperties(0) = 9 Then 'Format A2 height = 0.015985 width = 0.010362 End If ' End If 'Next i 'End If
Set swTable = swDrawing.InsertTableAnnotation2(False, height, width, swBOMConfigurationAnchor_BottomLeft, "J:\Solidworks\Templates\Revision-Table.sldtbt", 4, 2)
Here's a macro that you need to be able to start from to do what you want to do. This allows you to insert either a nomenclature or a general table depending on the choice of the type of file that is selected in the template file selection window.