houlinbo 发表于 2007-8-15 10:58:00

新建文件

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