ahlzl 发表于 2009-6-4 19:10:00

tooltip显示图元类型

using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.Runtime;
namespace tooltip
{
    public class Class1
    {
      Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
      
      public void MyTestOn()
      {
            ed.PointMonitor += new PointMonitorEventHandler(ed_PointMonitor);
      }
      
      public void MyTestOff()
      {
            ed.PointMonitor -= new PointMonitorEventHandler(ed_PointMonitor);
      }
      void ed_PointMonitor(object sender, PointMonitorEventArgs e)
      {
            Database db = HostApplicationServices.WorkingDatabase;
            InputPointContext ipc = e.Context;
            FullSubentityPath[] ePaths = ipc.GetPickedEntities();
            if (ePaths.Length > 0)
            {
                FullSubentityPath ePath = ePaths;
                using (Transaction trans = db.TransactionManager.StartTransaction())
                {
                  ObjectId entId = ePath.GetObjectIds();
                  Entity ent = (Entity)trans.GetObject(entId, OpenMode.ForRead);
                  e.AppendToolTipText("\n这是 :" + ent.GetType().FullName);
                  trans.Commit();
                }
            }
      }
    }
}加载DLL,输入teston命令后,用鼠标指向一个图元,会出现tooltip提示。用testoff命令可关掉这个功能。当然,你可以进一步修改代码,如显示扩展数据,加载DLL后功能即打开……

evergreenxq 发表于 2019-5-16 16:00:47

e.AppendToolTipText 不显示内容

雪山飞狐_lzh 发表于 2009-6-4 19:45:00

<p>以前试过ToolTip,但有个问题,2010里的ToolTip是灰色的底色,</p><p>而代码实现的是蓝色的,有办法解决么?</p>

wuzhiheidong 发表于 2009-7-25 22:37:00

<p>VB代码:</p><p>Imports Autodesk.AutoCAD.ApplicationServices<br/>Imports Autodesk.AutoCAD.DatabaseServices<br/>Imports Autodesk.AutoCAD.EditorInput<br/>Imports Autodesk.AutoCAD.GeomeTry<br/>Imports Autodesk.AutoCAD.Runtime</p><p>Namespace tooltip<br/>&nbsp;&nbsp;&nbsp; Public Class Class1<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;CommandMethod("TestOn")&gt; _<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Public Sub MyTestOn()<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AddHandler ed.PointMonitor, New PointMonitorEventHandler(AddressOf ed_PointMonitor)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End Sub<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;CommandMethod("TestOff")&gt; _<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Public Sub MyTestOff()<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; RemoveHandler ed.PointMonitor, New PointMonitorEventHandler(AddressOf ed_PointMonitor)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End Sub</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Private Sub ed_PointMonitor(ByVal sender As Object, ByVal e As PointMonitorEventArgs)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim db As Database = HostApplicationServices.WorkingDatabase<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim ipc As InputPointContext = e.Context<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim ePaths() As FullSubentityPath = ipc.GetPickedEntities()<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If ePaths.Length &gt; 0 Then<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim ePath As FullSubentityPath = ePaths(0)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim trans As Transaction = db.TransactionManager.StartTransaction()<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim entId As ObjectId = ePath.GetObjectIds()(0)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim ent As Entity = CType(trans.GetObject(entId, OpenMode.ForRead), Entity)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; e.AppendToolTipText(vbCrLf &amp; "这是 :" + ent.GetType().FullName)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; trans.Commit()<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End Sub<br/>&nbsp;&nbsp;&nbsp; End Class<br/>End Namespace<br/></p>

zyc_gz 发表于 2009-7-28 11:42:00

学习学习

CAD学习开发 发表于 2009-8-11 19:09:00

没看懂,希望高手指点一下VBA部分的!

Student 发表于 2011-1-14 20:01:30

我测试了一下,程序运行正常
可就是看不到ToolTip,不知是什么原因?

dchlmz 发表于 2011-5-3 10:12:59

好好学习,正是我要学习的东西

易晨托 发表于 2013-11-6 10:43:49

我直接使用这个e.AppendToolTipText显示内容,为什么不显示呢?各位大神帮忙啊。。。谢谢了

cooolseee 发表于 2013-11-12 22:40:34

真不错的工具

鱼与熊掌 发表于 2015-8-8 17:25:33

学习    了赞   ~
页: [1] 2
查看完整版本: tooltip显示图元类型