I forgot to say the BOM is in Assembly.
Now I tried to put the BOM into a Drawing, and it is working in this case.
But why doesn't works in Assembly?
did you try GetTableAnnotations() instead of IGetTableAnnotations()
From help of IGetTableAnnotations()
- VBA, VB.NET, C#, and C++/CLI: Not supported
Are you sure that your BomTableAnn is not equal to nothing?
I've tried GetTableAnnotations, but in this case I got 'System.InvalidCastException' error when I try to set it's result to variable BomTableAnn (SldWorks.BomTableAnnotation).
If I use BomTableAnn As Object that is OK, but in this case later I can't use it's properties and funtions.
With IGetTableAnnotations everything works fine except this Asm Bom column show/hide, and yes I checked BomTableAnn is not equal to nothing.
I do not know if you can use "index" in method GetTableAnnotations(). There is no index option in help.
BomTableAnn = BomFeature.IGetTableAnnotations(1)
Try this procedure below. I did not test it.
Dim vTableArr As Object
Dim vTable As Object
Dim swTable As TableAnnotation
vTableArr = swBomFeat.GetTableAnnotations
For Each vTable In vTableArr
swTable = vTable
.. do job with swTable
Thank you the try,but same effect :/
it works for me.
ColumnCount will change everytime when you hide or unhide column.
public void HideColumn()
IModelDoc2 swModel = null;
IFeature swFeat = null;
BomFeature swBomFeat = null;
object tables = null;
TableAnnotation swTable = null;
swModel = (IModelDoc2)iSwApp.ActiveDoc;
swFeat = swModel.FirstFeature();
while (swFeat != null)
if (swFeat.GetTypeName2() == "BomFeat")
swBomFeat = (BomFeature)swFeat.GetSpecificFeature2();
Console.WriteLine("number of ann : " + swBomFeat.GetTableAnnotationCount());
tables = swBomFeat.GetTableAnnotations();
foreach (var table in tables)
swTable = (TableAnnotation)table;
Console.WriteLine("number of columns visible " + swTable.ColumnCount);
Console.WriteLine("number of columns " + swTable.TotalColumnCount);
for (int i = 0; i < swTable.TotalColumnCount; i++)
if (i > 0)
swTable.ColumnHidden[i] = true;
swFeat = swFeat.GetNextFeature();
It works thank you.
I check ColumnCount before and after I set ColumnHidden(i) to false, and if it is different I know the column was hidden
Btw I wonder why is this so complicated, but at least there is some method