ublic Function addpl() Dim db As Database = HostApplicationServices.WorkingDatabase() Dim trans As Transaction = db.TransactionManager.StartTransaction() MsgBox("0") Try Dim pl As New Circle(New Point3d(0, 0, 0), Vector3d.ZAxis, 100) MsgBox("1") Dim bt As BlockTable = trans.GetObject(db.BlockTableId, OpenMode.ForRead) MsgBox("2") Dim btrid As ObjectId = bt.Item(BlockTableRecord.ModelSpace) Dim btr As BlockTableRecord = trans.GetObject(btrid, OpenMode.ForWrite) MsgBox("3") Dim ObjId As ObjectId MsgBox("4") ObjId = btr.AppendEntity(pl) MsgBox("5") trans.AddNewlyCreatedDBObject(pl, True) MsgBox("6") trans.Commit() Catch ex As Exception MsgBox("pl error.") Finally trans.Dispose() End Try End Function
上面程序中红色代码总出错。请高手指点。 |