如题,我写的代码如下,好像没出错,但是重新打开之后没有发现块有定义
Dim db As Database = New Database(False, True) db.ReadDwgFile(Path, System.IO.FileShare.ReadWrite, True, "") Using trans As Transaction = db.TransactionManager.StartTransaction() Dim bt As BlockTable = trans.GetObject(db.BlockTableId, OpenMode.ForWrite) If Not bt.Has(curUnitName) Then Return End If Dim btr As BlockTableRecord = trans.GetObject(bt(curUnitName), OpenMode.ForWrite) Dim attdef As New AttributeDefinition attdef.Tag = “SP" attdef.TextString = "SPText"
btr.AppendEntity(attdef) trans.Commit() End Using db.Dispose() |