.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Get or Set the TextNote Property with Vb.Net

0 REPLIES 0
Reply
Message 1 of 1
jpkycek
389 Views, 0 Replies

Get or Set the TextNote Property with Vb.Net

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

0 REPLIES 0

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost