乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 31|回复: 7

[编程交流] Change Cursor Type (Shape)

[复制链接]

7

主题

24

帖子

17

银币

初来乍到

Rank: 1

铜币
35
发表于 2022-7-5 23:57:58 | 显示全部楼层 |阅读模式
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.
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 00:09:35 | 显示全部楼层
Quick example:
  1. (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))
回复

使用道具 举报

7

主题

24

帖子

17

银币

初来乍到

Rank: 1

铜币
35
发表于 2022-7-6 00:19:35 | 显示全部楼层
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
回复

使用道具 举报

8

主题

1133

帖子

1164

银币

初来乍到

Rank: 1

铜币
10
发表于 2022-7-6 00:25:42 | 显示全部楼层
Is the system variable CURSORSIZE what you have been looking for?
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 00:37:30 | 显示全部楼层
 
Here is another quick example:
  1. (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))
回复

使用道具 举报

7

主题

24

帖子

17

银币

初来乍到

Rank: 1

铜币
35
发表于 2022-7-6 00:43:47 | 显示全部楼层
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:

[code]..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 (
回复

使用道具 举报

114

主题

1万

帖子

1万

银币

中流砥柱

Rank: 25

铜币
543
发表于 2022-7-6 00:56:57 | 显示全部楼层
 
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.
回复

使用道具 举报

7

主题

24

帖子

17

银币

初来乍到

Rank: 1

铜币
35
发表于 2022-7-6 00:59:19 | 显示全部楼层
I understand. I appreciate your help, Lee Mac.
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-10 21:24 , Processed in 0.435853 second(s), 68 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表