本帖最后由 作者 于 2007-5-6 17:23:51 编辑
Imports Autodesk.AutoCAD.Runtime Imports Autodesk.AutoCAD.Geometry Imports Autodesk.AutoCAD.EditorInput Public Class Class1 Private MousePoint As Point3d = New Point3d(0, 0, 0) '保存当前鼠标位置 <CommandMethod("mtest")> _ Public Sub test() Dim ed As Editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor AddHandler ed.PointFilter, AddressOf GetMousePoint Dim pro As PromptPointOptions = New PromptPointOptions("按左键退出...") ed.GetPoint(pro) RemoveHandler ed.PointFilter, AddressOf GetMousePoint End Sub ''动态获取鼠标位置 Private Sub GetMousePoint(ByVal sender As Object, ByVal e As PointFilterEventArgs) MousePoint = e.Context.ComputedPoint Dim m_ed As Editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor m_ed.WriteMessage("当前鼠标位置: " + vbLf + "X=" + MousePoint.X.ToString + vbLf + "Y=" + MousePoint.X.ToString + vbLf + "Z=" + MousePoint.Z.ToString + vbLf) End Sub End Class |