Just wanted to share how to get/set the TextNote
property for any entity with vb.net.
Public Function GetNote(ByVal oEnt As Entity) As String
Dim doc As Document = Application.DocumentManager.MdiActiveDocument
Dim tr As Transaction = doc.Database.TransactionManager.StartTransaction()
Dim oDict As DBDictionary
Dim oDictId As ObjectId
Dim o As Object
GetNote = ""
If oEnt.ExtensionDictionary = ObjectId.Null Then
GoTo pass
End If
oDictId = oEnt.ExtensionDictionary()
oDict = tr.GetObject(oDictId, OpenMode.ForRead)
If oDict.Item("AEC_TEXT_NOTE") = ObjectId.Null Then
GoTo pass
Else
o = tr.GetObject(oDict.Item("AEC_TEXT_NOTE"), OpenMode.ForRead)
GetNote = o.note
End If
pass:
tr.Commit()
End Function
Public Sub SetNote(ByVal oEnt As Entity, ByVal sNote As String)
Dim doc As Document = Application.DocumentManager.MdiActiveDocument
Dim tr As Transaction = doc.Database.TransactionManager.StartTransaction()
Dim oDict As DBDictionary
Dim oDictId As ObjectId
Dim o As Object
If oEnt.ExtensionDictionary = ObjectId.Null Then
GoTo pass
End If
oDictId = oEnt.ExtensionDictionary()
oDict = tr.GetObject(oDictId, OpenMode.ForRead)
If oDict.Item("AEC_TEXT_NOTE") = ObjectId.Null Then
GoTo pass
Else
o = tr.GetObject(oDict.Item("AEC_TEXT_NOTE"), OpenMode.ForWrite)
o.note = sNote
End If
pass:
tr.Commit()
End Sub