So I have spreadsheet with a bunch of point data, and i have a .net app that scans microstation dgn using COM API for text nodes and elements that fall into the point range. This does work, but i'm getting what I would call ghost data on top of the real visible text elements. The values are similar to what could've been in that area before, but they are obviously not in the drawing now. I checked all levels, i tried searching for them with find/replace tool, still no luck. But they do come up as valid textelements when i'm scanning the with COM API.
Anyone run into this? It feels like there should be a IsElementAlmostDeleted flag or something along those lines...
Without seeing any code, it's impossible to comment.
Regards, Jon Summers LA Solutions
Sure, here's a section where I'm scanning for text elements, i hate posting code here because of the formatting mess...
Dim elems As New List(Of TextElem) Dim elemEnum As ElementEnumerator Dim scanCriteria As New ElementScanCriteria scanCriteria.ExcludeAllTypes() scanCriteria.IncludeType(MsdElementType.msdElementTypeText) scanCriteria.IncludeType(MsdElementType.msdElementTypeTextNode) elemEnum = UstnApplication.ActiveModelReference.Scan(scanCriteria) Do While elemEnum.MoveNext If elemEnum.Current.IsTextElement Then Dim telem As TextElement telem = elemEnum.Current If telem.Text.Trim <> "" Then Dim tl As New TextElem tl.MaxPoint = telem.Boundary.High tl.MinPoint = telem.Boundary.Low tl.Value = telem.Text tl.TextObj = telem elems.Add(tl) End If End If If elemEnum.Current.IsTextNodeElement Then Dim tn As TextNodeElement tn = elemEnum.Current Dim tnEnum As ElementEnumerator tnEnum = tn.GetSubElements Do While tnEnum.MoveNext Dim telem As TextElement telem = tnEnum.Current If telem.Text.Trim <> "" Then Dim tl As New TextElem tl.MaxPoint = telem.Boundary.High tl.MinPoint = telem.Boundary.Low tl.Value = telem.Text tl.TextObj = telem elems.Add(tl) End If Loop End If Loop For Each tl In elems For Each p In params If IsTextWithinRange(tl, p) Then If p.Value = "3.65,5.67;4.22,5.985" Then 'drawing does not have anything in this range tl.TextObj.IsHighlighted = True End If If p.ReturnedValue = "" Then p.ReturnedValue = tl.Value Else p.ReturnedValue = p.ReturnedValue & ";" & tl.Value End If p.ListOfTextElems.Add(tl) Exit For End If Next Next
Dim elems As New List(Of TextElem)
Dim elemEnum As ElementEnumerator
Dim scanCriteria As New ElementScanCriteria
scanCriteria.ExcludeAllTypes()
scanCriteria.IncludeType(MsdElementType.msdElementTypeText)
scanCriteria.IncludeType(MsdElementType.msdElementTypeTextNode)
elemEnum = UstnApplication.ActiveModelReference.Scan(scanCriteria)
Do While elemEnum.MoveNext
If elemEnum.Current.IsTextElement Then
Dim telem As TextElement
telem = elemEnum.Current
If telem.Text.Trim <> "" Then
Dim tl As New TextElem
tl.MaxPoint = telem.Boundary.High
tl.MinPoint = telem.Boundary.Low
tl.Value = telem.Text
tl.TextObj = telem
elems.Add(tl)
End If
If elemEnum.Current.IsTextNodeElement Then
Dim tn As TextNodeElement
tn = elemEnum.Current
Dim tnEnum As ElementEnumerator
tnEnum = tn.GetSubElements
Do While tnEnum.MoveNext
telem = tnEnum.Current
Loop
For Each tl In elems
For Each p In params
If IsTextWithinRange(tl, p) Then
If p.Value = "3.65,5.67;4.22,5.985" Then 'drawing does not have anything in this range
tl.TextObj.IsHighlighted = True
If p.ReturnedValue = "" Then
p.ReturnedValue = tl.Value
Else
p.ReturnedValue = p.ReturnedValue & ";" & tl.Value
p.ListOfTextElems.Add(tl)
Exit For
Next
This part is where I catch the ghost entity:
Another interesting thing to point out is that when i selected all elements and copied/pasted into a new drawing, these ghost entities didn't show up.
Unknown said: I hate posting code here because of the formatting mess
I agree. It used to work better, but something changed in the way the editor handles the HTML <pre> element. I wish they would restore it to the working version.
Unknown said:When I selected all elements and copied/pasted into a new drawing, these ghost entities didn't show up
Is there something unexpected about the original DGN? Perhaps it contains self-references?
not really, these are very simple line & text drawings, that's why its puzzling me. I decided to prompt the user to select all manually and scan the selection instead of the entire database and that fixed it.
One other odd thing about this is that if I process the selection it finds all the elements i need in less than a second. But if i run through the entire database, even with criteria, it takes 5 times longer. Makes me think that there's quiet a few of these "ghost" elements out there.
I tried compressing the file but that didn't help either.
Can you post the DGN file here (if the data is not confidential)?
These are not my drawings but customer's, I guess if this isn't something common I'll just assume these drawings have some corrupted data. I thought I'd post it in case this happens quiet a bit.