- 积分
- 1763
- 明经币
- 个
- 注册时间
- 2004-12-15
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
我想在图中已有的块定义里增加圆,运行结果加了圆 但是会过一会儿就 或者 双击块定义 致命错误了
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
|
|