Browsing References for Specific Items


  
 Applies To 
  
 Product(s):MicroStation
 Version(s):08.11.09.578
 Environment: Windows 7 32 bit,Windows 7 64 bit
 Area: Programming
 Subarea: VBA
 Original Author:Tristan Anderson, Bentley Technical Support Group
  

In addition to searchign the current model for specific items, it is also often necessary to search on all attached references. The treatment of references in the search, however, is very similar to looking into a model for a reference (attachment in VBA), one type per model.

Here is a small example in which all references are found by looking for lines, and the total number of lines found is output:

Sub refscan()
Dim Ee As ElementEnumerator
Dim SC As New ElementScanCriteria
Dim oAtt As Attachment
Dim count As Long
count = 0
SC.ExcludeAllTypes
SC.IncludeType msdElementTypeLine
For Each oAtt In ActiveModelReference.Attachments
    Set Ee = oAtt.Scan(SC)
    Do While Ee.MoveNext
        count = count + 1
    Loop
Next
MsgBox ("Total: " & count & " lines found in all references")
End Sub

The For-Next loop runs through all currently open models and their attached references. The variable "count" counts all found lines and is output at the end of the routine.

See Also

MVBA-FAQ