Get mouse position

Get mouse position

Anonymous
Not applicable
4,851 Views
5 Replies
Message 1 of 6

Get mouse position

Anonymous
Not applicable

Hi,

 

How can I do to get the cursor position in AutoCAD. I want to get those coordinates that are in the lower left corner in AutoCAD. I saw a solution in C + + but I could not do the same with VB, I need to do this with VB if possible i even use the Point API but can't link with AutoCAD, how i can handle the cursor in .NET?

 

http://adndevblog.typepad.com/autocad/2013/08/get-mouse-cursor-position-without-event.html

 

Thanks, sorry my bad english.

0 Likes
4,852 Views
5 Replies
Replies (5)
Message 2 of 6

Balaji_Ram
Alumni
Alumni

Hi Josuesasilva,

 

There is a discussion forum dedicated to AutoCAD .Net API related queries. Posting your query there will help get you answers quickly.

 

About your query :

 

The blog post that you mentioned does not use events and relies on the Windows API.

 

The easier and more reliable way would be to use the events.

To use the PointMonitor event, please refer to this blog post. This lesson also has a sample code in VB.Net.

http://adndevblog.typepad.com/autocad/2012/10/autocadnet-lesson-6-input-point-monitor.html

 

After you have the PointMonitor event subscribed, you can use the "PointMonitorEventArgs.InputPointContext.RawPoint" or the "ComputedPoint" to get the coordinates.

 

Regards,

Balaji



Balaji
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 3 of 6

Anonymous
Not applicable

2 ways to get cursor position 

1, mfc api, 

BOOL getCursorPos( MSG *msg)
{
if( msg->message == WM_MOUSEMOVE )//here you can add the message you want to watch
{
CPoint pt1;
pt1 = msg->pt;
acedGetAcadDwgView()->ScreenToClient( &pt1 );
acedDwgPoint pt2;
acedCoordFromPixelToWorld( 0, pt1, pt2 );
}

}

 

 

 the pt2, is the format of ads_point

 

2, objectarx api

    the objectarx class, AcEdInputPointMonitor, shall do the thing you need, which can be find in the referece guide.

 

hope these can solve the problems

 

 

0 Likes
Message 4 of 6

Anonymous
Not applicable

[CommandMethod("DT")]

 

public void  mousepoint()
{
Editor acDocEd = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
acDocEd.PointMonitor += new PointMonitorEventHandler(ed_PointMonitor);
}

 

private static void ed_PointMonitor(object sender, PointMonitorEventArgs e)
{
Editor ed = sender as Editor;
ed.WriteMessage("\n" + e.Context.ComputedPoint.X + "|" + e.Context.ComputedPoint.Y);
}

 

[CommandMethod("DT1")]

 

public void removeregistry()
{
Editor acDocEd = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
acDocEd.PointMonitor -= new PointMonitorEventHandler(ed_PointMonitor);
}

Message 5 of 6

Alexander.Rivilis
Mentor
Mentor

@Anonymous

 

Sorry but it is ObjectARX forum and not AutoCAD .NET API forum. AutoCAD .NET API forum here: https://forums.autodesk.com/t5/net/bd-p/152

Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"


Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Expert Elite Member

0 Likes
Message 6 of 6

yulianagonzalezz
Explorer
Explorer

Thanks 🙂

0 Likes