Afternoon all,
I'm revisiting an old tags extraction macro within an XLS file and rewriting it to improve its performance as when I last used it was a bit maverick in its results.
There are plenty of similar threads on the process but I've got a slightly different issue where in a dgn I am:
- Scanning for certain element types
- Checking if they are valid
- Checking if they are visible
- Checking if they have tags
- Checking if the tags belong to 1 of a possible 5 tagsets (if not they ignore)
1-4 is all very common to the other threads I've read but they also only have a single tagset specified (typically in a specific cell in the XLS worksheet) whereas I want to check if the tags belong to 5 valid tagsets. The Tagset names are on a second worksheet in the same xls file and populate columns A1-E1. The adjacent cells in each row contain the tag definitions stored in each tagset.
Where I am currently stuck is that I have a select case statement which I have tried to check what the .TagDefinitionName of the current element in the enumerator is however following the debug process with a break on the select case line I can see it then moves to the error handling section. My tagset are originally placed in a cell and the cell contains the host tag element which is a point so I my scan criteria is only specifying oScanCriteria.IncludeType msdElementTypeLine
Obviously the line is not a tag element so my guess is the AsTagElement.TagDefinitionName part of the select case line is causing a conflict so I am wondering what do I need to change to allow checking of the tagsets that each host element is associated to?
bTagFound = False Set oEnumerator = oDGN.Models(sModel).Scan(oScanCriteria) While oEnumerator.MoveNext Set oEl = oEnumerator.Current If oEl.IsValid Then Debug.Print "Element type " & CStr(oEl.Type) & " ID " & DLongToString(oEl.ID) If oEl.IsGraphical Then If Not oEl.IsHidden Then If oEl.HasAnyTags Then bTagFound = True Debug.Print "Found valid Tags" Select Case oEl.AsTagElement.TagDefinitionName Case ShtTagDefs.Cells(1, 1) TagCriteria oEl, sModel Case ShtTagDefs.Cells(2, 1) TagCriteria oEl, sModel Case ShtTagDefs.Cells(3, 1) TagCriteria oEl, sModel Case ShtTagDefs.Cells(4, 1) TagCriteria oEl, sModel Case ShtTagDefs.Cells(5, 1) TagCriteria oEl, sModel End Select Else Debug.Print "No valid tags found" End If Else Debug.Print "Not visible" End If Else Debug.Print "Not graphical" End If Else Debug.Print "Not valid" End If Wend