Hi All,
I'm trying to use a Pointmonitor event event but can't find an easy example.
I want to find and use pointer coords into my code but I don't understand how it works.
I tried to translate the examples by Kean Walmsley:
Please help.
Thanks,
Jeroen
You can use
e.Context.LastPoint.X
e.Context.LastPoint.Y
to get the location of the pointer.
Here is Tony's code in VB.
Imports Autodesk.AutoCAD.ApplicationServices Imports Autodesk.AutoCAD.DatabaseServices Imports Autodesk.AutoCAD.Runtime Imports Autodesk.AutoCAD.EditorInput Imports Autodesk.AutoCAD.Geometry Public Class PointMonitorTooltips <CommandMethod("SM")> _ Public Shared Sub StartMonitor() Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor AddHandler ed.PointMonitor, New PointMonitorEventHandler(AddressOf ed_PointMonitor) End Sub <CommandMethod("XM")> _ Public Shared Sub StopMonitor() Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor ed.TurnForcedPickOn() RemoveHandler ed.PointMonitor, AddressOf ed_PointMonitor End Sub Private Shared Sub ed_PointMonitor(ByVal sender As Object, ByVal e As PointMonitorEventArgs) Dim ed As Editor = DirectCast(sender, Editor) Dim doc As Document = ed.Document Try Dim paths As FullSubentityPath() = e.Context.GetPickedEntities() ' Go through the results of the selection ' and detect the curves Dim curveInfo As String = "" Dim tr As Transaction = doc.TransactionManager.StartTransaction() Using tr ' Open each object, one by one For Each path As FullSubentityPath In paths Dim ids As ObjectId() = path.GetObjectIds() If ids.Length > 0 Then Dim id As ObjectId = ids(ids.GetUpperBound(0)) Dim obj As DBObject = tr.GetObject(id, OpenMode.ForRead) If obj IsNot Nothing Then ' If it's a curve, get its length Dim cv As Curve = TryCast(obj, Curve) If cv IsNot Nothing Then Dim length As Double = cv.GetDistanceAtParameter(cv.EndParam) - cv.GetDistanceAtParameter(cv.StartParam) ' Then add a message including the object ' type and its length curveInfo += obj.[GetType]().Name + "'s length: " & String.Format("{0:F}", length) & vbLf End If End If End If Next ' Cheaper than aborting tr.Commit() End Using ' Add the tooltip of the lengths of the curves detected If curveInfo <> "" Then e.AppendToolTipText(curveInfo) End If Catch ' Not sure what we might get here, but not real action ' needed (worth adding an Exception parameter and a ' breakpoint, in case things need investigating). End Try End Sub End Class
I'm trying to use custom tooltips the same way, but for some reason, only the default tooltips are displayed.
e.AppendToolTipText(info) does nothing
maybe some AutoCAD settings disable the custom tooltips?
so i solved it, there were 2 issues
first, i had to turn off the rollover tooltips
and second, I had AUTOSNAP set to 0, you have to have the third bit set to true to have the tooltips displayed. http://forums.autodesk.com/t5/NET/PointMonitor-and-AutoSnap-37/m-p/2125768/highlight/true#M8924 gives a hint.
Hi.
How can I fire off the point monitor event? Perhaps using another event, for example the right click mouse?
You do not fire off PointMonitor event, AutoCAD's Editor does. That is, when the mouse cursor moves on the screen of AutoCAD Ediitor, the event fires. This is how AutoCAD works. Your code cannot stop it.
What your code can do is to handle the event if needed. If you want to something when this event fires, you add event handler
VB:
AddHandler TheEditor.PointMonitor, AddressOf.....
C#
TheEditor.PointMonitor += .....
During your code execution, you likely only need to handle this event in particular steps, so, you register the handler when needed, and then remove the handler when you do not want it.
Since the event fires with every slight move of the mouse, you do not want to do heavy lifting in the event handler, which would cause the mouse move staggering/sticky.
Norman Yuan