.NET

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

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

40 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
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!