作为快速示例,尝试打开多个图形进行阅读,
最好看看数据库。ReadDwg方法
代码:
-
- <CommandMethod("bah")> _
- Public Shared Sub BatchStart()
- Autodesk.AutoCAD.ApplicationServices.Application.SetSystemVariable("SDI", 0)
- Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
- Dim ed As Editor = doc.Editor
- ' Get drawings to process
- Dim dwgsForm As New Autodesk.AutoCAD.Windows.OpenFileDialog("Drawings to Process", "", "dwg", "", Autodesk.AutoCAD.Windows.OpenFileDialog.OpenFileDialogFlags.AllowMultiple)
- If dwgsForm.ShowDialog() <> Windows.Forms.DialogResult.OK Then
- Return
- End If
- Dim dwgfiles As String() = dwgsForm.GetFilenames()
- Using doclock As DocumentLock = doc.LockDocument()
- For i As Integer = 0 To dwgfiles.GetLength(0) - 1
- Dim newdoc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.Open(dwgfiles(i), False)
- 'your rest code to retrieve desired things from opened document here
- '__________________________________________________'
- ed.WriteMessage(vbLf & dwgfiles(i).ToString())
- ' close doc without changes
- newdoc.CloseAndDiscard()
- Next
- End Using
- End Sub
|