Hi,
I some drawings (dgn files, converted from dwg files) that have some tables in them. I would like to use vba to delete all these tables. Is there an msdElementType for a table? Or something equivalent?
--Thanks,--Robert Arnold
Hi Robert,
RobertArnold said:dgn files, converted from dwg files
to be sure: Are the tables, when converted from dwg, represented zas MicroStation tables?
RobertArnold said:Is there an msdElementType for a table?
I think tables are stored as extended element, so no 'element type id' exists: all elements, stored as extended type, share the same type (but different element handler).
RobertArnold said:I would like to use vba to delete
I think tables are not supported by VBA
But maybe the tables can be selected by key-in?
Regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
RobertArnold said: I would like to use vba to delete all these tables
The .NET and C++ APIs work with DGN tables. Regrettably, VBA has not been extended to include a table class.
We started and largely completed work on a Table Manager AddIn. It's written in C#. Since we received no enquiries about that, it has not been commercialised.
Regards, Jon Summers LA Solutions
Hi Jan,
In the Mstn information dialog, it lists the type of these element as "Table" with rows and columns.
Yes, I do see that using a msdElementType value of 106 includes the tables. Is there a way of seeing what the "element handler" is from vba?
RobertArnold said:Is there a way of seeing what the "element handler" is from vba?
Handlers are an OOP concept. VBA pre-dates such concepts by a decade or so.
VBA lets you Declare a procedural function from Windows or MDL implemented in a DLL. It doesn't provide access to OO classes implemented in a DLL
Is there a list of element types that would be included in msdElementType = 106? If they are all items that I don't need, maybe I just delete all type 106 elements...
--Thanks,--Robert
No. VBA API is based on element types IDs, so not compatible with the concept of "one element type for different elements".
RobertArnold said:Is there a list of element types that would be included in msdElementType = 106?
No. Even in SDK, type 106 (and 107, which is non-graphical variant) is not listed.
What I know, 106/107 elements are used for tables, parametric modeling, point clouds attachment, some elements created by OpenCities Map products, and maybe even more.
The situation is even more complicated: Types 106 and 107 can be used together, so one element (as seen by a user) can be stored as several 106 and 107 elements. Only the owner handler knows how to access these elements.
Honestly, I think there is no solution using VBA (unfortunately there is also no key-in to select tables in opened model).
With regards,
Greetings!
You may get an element and check the value of property "GetDisplayString", if the value is "Table", it is a table.
Here we have a piece of code for getting number of table elements in model, please check.
Sub getTableElements() Dim oElement As Element Dim oSc As ElementScanCriteria Dim oPH As PropertyHandler Dim iCountTables As Integer Dim str() As String, oStr1 As String Dim ElemID As Long Set oSc = New ElementScanCriteria oSc.ExcludeNonGraphical Dim oScanEnumerator As ElementEnumerator Set oScanEnumerator = ActiveModelReference.Scan(oSc) Do While oScanEnumerator.MoveNext Set oElement = oScanEnumerator.Current Set oPH = CreatePropertyHandler(oElement) str = oPH.GetAccessStrings On Error Resume Next For i = LBound(str) To UBound(str) If str(i) = "ElementDescription" Then oPH.SelectByAccessString (str(i)) oStr1 = oPH.GetDisplayString If oStr1 = "Table" Then ElemID = oElement.ID.Low Debug.Print "found table element with id " + CStr(ElemID) ' print id of table element. iCountTables = iCountTables + 1 Exit For End If End If Next i Loop Debug.Print "Total number of table element in model - " & iCountTables ' print number of table elements in active model End Sub
Best Regards,
Colin