.NET

.NET

Reply
*Rune Aarnes
Message 1 of 1 (41 Views)

How to put a new value in a block with attributs?

41 Views, 0 Replies
01-24-2006 10:50 AM
Do anybody know what is wrong with this codesegment.
I try to put some new value in attributes in a block I pick in a drawing...
I am new in vb.net...


Dim db As Database = HostApplicationServices.WorkingDatabase
Dim tm As Autodesk.AutoCAD.DatabaseServices.TransactionManager =
db.TransactionManager
Dim trans As Autodesk.AutoCAD.DatabaseServices.Transaction =
tm.StartTransaction

Try
Dim blkRef As BlockReference
blkRef = trans.GetObject(m_blockId, OpenMode.ForRead)
Dim attRibCol As AttributeCollection
attRibCol = blkRef.AttributeCollection()
Dim attributtID As ObjectId

For Each attributtID In attRibCol
Dim attributtRef As AttributeReference
attributtRef = trans.GetObject(attributtID, OpenMode.ForWrite,
False)
attributtRef.TextString = "someValue"
Next

trans.Commit() 'THIS IS WRONG MAY BE.....

Catch ex As Exception
MessageBox.Show(ex.Message)
trans.Abort()
Finally
If (Not trans Is Nothing) Then
trans.Dispose()
End If
End Try



thanks
Rune Aarnes
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.