.NET

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

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

39 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
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.