我用下面的方法实现了新建一个db ,然后在这个新建的db上画圆,你看一下是否可行,有没有 没有被发现的潜在错误?
<CommandMethod("startCAD")> _
Sub StartCAD()
Try
Dim cadApp As AcadApplication = GetObject(, "
AutoCAD.Application.17")
Dim olDb As Database = HostApplicationServices.WorkingDatabase
Dim db As Database = New Database(True, False)
HostApplicationServices.WorkingDatabase = db
Dim trans As Transaction = db.TransactionManager.StartTransaction()
Dim bt As BlockTable = trans.GetObject(db.BlockTableId, OpenMode.ForWrite)
Dim br As Circle = CreateCircle(db, bt)
db.SaveAs("d:\ff.dwg", DwgVersion.AC1015)
HostApplicationServices.WorkingDatabase = olDb
trans.Commit()
trans.Dispose()
Dim cadDoc As AcadDocument = cadApp.Documents.Open("d:\ff.dwg")
cadDoc.WindowState = Common.AcWindowState.acMax
cadDoc.Application.ZoomExtents()
Catch ex As Exception
End Try
End Sub
Dim db As Database = New Database(True, False)这一句的true 和false 是否正确
db.SaveAs("d:\ff.dwg", DwgVersion.AC1015) 这一句的DwgVersion.AC1015是否正确?
为什么在com中新建的文件会直接显示出来?arx中新建的db还要再专门打开?