How to get current cursor handle in AutoCAD using C# code?

How to get current cursor handle in AutoCAD using C# code?

kdongLVTHZ
Contributor Contributor
596 Views
4 Replies
Message 1 of 5

How to get current cursor handle in AutoCAD using C# code?

kdongLVTHZ
Contributor
Contributor

Hi, I wonder how to control mouse cursor in AutoCAD.

 

I notice that in AutoCAD the default cursor style is a crosshair with a small square pickbox sitting in its center. When we enter a command like "move" the cursor becomes small pickbox only, and after exiting command mode, the cursor change back to crosshair style again.

 

How can we control such behavior with C# code? Or is there a AutoCAD system variable we can use to easily switch the cursor style back and forth? Or how to get cursor handler in current AutoCAD window so that we may change the cursor style between crosshair and pickbox?

 

-- Thanks!

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

norman.yuan
Mentor
Mentor

You did not provide a concrete cases about when/why you want to change AutoCAD's built-in cursor behaviour (being a cross-hair or pick box...). But in general, it may not be a good idea to let the mouse cursor appear differently from an AutoCAD user is used to. With .NET API, it only allows you to choose Cursor type while doing your custom Jig (JigPromptOptions.Cursor property).

 

On the other hand, AutoCAD adds cursor badge (say, when you issue command "DIST", a question mark shows beside the mouse cursor to suggest the command is inquiring entity's information. This is where you usually do to use meaningful badge alongside the default AutoCAD cursor to catch user's attention. See this article about how to add a cursor badge:

 

https://www.keanw.com/2014/05/adding-a-cursor-badge-in-autocad-2015-using-net.html 

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 3 of 5

kdongLVTHZ
Contributor
Contributor

I think the use case could be a customized command where cursor shows as pickbox while in command mode, and the cursor turns back to default shown as crosshair while we exit command mode. This behavior is the same as AutoCAD "Move" command: cursor as pickbox while in command mode, and cursor as crosshair after finishing "Move" command. The cursor doesn't add any badge on top or beside of it. We want to control the cursor style/type itself in customized command, and let it align with the general AutoCAD cursor behavior for customized command.

 

@norman.yuan Do you have any sample C# code (maybe Jig as mentioned) to achieve this behavior for customized command? -- Thanks!

0 Likes
Message 4 of 5

norman.yuan
Mentor
Mentor

Mouse cursor change in command is NOT BECAUSE OF the command itself, but because of the command required user input: cross hair for picking point, pick box for picking entity.... So, in your command, if you need a user input by calling API Editor.GetXxxxx(), AutoCAD AUTOMATICALLY changes the mouse cursor as required. So, if you use Editor.GetXXXX() in your code/your custom command for user to interact with Editor, you do not need to worry what cursor style. 

 

So, I am not sure/do not understand in what kind of scenario you need to decide what cursor to use and why you do not/cannot use Editor.GetXXXX() to let user interact with AutoCAD editor.

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 5 of 5

kdongLVTHZ
Contributor
Contributor

Editor.GetXXXX() prompts user input and then controls the cursor style accordingly. I guess what I am look for is actually existing inside this Editor.GetXXXX() function.

 

If anyone can share the code how this Editor.GetXXXX() is implemented, that would be cool.

0 Likes