I'm working on updating a macro written a few years ago. The macro takes a General Table (or SW Assembly BOM) on a drawing sheet which is a BOM table and converts it to a CSV file. In the past I had it set so that the user had to pre-select the table before running the macro. I'm rewriting the macro to add some more functionality and while I'm at it I'm trying to make it so you do not have to pre-select the table.
I would like to be able to have the user have a drawing open, run the macro and it does the following basic routine:
Find the name of all General Tables in the drawing
Look at how many columns are in each table that exists
If it has 6 columns, look at the first cell and see if it has certain text, if it does then that is the Bom table that I want.
Then I would go through my routine to export the data.
(We use General Tables for items that are not modeled and do not show up in the SW Assembly BOM)
I'm using VB.net currently for this macro.
I know I can select a table with a known name using a command like this:
Dim swModel As ModelDoc2
Dim swDrawing As DrawingDoc
Dim swAssembly As AssemblyDoc
Dim status As Boolean
Dim swTableAnnotation As TableAnnotation
Dim swGeneralTableFeature As GeneralTableFeature
Dim swSelectionMgr As SelectionMgr
Dim swModelDocExt As ModelDocExtension
Dim swFeature As Feature
'Use currently opened document
swModel = swApp.ActiveDoc
'Assume GeneralTable1 is the table we want, and select it
swModelDocExt = swModel.Extension
status = swModelDocExt.SelectByID2("General Table1", "GENERALTABLEFEAT", 0, 0, 0, False, 0, Nothing, 0)
swSelectionMgr = swModel.SelectionManager
swGeneralTableFeature = swSelectionMgr.GetSelectedObject6(1, -1)
swFeature = swGeneralTableFeature.GetFeature
The problem is the table will not always be General Table1... It could be 2, 3, 5... and it may be that 1, 2, and 3 don't exist because someone created one and then deleted it. So I'm trying to avoid simply running through a loop guessing the names, if possible. With genuine BOM features there is a Next feature command that you can go through a list of them, but I cannot seem to figure out how to do the same for General Tables since they don't seem to show up in the feature list.