Posts: 15
Registered: ‎11-01-2005
Message 1 of 4 (939 Views)

Pointmonitor for VB.net

939 Views, 3 Replies
01-24-2011 01:29 PM

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.





*Expert Elite*
Posts: 1,285
Registered: ‎06-21-2004
Message 2 of 4 (915 Views)

Re: Pointmonitor for VB.net

01-24-2011 07:34 PM in reply to: jeroen_verdonschot

You can use




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
        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
            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
                ' Cheaper than aborting
            End Using

            ' Add the tooltip of the lengths of the curves detected

            If curveInfo <> "" Then
            End If
            ' 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))
Posts: 246
Registered: ‎03-11-2008
Message 3 of 4 (693 Views)

Re: Pointmonitor for VB.net

07-06-2011 05:42 AM 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?

Posts: 246
Registered: ‎03-11-2008
Message 4 of 4 (671 Views)

Re: Pointmonitor for VB.net

07-06-2011 11:48 PM 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.

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!