批量打开文件会致命错误
<CommandMethod("ls1", CommandFlags.Session)> Public Sub ls1()Dim objOpenFileDialog As Autodesk.AutoCAD.Windows.OpenFileDialog = New Autodesk.AutoCAD.Windows.OpenFileDialog("选择文件", "CAD图", "dwg", "DialogName", Autodesk.AutoCAD.Windows.OpenFileDialog.OpenFileDialogFlags.AllowMultiple)
If objOpenFileDialog.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
'创建文件夹
Dim myDirectory As String = Path.GetDirectoryName(objOpenFileDialog.Filename)
Dim newFolder As String = "\转换后"
If Not Directory.Exists(myDirectory + newFolder) Then
Directory.CreateDirectory(myDirectory + newFolder)
End If
For i As Integer = 0 To objOpenFileDialog.GetFilenames.Length - 1
Try
Dim Filename As String = objOpenFileDialog.GetFilenames(i)
Dim doc As Document = Application.DocumentManager.Open(Filename, False)
'执行命令,接受Document参数。
Dim doclock As DocumentLock = doc.LockDocument()
pRastIns(Filename)
doclock.Dispose()
'改文件名
Dim newFileName As String = myDirectory + newFolder + "\" + Path.GetFileName(Filename)
'存储的文件版本
doc.Database.SaveAs(newFileName, DwgVersion.Current)
'ed.WriteMessage("newFileName:<" + newFileName + ">");
doc.CloseAndSave(newFileName)
Catch ex As Exception
ed.WriteMessage(ex.Message)
End Try
Next
End If
End Sub
运行有些文件没问题,有些有问题,不知道错在哪里
问题是这句Dim doc As Document = Application.DocumentManager.Open(Filename, False)
cad提示如下:
致命错误:Unhandled Access Violation Reading 0x7efc4134 Exception at 62066e4h
忘高手解决,在线等
cad 2006 有这个问题,俺也没解决
页:
[1]