Dim db As Database = HostApplicationServices.WorkingDatabase
Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor
Dim ent As Entity
Dim k As Integer
Dim Doc As Document = Application.DocumentManager.MdiActiveDocument
Using LckDoc As DocumentLock = Doc.LockDocument
Using Trans As Transaction = db.TransactionManager.StartTransaction
Try
'建立DIM图层
Dim Lt As LayerTable = Trans.GetObject(db.LayerTableId, OpenMode.ForRead)
Dim Layname As String = "DIM"
If Lt.Has(Layname) = False Then
Dim Ltr As LayerTableRecord = New LayerTableRecord()
Ltr.Name = Layname
Ltr.Color = Color.FromColorIndex(ColorMethod.ByAci, 3)
Lt.UpgradeOpen() '升级图层块表为写入
Lt.Add(Ltr) '加入到图层块表
Trans.AddNewlyCreatedDBObject(Ltr, True) '加入该事务
End If