怎么在已有的块定义增加个圆?
我想在图中已有的块定义里增加圆,运行结果加了圆 但是会过一会儿就 或者 双击块定义 致命错误了Public Sub AddCircle()
'' Get the current document and database
Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
Dim acCurDb As Database = acDoc.Database
'' Start a transaction
Using acLckDoc As DocumentLock = acDoc.LockDocument()
Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction()
'' Open the Block table for read
Dim acBlkTbl As BlockTable
acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId, OpenMode.ForWrite)
'' Open the Block table record Model space for write
Dim acBlkTblRec As BlockTableRecord
acBlkTblRec = acTrans.GetObject(acBlkTbl("11"), OpenMode.ForWrite)
'' Create a circle that is at 2,3 with a radius of 4.25
Dim acCirc As Circle = New Circle()
acCirc.SetDatabaseDefaults()
acCirc.Center = New Point3d(2, 3, 0)
acCirc.Radius = 4.25
'' Add the new object to the block table record and the transaction
acBlkTblRec.AppendEntity(acCirc)
' acTrans.AddNewlyCreatedDBObject(acCirc, True)
acBlkTblRec.Dispose()
acBlkTbl.Dispose()
'' Save the new object to the database
acTrans.Commit()
End Using
End Using
End Sub
"11" 是我预先随便定义的一个块名 ' acTrans.AddNewlyCreatedDBObject(acCirc, True)
这句不要注释掉 呵呵谢谢 sxpd
页:
[1]