.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Pointmonitor for VB.net

5 REPLIES 5
Reply
Message 1 of 6
jeroen_verdonschot
2909 Views, 5 Replies

Pointmonitor for VB.net

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:

http://through-the-interface.typepad.com/through_the_interface/2009/07/providing-information-on-auto...

 

Please help.

 

Thanks,

 

Jeroen

5 REPLIES 5
Message 2 of 6

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

 

 

---------------------------



(defun botsbuildbots() (botsbuildbots))
Message 3 of 6
matus.brlit
in reply to: arcticad

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?

Message 4 of 6
matus.brlit
in reply to: matus.brlit

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.

Message 5 of 6
joantopo
in reply to: matus.brlit

Hi.

How can I fire off the point monitor event? Perhaps using another event, for example the right click mouse?

Autocad C3D 2019 SP3, 2020 & 2021
Intel I9 9900K with frontal watercooler alphacool eisbaer 360 (original fans mounted in pull)- 3 fans Corsair 120 ML PRO in push.
MOBO Gygabyte Z390 Aorus Master- Corsair RGB Vengeance 64GB RAM (4x16) CL16
Nvidia Quadro RTX 4000
Samsung 970 EVO PLUS 1TB (unit C). Samsung 970 PRO 512GB (for data)
Power Supply: Corsair TX850M PLUS


Descubre mi programa VisorNET para Civil 3D:
https://apps.autodesk.com/CIV3D/es/Detail/Index?id=appstore.exchange.autodesk.com%3avisornet_windows32and64%3aes
Message 6 of 6
norman.yuan
in reply to: joantopo

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

Drive CAD With Code

EESignature

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost