- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am inserting a block (strSectionBlk) into an AutoCAD 13 drawing using VB .NET. This block has an attribute with tag "FAB_HEIGHT" and I want to edit its string to the value of a variable "strFabHeight" at the time of the insertion of the block. The insertion of the block is fine but I've failed to edit the attibute. Could someone help me, please?
Public Sub InsertSection()
'Call the Function that decides the name of the head section block strSectionBlk
getSectionDwg(strModel, strHeadType)
'Start the database
Dim db As Database
db = HostApplicationServices.WorkingDatabase()
'Start the Editor
Dim ed As Editor
ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor
'Start the transaction
Dim trans As Transaction
trans = db.TransactionManager.StartTransaction
Try
'Open the Block Table for Read
Dim bt As BlockTable = trans.GetObject(db.BlockTableId, OpenMode.ForRead)
'Open the Block Table Record for Write
Dim btr As BlockTableRecord
btr = trans.GetObject(bt.Item(BlockTableRecord.ModelSpace), Autodesk.AutoCAD.DatabaseServices.OpenMode.ForWrite)
'Read the file and insert the block
Dim id As ObjectId
Dim dbDwg As New Database(False, True)
dbDwg.ReadDwgFile(file path & strSectionBlk, IO.FileShare.Read, True, "")
id = db.Insert(strSectionBlk, dbDwg, True)
dbDwg.Dispose()
Dim ptInsert As New Point3d(0.875, 0.875, 0)
Dim blkRef As New BlockReference(ptInsert, id)
btr.AppendEntity(blkRef)
trans.AddNewlyCreatedDBObject(blkRef, True)
Editing of the attribute?
'Commit the transaction
trans.Commit()
Catch
MsgBox("Fail to Read Section Dwg File and Insert it in Current Database.")
Finally
trans.Dispose()
End Try
End Sub
Solved! Go to Solution.