Jump to content

Recommended Posts

Posted (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 by Arepo
Posted

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)
)

Posted

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

Posted

Is the system variable CURSORSIZE what you have been looking for?

Posted
... 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)
)

Posted

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

Posted
..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.

Posted (edited)

I understand. I appreciate your help, Lee Mac.

Edited by Arepo

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...