各位大侠,有关VB.net编写lsp对话框函数问题!
我想写一个lsp可以用来调用对话框的vb.netdll,加载后就会有这个函数来调用,选中的的文件名写入CAD系统变量(没办法呀,自定义lsp函数的参数搞不明白)代码如下:Imports Autodesk.AutoCAD.DatabaseServicesImports Autodesk.AutoCAD.Windows '.OpenFileDialog
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.Runtime
Public Class CADnet
<LispFunction("LispDialog")> _
Public Sub LispDialog(ByVal rbArgs As ResultBuffer)
'Dim Myvar As String = Application.GetSystemVariable("USERS1")
Try
Dim Myfile As String = ""
If rbArgs = Nothing Then
Dim sFilter As String = "*"
Dim MLsDlog As New OpenFileDialog("打开----江河梦小组", "", sFilter, "", OpenFileDialog.OpenFileDialogFlags.AllowMultiple)
Dim Fname As String = ""
MLsDlog.ShowDialog()
For Each Fname In MLsDlog.GetFilenames()
Myfile = Myfile & Fname & ","
Next
Application.SetSystemVariable("USERS1", Myfile)
MLsDlog = Nothing
End If
Catch e As Exception
End Try
End Sub
End Class加载dll后确实有了这个函数,选中文件文件名就会存入系统变量。但是问题来了,如果点击取消按钮,CAD会马上出现致命错误,请各大侠给指点指点! if MLsDlog.ShowDialog()<>DialogResult.OK Then Return 楼上正解,多谢大侠指点。Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.Windows '.OpenFileDialog
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.LayerManager.LayerFilter
'E:\我的磁盘\源代码\VB.net\vb.net程序\lsp函数对话框(lispdialog)\lsp函数对话框(lispdialog)\bin\Debug\lsp函数对话框(lispdialog).dll
Public Class CADnet
<LispFunction("LispDialog")> _
Public Sub LispDialog(ByVal rbArgs As ResultBuffer)
'Dim Myvar As String = Application.GetSystemVariable("USERS1")
Try
Dim Myfile As String = ""
If rbArgs = Nothing Then
Dim sFilter As String = "*"
Dim MLsDlog As New OpenFileDialog("打开----江河梦小组", "", sFilter, "", OpenFileDialog.OpenFileDialogFlags.AllowMultiple)
Dim Fname As String = ""
MLsDlog.ShowDialog()
If MLsDlog.ShowDialog() <> DialogResult.OK Then
Exit Sub
Else
For Each Fname In MLsDlog.GetFilenames()
Myfile = Myfile & Fname & ","
Next
Application.SetSystemVariable("USERS1", Myfile)
MLsDlog = Nothing
End If
End If
Catch e As Exception
End Try
End Sub
End Class但是为何点击取消后,这个对话框会再弹出来一次,再点击才会消失,请再指点一下!谢谢 删掉一个MLsDlog.ShowDialog() 额,是呀。竟然忽略了这个,谢谢各位指点。 本帖最后由 雪山飞狐_lzh 于 2012-6-24 09:51 编辑
选中的的文件名写入CAD系统变量。。。
LispFunction可以有返回值的,看这里6楼代码
http://bbs.mjtd.com/forum.php?mod=viewthread&tid=79849&extra=page%3D1%26filter%3Dtypeid%26typeid%3D36&page=1
雪山飞狐_lzh 发表于 2012-6-24 09:49 static/image/common/back.gif
选中的的文件名写入CAD系统变量。。。
LispFunction可以有返回值的,看这里6楼代码
http://bbs.mjtd.com/ ...
受教了,多谢狐哥指点。
页:
[1]