I have some code written by someone else.
They apparently have been using Xdata to store information about certain cells. They have routines to read the information back out of the cell (probably using the Xdata). However, some of our cells have been corrupted and don't read back in correctly. I've been looking at the code and running it on a corrupt cell to see if I can determine the problem. When I run 'Debug.Print TempEle.HasAnyXData' it returns a 'True' which makes me believe there is Xdata associated with this cell. However, I can't seem to determine the 'Application name' this information would be stored under? Why does 'AppNames = TempEle.GetXDataApplicationNames' return an empty array?
Thanks in advance,
Christmas May
Unknown said: I can't seem to determine the 'Application name' this information would be stored under? Why does 'AppNames = TempEle.GetXDataApplicationNames' return an empty array?
A code sample is worth 1,000 words. Please provide some context. Crucially, we need to see how you have declared variable AppNames.
Regards, Jon Summers LA Solutions
Mr. Jon Summers,
Thanks for the quick reply. I've been able to correct the initial problem, although I'm not entirely sure how. (Changed several things.) My question now is why the AppName is so weird? It is producing '??? (ID &H9C4)' without the quotes.
'My Added function.
Public Function fBlnSearchCell(Cell As CellElement) As Boolean
Dim TempEle As Element
Dim appNames() As String
Dim ElementNumber As Integer
'Step through cell.
Cell.ResetElementEnumeration
ElementNumber = 0
Do While Cell.MoveToNextElement
ElementNumber = ElementNumber + 1
Set TempEle = Cell.CopyCurrentElement
If TempEle.IsTextElement Then
'Debug.Print TempEle.HasAnyXData 'Prints "True" in the immediate window.
appNames = TempEle.GetXDataApplicationNames
For index = LBound(appNames) To UBound(appNames)
Debug.Print ElementNumber & ", " & TempEle.AsTextElement.Text
Debug.Print appNames(index) 'Prints "??? (ID &H9C4)"
Next
End If
Loop
End Function
Sincerely,
Is it possible to either change the "Application name" on an Xdata set or to use this information to build a new Xdata set with the correct application name?
Bentley developed XData primarily for compatibility with AutoCAD. What you can or cannot do with XData should be viewed from the viewpoint of an AutoDesk developer.
The following subroutine works well the first time it is called as the Model is the activemodel. However, when this routine is called with subsequent models it fails. From what I can tell the gObjCell is indeed a cellelement from the correct model. What I don't know is how to write the Xdata to a Model other than the ActiveModel?
Public Sub sRepairRevBlock2008(gObjCell As CellElement, Model As ModelReference)
Do While gObjCell.MoveToNextElement
XdataQK = "QK"
'Build the new XDatum array.
AppendXDatum sAryXdatum, msdXDatumTypeString, XdataQK
'Then put it onto the element.
sObjTempElement.DeleteAllXData
sObjTempElement.SetXData "Label2011", sAryXdatum
sObjTempElement.Rewrite ' Don't forget to do this!
DeleteXDatum sAryXdatum, 0
end sub
What is a 'subsequent model'? How do you obtain a ModelReference to that model?
Please take a look at
http://communities.bentley.com/products/microstation/microstation_v8_xm_edition/f/159/t/64185.aspx
Your assistance would be GREATLY appreicated.