How Can I Access Interface of GetBomTable?

I tried the code block below, but the result is always null. I also examined the diagram, so I tried to access it from the view interface.
How can access that interface?

string fileName = @"file.SLDDRW";

ModelDoc2 SwModel = swApp.OpenDoc6(fileName, (int)swDocumentTypes_e.swDocDRAWING, (int)swOpenDocOptions_e.swOpenDocOptions_Silent, "", ref errors, ref warnings);
DrawingDoc swDrawDoc = (DrawingDoc)SwModel;

for (int i = 0; i < swDrawDoc.GetSheetCount(); i++)
{
	string sheetName = swDrawDoc.GetSheetNames()[i];
	Sheet swSheet = swDrawDoc.Sheet[sheetName];

	//swDrawDoc.ActivateSheet(swSheet.GetName());
	//swDrawDoc.SetSheetsSelected(swSheet.GetName());

	object[] views = (object[])swSheet.GetViews();

	foreach (var view in views)
	{
		View swView = (View)view;
		Debug.Print("View: " + swView.Name);
		if (swView.GetBomTable() is BomTable bmTable)
		{
			bmTable.Select(false, 0);
			bmTable.Attach3();
			//var xyz = bmTable.IGetExtent();
			var xyz = bmTable.GetExtent();
			bmTable.Detach();
		}
	}
}

BomTables aren’t in use anymore, we now use BomTableAnnotation. In my product, I find BOM tables by traversing the feature tree. You can probably also use GetTableannotations.

1 Like

I dont want to access bom tree. I want to access the coordinates of the table. Is it possible without getextent()?

I wasn’t talking about the BOM tree, I mentioned the feature tree. You’ll need to:

  1. Traverse the feature tree
  2. Get a bom table annotation
  3. Get its TableAnnotation
  4. Traverse through all rows and columns
  5. Sum the column widths and row heights
2 Likes

Sorry @PeterBrinkhuis . I think you didn’t exatly understand. How do I access the coordinate where the table is located on the page?
In the IBomTableAnnotation interface, only the table has certain properties, there is no property to extract its position on the page.

The underlying annotation has a position property. That can be any corner of the table, so you’ll need to check the orientation of the table annotation as well. And if you want the size if the table, you’ll need to sum the widths and heights.

1 Like

Thanks @PeterBrinkhuis for answers.

I managed to get coordinates and table width height with the method you said. However, it did not turn out as I imagined.

I need to remove the table with this coordinate and width height information from pdf content after pdf is created.

We obtain the coordinate and other information on the solidworks installed computer. but I’m doing the table removal event on the server. so there is no solidworks on the server.

How do I convert this coordinate information?

double[] xyz = (double[])swAnnotation.GetPosition();
for (int cc = 0; cc < swTable.ColumnCount; cc++)
{
    tablo_genisligi += swTable.GetColumnWidth(cc);
}
for (int rc = 0; rc < swTable.RowCount; rc++)
{
    tablo_yuksekligi += swTable.GetRowHeight(rc);
}

Result:

xyz[0] = 0.12035561082662763
xyz[1] = 0.0276583321141185
xyz[2] = -1.97215226305253E-31

What do you mean with “However, it did not turn out as I imagined.”?

I think the annotation position uses sheet coordinates, so there should be no coordinate transformation required. The position can be the top-left or any other table corner though, so you have to check the orientation and correct for that.