building a list from scanned TextNodeElements

What is wrong with my code?

Sub EE_Example()
Dim ee As ElementEnumerator
Dim es As New ElementScanCriteria
Dim elArray() As Element
Dim i As Long
Dim iStart As Long
Dim iEnd As Long
Dim elLevel As Level
Dim elVariant() As Variant
Dim bigString As String

'
' set element scan criteria to find only described elements
'

Set elLevel = ActiveDesignFile.Levels("DRAWING TEXT")

es.ExcludeAllColors
es.IncludeColor 7
es.ExcludeAllLevels
es.IncludeLevel elLevel
es.ExcludeAllTypes
es.IncludeType msdElementTypeTextNode

'
' set enumerator from active model
'
Set ee = ActiveModelReference.Scan(es)

'
' get an element array of all elements found
'
elArray = ee.BuildArrayFromContents
iStart = LBound(elArray)
iEnd = UBound(elArray)

'
' loop through array and get the second line of text
'
For i = iStart To iEnd
elVariant(i) = elArray(i).AsTextNodeElement.TextLine(2)
bigString = Join(elVariant(i), ",")
Next


End Sub

Parents
  • Unknown said:
    What is wrong with my code?

    As others have written, do you want us to guess?

    Does your code throw an error, or does it simply not do what you expect?

    Put some Debug.Print and Debug.Assert statements in there to reassure yourself that the code does what you expect.

    Debug.Printlets you, the developer, see the state of your code and confirm it does what you want.

    Debug.Assert lets you validate a fact — it questions our assumptions. For example …

     elArray = ee.BuildArrayFromContents
    iStart = LBound(elArray)
    iEnd = UBound(elArray)
    ' Show me the size of my array
    Debug.Print "Array size=" & CStr(iEnd - iStart)
    ' Assert that the array is not empty
    Debug.Assert (0 < (iEnd - iStart))

    Regards, Jon Summers
    LA Solutions

     
    Regards, Jon Summers
    LA Solutions

Reply
  • Unknown said:
    What is wrong with my code?

    As others have written, do you want us to guess?

    Does your code throw an error, or does it simply not do what you expect?

    Put some Debug.Print and Debug.Assert statements in there to reassure yourself that the code does what you expect.

    Debug.Printlets you, the developer, see the state of your code and confirm it does what you want.

    Debug.Assert lets you validate a fact — it questions our assumptions. For example …

     elArray = ee.BuildArrayFromContents
    iStart = LBound(elArray)
    iEnd = UBound(elArray)
    ' Show me the size of my array
    Debug.Print "Array size=" & CStr(iEnd - iStart)
    ' Assert that the array is not empty
    Debug.Assert (0 < (iEnd - iStart))

    Regards, Jon Summers
    LA Solutions

     
    Regards, Jon Summers
    LA Solutions

Children
No Data