Thanks, this is good information, I am hoping that there was a simpler method to select the Bill of Material on the Active Sheet.
I hit that road bump some time ago, it's either of two ways (which were already described):
- Traverse all the views from the active sheet and get an array of the table annotations for each view. This is the fastest way.
- Traverse the entire drawing document feature tree and then use the GetOwnerFeature on features with table annotation type and check see if their owner is a sheet has the name of the active sheet.
This begs the question. How would you select a BOM if you had multiple BOMs in the active sheet. Are there selection criteria?
Fortunately I don't have multiple BOMs on one sheet, is there a way to look at the table properties?
This will do it: 2018 SOLIDWORKS API Help - GetColumnCustomProperty Method (IBomTableAnnotation)
I think you'll get a null (nothing in VBA/VB.NET) if you are querying the quantity column.
SolidWorks API Video Tutorials
Set TableAnn = View.GetFirstTableAnnotation
Do While Not TableAnn Is Nothing
If TableAnn.Type = 2 Then '2 is the bom table type
Set Bom = TableAnn
Set TableAnn = TableAnn.GetNext
If Bom Is Nothing Then
MsgBox "BOM was not found"
'do something here