Message 1 of 5
How to amend object
Not applicable
12-06-2011
01:32 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
This is my code (thanks to Alfred NESWADBA)
Friend Sub ObjectModified(ByVal sender As Object, ByVal e As Autodesk.AutoCAD.DatabaseServices.ObjectEventArgs)
Using tr As Transaction = CurDb.TransactionManager.StartTransaction()
Dim btr As BlockTableRecord
btr = tr.GetObject(CurDb.CurrentSpaceId, OpenMode.ForWrite)
With e.DBObject
If .IsWriteEnabled Then Exit Sub
If .Id.ObjectClass.Name = "AcDbAttribute" Then
Dim ar As AttributeReference = CType(e.DBObject, AttributeReference)
Dim blk As BlockReference = tr.GetObject(ar.OwnerId, OpenMode.ForRead)
blk.SetDatabaseDefaults()
With a_Job
For i As Integer = 4 To 19
If a_Title.Tags(i) = ar.Tag Then
Select Case i
Case 4, 5, 6, 7
Dim a As String = .Description(i - 4)
ar.UpgradeOpen()
ar.TextString = a
tr.AddNewlyCreatedDBObject(ar, False)
End Select
End If
Next i
End With
End If
End With
tr.Commit()
End Using
End SubNaturally it doesn;t work. Actually it crashes AutoCad