Message 1 of 17
Not applicable
12-11-2014
12:38 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am inserting a block with attributes in my drawing. Basically this enables the user to begin with the correct layout template that the company uses.
When the following code finishes executing, I can visually see that the block has been inserted.
Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
Dim ed As Editor = acDoc.Editor
Dim db As Database = acDoc.Database
Dim bt As BlockTable
Dim btr As BlockTableRecord
Dim blockref As BlockReference
Dim att As AttributeReference
Dim templateName As String = "BLOCKNT_LE"
'User saved
Using tr As Transaction = db.TransactionManager.StartTransaction()
bt = TryCast(tr.GetObject(db.BlockTableId, OpenMode.ForRead), BlockTable)
btr = TryCast(tr.GetObject(bt(BlockTableRecord.ModelSpace), OpenMode.ForWrite), BlockTableRecord)
'Insert template
Using newdb As New Database(False, True)
newdb.ReadDwgFile(clsProgramVariable.GetValue("LayoutNumberGenerator", templateName), FileOpenMode.OpenForReadAndAllShare, True, "")
db.Insert(Matrix3d.Displacement(New Vector3d(0, 0, 0)), newdb, True)
End Using
'List all block table record names
Dim tmpstr As String = ""
For Each id As ObjectId In bt
btr = DirectCast(tr.GetObject(id, OpenMode.ForRead), BlockTableRecord)
If Not btr.IsLayout Then
tmpstr = vbNewLine & btr.Name
ed.WriteMessage(tmpstr)
End If
Next
tr.Commit()
End Using
The only issue is, I cannot find the BLOCKNT_LE when I list the block table record names... I need to find the BLOCKNT_LE because it has attributes and I need to change some values in there. Why is this? Do I need to save before? Do I need to do some sort of regen?
Also, this is a side question, but I can't seem to figure out how to center the user's view at (0,0,0) which is where the block is inserted.
Thanks,
Alex
Solved! Go to Solution.