VB API cast selected table to ITable
Hi,
I am doing a little program in which the user will select a table in a drawing, and then the program will read that table and extract information and do stuff with it.
My problem is that I can't figure out how to cast the selected object to a table object.
Here's how I launch the selection process:
Private Sub BtnSelectTable_Click(sender As Object, e As EventArgs) Handles BtnSelectTable.Click
Try
Dim SelectedTable As IpfcSelections = SelectFeatures(theBaseSession)
For i = 0 To SelectedTable.Count - 1
Dim CurrTbl As IpfcTable = SelectedTable.Item(i)
MsgBox(CurrTbl.GetRowCount)
Next
Catch ex As Exception
MsgBox(ex.Message & vbNewLine & vbNewLine & ex.StackTrace,, GetCurrentMethod().Name)
End Try
End Sub
Here's how I select the drawing table (comes from the PTC supplied example):
Public Function SelectFeatures(ByVal session As IpfcBaseSession) As IpfcSelections
Dim selections As IpfcSelections
Dim selectionOptions As IpfcSelectionOptions
Try
'======================================================================
'Selection options are set to select only features with a specified max
'number.
'======================================================================
selectionOptions = (New CCpfcSelectionOptions).Create("dwg_table")
selections = session.Select(selectionOptions, Nothing)
SelectFeatures = selections
Catch ex As Exception
MsgBox(ex.Message.ToString + Chr(13) + ex.StackTrace.ToString)
Return Nothing
End Try
End Function
I can confirm that the selection works, if I select somethings I can get a correct COUNT of how many object I have selected.
The problem is that when I try to cast the selected object to any kind of table object to be able to work with it I get casting error:

Any idea?

