tcsl9621 发表于 2006-8-27 21:46:00

如何实时动态取得CAD下光标的位置?

如何实时动态取得CAD下光标的位置?
此功能有没有人知道是什么命令?(VBA,VB.net,C#,或读CAD系统参数都可以)
请知道的朋友告诉我。谢了!!!

tcsl9621 发表于 2006-8-29 19:35:00

或有这个函数也可以。
将屏幕点转化为CAD下的点。
VB开发CAD2007有这个函数,但我用的CAD2006没有。请问大家有没有别的函数可以实现?
如CAD2007开发用的函数:ed.pointtoworld(new point(e.x,e.y))

tcsl9621 发表于 2006-8-31 22:02:00

用API函数此问题已解决。谢谢才鸟兄。

tcsl9621 发表于 2006-9-10 22:30:00

Public Class ArxApi
   _
    Public Shared Function acedCoordFromPixelToWorld(ByVal viewportNumber As Integer, ByVal pixel As System.Drawing.Point, ByRef point As Point3d) As Boolean
      '''
      '''
    End Function
    '''
   _
    Public Shared Function acedCoordFromWorldToPixel(ByVal viewportNumber As Integer, ByVal worldPt As Point3d, ByRef pixel As System.Drawing.Point) As Boolean
      '''
      '''
    End Function
    '''
End Class

mkhsj929 发表于 2006-10-18 23:46:00


      private static Point3d m_MousePoint = new Point3d(0, 0, 0);//保存当前鼠标位置
      
      public void test()
      {
            Editor m_ed = Application.DocumentManager.MdiActiveDocument.Editor;
            m_ed.PointFilter+=new PointFilterEventHandler(m_GetMousePoint);
            PromptPointOptionsm_pko = new PromptPointOptions("\n按左键退出...");
            PromptPointResult m_ppr = m_ed.GetPoint(m_pko);
            if (m_ppr.Status == PromptStatus.OK)
            {
                m_ed.PointFilter -= new PointFilterEventHandler(m_GetMousePoint);
            }
      }
      //动态获取鼠标位置
      void m_GetMousePoint(object sender, PointFilterEventArgs e)
      {
            //throw new System.Exception("The method or operation is not implemented.");
            m_MousePoint = e.Context.ComputedPoint;
            Editor m_ed = Application.DocumentManager.MdiActiveDocument.Editor;
            m_ed.WriteMessage("\n当前鼠标位置:" + m_MousePoint + "\t按下鼠标左键退出...");
      }

sailor538 发表于 2006-11-6 14:46:00

屏幕点是怎么得到的?

tcsl9621 发表于 2006-11-7 10:41:00

mouseup 事件中得到

18hzt 发表于 2007-4-20 14:22:00

可以用吗?

scs5999 发表于 2007-5-6 17:20:00


Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.Geometry
Imports Autodesk.AutoCAD.EditorInput
Public Class Class1
   Private MousePoint As Point3d = New Point3d(0, 0, 0) '保存当前鼠标位置
   _
       PublicSub 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

tcsl9621 发表于 2007-6-9 00:54:00

好样的。
页: [1]
查看完整版本: 如何实时动态取得CAD下光标的位置?