Arepo Posted November 18, 2013 Posted November 18, 2013 (edited) I need some advice to change the cursor type (shape) during the program to match the input asked. Eg. I need to change the cursor to a cross (target) and then to change it back to default. I guess it has something to do with grread, I read AutoCAD help and a few examples on internet but I couldn't make it work. If someone could give me an example how to manipulate it would be great. Thank you. Edited November 18, 2013 by Arepo Quote
Lee Mac Posted November 18, 2013 Posted November 18, 2013 Quick example: (defun c:cursortype ( / c g ) (setq c 0) (princ "\nChoose [None/Point/Selection]: ") (while (or (= 5 (car (setq g (grread nil 14 c)))) (and (= 2 (car g)) (member (cadr g) '(78 80 83 110 112 115)) ) ) (if (= 2 (car g)) (setq c (cadr (assoc (cadr g) '((78 1)(80 0)(83 2)(110 1)(112 0)(115 2))))) ) ) (princ) ) Quote
Arepo Posted November 19, 2013 Author Posted November 19, 2013 Thanks for the example, Lee Mac. It works, but unfortunately, I am unable to decipher it and adapt it to what I need. I was expecting to have a variable that needs to be changed so the cursor changes without asking user for input to change cursor. I tried using your example as a function to pass a variable to, but unsuccessful. ... some code - default cursor type ... some code - target cursor type (or none) ... some code - default cursor type again Quote
eldon Posted November 19, 2013 Posted November 19, 2013 Is the system variable CURSORSIZE what you have been looking for? Quote
Lee Mac Posted November 19, 2013 Posted November 19, 2013 ... some code - default cursor type... some code - target cursor type (or none) ... some code - default cursor type again Here is another quick example: (defun c:test ( / e g ) (princ "\nPick a point: ") (while (= 5 (car (setq g (grread nil 12 0))))) (if (= 3 (car g)) (progn (princ "\nUser picked ") (princ (cadr g)) ) ) (princ "\nSelect an object: ") (while (= 5 (car (setq g (grread nil 12 2))))) (if (and (= 3 (car g)) (setq e (car (nentselp (cadr g)))) ) (princ (strcat "\nUser selected a " (strcase (cdr (assoc 0 (entget e))) t))) ) (princ) ) Quote
Arepo Posted November 20, 2013 Author Posted November 20, 2013 Thanks, Lee Mac. This example is more clear. I am trying to adapt it to my program. It kind of works, but I have to hit ENTER to make the program continue, and when I do that, the cursor goes back to default. Here's what I'm trying to do: ..some code - box cursor type (while (null n) ;;here inside while I need point (target) cursor type instead of default (setq n (getint "\nNo of spaces: ")) (if (<= n 0) (progn (setq n nil) (princ "\nRequires a positive no. ") ) ) ) ;end while ...some code - back to default cursor Quote
Lee Mac Posted November 20, 2013 Posted November 20, 2013 ..some code - box cursor type (while (null n) [color=red];;here inside while I need point (target) cursor type instead of default[/color] (setq n (getint "\nNo of spaces: ")) (if (<= n 0) (progn (setq n nil) (princ "\nRequires a positive no. ") ) ) ) ;end while ...some code - back to default cursor This is not possible to achieve with your code since the cursor type will only be modified during evaluation of the grread function, and will revert back to the standard cursor when other user-input functions (such as getint) are evaluated. The only way to change the cursor for the prompt would be to write your own version of the getint function using grread. This is not impossible, but not worth the effort in my opinion if you are only looking to change the cursor appearance. Quote
Arepo Posted November 20, 2013 Author Posted November 20, 2013 (edited) I understand. I appreciate your help, Lee Mac. Edited November 21, 2013 by Arepo Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.