What is wrong with my code?
Sub EE_Example()Dim ee As ElementEnumeratorDim es As New ElementScanCriteriaDim elArray() As ElementDim i As LongDim iStart As LongDim iEnd As LongDim elLevel As LevelDim elVariant() As VariantDim bigString As String'' set element scan criteria to find only described elements'Set elLevel = ActiveDesignFile.Levels("DRAWING TEXT")es.ExcludeAllColorses.IncludeColor 7es.ExcludeAllLevelses.IncludeLevel elLeveles.ExcludeAllTypeses.IncludeType msdElementTypeTextNode'' set enumerator from active model'Set ee = ActiveModelReference.Scan(es)'' get an element array of all elements found'elArray = ee.BuildArrayFromContentsiStart = LBound(elArray)iEnd = UBound(elArray)'' loop through array and get the second line of text'For i = iStart To iEndelVariant(i) = elArray(i).AsTextNodeElement.TextLine(2)bigString = Join(elVariant(i), ",")NextEnd Sub
Hi,
What is this routine doing, and what do you want it to do?
I don't think you need the "()" in the elVariant dim statement
I think you may want:
elVariant = elArray(i).AsTextNoteElement.TextLine(2)
bigString = bigString & elVariant & ", "
--Robert
Reu,
You don't say what your code is doing wrong. So we are left to speculate. I don't have access to MicroStation on the computer I typing this response on so I can't test it out now but a few things pop out at me
Rod WingSenior Systems Analyst
Answer Verified By: rashil
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
All,
My apologies, it was late and I was frustrated.
My intention is for this code to scan through the model and get the text on the 2nd line of the scanned textnodeelements. Then I want to place the text string from each into a big comma delimited list ("bigstring").
Thanks for all your help.