You are currently reviewing an older revision of this page.
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
SC
New
ElementScanCriteria
oAtt
Attachment
count
Long
count = 0
SC.ExcludeAllTypes
SC.IncludeType msdElementTypeLine
For
Each
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
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.