Cursor position

Cursor position

jptallano
Enthusiast Enthusiast
329 Views
4 Replies
Message 1 of 5

Cursor position

jptallano
Enthusiast
Enthusiast

Hi,

I made a few commands that prompt the user for clicking where something should be inserted in the current space. I use the PointMonitorEventHandler handler and it words perfectly fine. But the object that must be inserted starts following cursor position only after I started moving said cursor. In other words, the PointMonitor event is fired only after the cursor started moving. So, in order for the inserted object to be placed at cursor position as soon as I prompt the user, I need to know the cursor position before I insert it. I found a few topics online about this (https://forums.autodesk.com/t5/objectarx/get-mouse-position/td-p/4682337, https://spiderinnet1.typepad.com/blog/2015/12/get-cursor-position-in-current-ucs-using-autocad-net-a... https://adndevblog.typepad.com/autocad/2013/08/get-mouse-cursor-position-without-event.html), but I'm having trouble understanding or implementing them. Any ideas? 🙂

0 Likes
330 Views
4 Replies
Replies (4)
Message 2 of 5

_gile
Consultant
Consultant

Hi,

I'm not sure to fully understand what you're trying to achieve but it seems to me you should use a Jig instead (search for DrawJig and EntityJig in this forum).



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 3 of 5

jptallano
Enthusiast
Enthusiast

Yes, my explanation in English may be unclear, so here goes in French so we understand each other:

Bonjour Gilles,

En fait, j'ai tout simplement besoin de connaître les coordonnées du curseur, sans avoir à utiliser l'événement PointMonitor.

 

English translation for forum readers:

Actually, I need the cursor's position, without having to use the PointMonitor event.

Message 4 of 5

ActivistInvestor
Mentor
Mentor

Using a PointMonitor to do dynamic dragging is not advisable, because repeatedly updating database-resident objects with each cursor movement will generate massive amounts of undo information and can involve significant memory overhead.

 

AutoCAD doesn't drag objects in the database, it creates clones of them and modifies those, which are not database-resident and have no undo history. It is those clones that are what you see when dragging objects.. It leaves the original objects as-is and only modifies them once, after the user specifies a point.

 

A Jig does not drag objects in the database, and will provide you with the current cursor position. You can find plenty of examples of its use by searching this discussion group. The Jig's AcquirePoint() method will return the current cursor position on the first call and doesn't suffer from the problem that PointMonitor has.

 

Message 5 of 5

jptallano
Enthusiast
Enthusiast

Ok then, let's go jig! 👍

0 Likes