新手发个 动态按键旋转 1 15 45 90 180度
本帖最后由 weiqi 于 2012-12-2 21:44 编辑已修改~新手发个 按键旋转
《1键- 1度》《2键-1度》《Q键 15度》《W键 -15度》《E键 45度》
《A键 90度》《E键 -90度》 《D键 180度》
大小写通过了~
空格 回车退出 (不报错 已修改)
;;; ----------------------------------------------------------------------------
;;; ----------------------= = = =主 函 数= = = =------------------------
;;; ----------------------------------------------------------------------------
;;; ( 通过键盘旋转目标 )
;;; ----------------------------------------------------------------------------
(DEFUN C:xz (/ cmd loop SSet KeyList n step BasePoint0 BasePoint1 BasePoint2)
(SETQ cmd (GETVAR "CMDECHO"))
(SETVAR "CMDECHO" 0)
(SETQ loop 1)
(WHILE loop
(PROMPT "\n 选择对象 : ")
(SETQ SSet (SSGET))
(COND
((NULL SSet)(ALERT "没有选中对象!"))
(T (SETQ loop nil))
)
)
(setq p1 (getpoint "指定基点: "))
(PRINC "\n Press key:")
(PRINC "\n\t 《1键- 1度》《2键-1度》《Q键 15度》《W键 -15度》《E键 45度》 ")
(PRINC "\n\t 《A键 90度》《E键 -90度》 《D键 180度》")
(TERPRI)
(SETQ KeyList '(3249 50 65 68 81 83 87 119 101 113 32 115 97 100))
(WHILE (/= (SETQ n (CADR (GRREAD))) 13)
(if (MEMBER n KeyList)
(COND
((= n 49)(COMMAND "ROTATE" SSet "" p1 1)(PRINC "\r< +1度 >"))
((= n 50)(COMMAND "ROTATE" SSet "" p1 -1)(PRINC "\r< -1度 >"))
((= n 113)(COMMAND "ROTATE" SSet "" p1 15)(PRINC "\r< q 15度 >"))
((= n 81)(COMMAND "ROTATE" SSet "" p1 15)(PRINC "\r< Q 15度 >"))
((= n 119)(COMMAND "ROTATE" SSet "" p1 -15)(PRINC "\r< w -15度 >"))
((= n 87)(COMMAND "ROTATE" SSet "" p1 -15)(PRINC "\r< W -15度 >"))
((= n 101)(COMMAND "ROTATE" SSet "" p1 45)(PRINC "\r< e 45度 >"))
((= n 69)(COMMAND "ROTATE" SSet "" p1 45)(PRINC "\r< E45度 >"))
((= n 115)(COMMAND "ROTATE" SSet "" p1 -90)(PRINC "\r< s -90度 >"))
((= n 83)(COMMAND "ROTATE" SSet "" p1 -90)(PRINC "\r< S -90度 >"))
((= n 97) (COMMAND "ROTATE" SSet "" p1 90)(PRINC "\r< a90度>"))
((= n 65) (COMMAND "ROTATE" SSet "" p1 90)(PRINC "\r< A90度>"))
((= n 100)(COMMAND "ROTATE" SSet "" p1 180)(PRINC "\r< d 180度>"))
((= n 68)(COMMAND "ROTATE" SSet "" p1 180)(PRINC "\r< D 180度>"))
((= n 32)(nil))
)
)
);WHILE
(SETVAR "CMDECHO" cmd)
(PRINC)
)
(PRINC "按键旋转1 2 q w e a s d 命令XZ ")
这个工作中能用到,下载了! 这个工作中能用到,精彩! 很有意思 学习了 试用了下,得按ESC 才退出,应该是没考虑输入除w、s、a、d外其它字符的处理(甚至是上述字符的大写都不行);如果最后一次输入w、s、a、d的话,还是能够通过回车退出的,自己再改下吧。 高手 能否 出手一下,实在 基础不行噢。。。
;;; ----------------------------------------------------------------------------
;;; ----------------------= = = =主 函 数= = = =------------------------
;;; ----------------------------------------------------------------------------
;;; ( 通过键盘旋转目标 )
;;; ----------------------------------------------------------------------------
(DEFUN C:xz (/ cmd loop SSet KeyList n step BasePoint0 BasePoint1 BasePoint2)
(SETQ cmd (GETVAR "CMDECHO"))
(SETVAR "CMDECHO" 0)
(SETQ loop 1)
(WHILE loop
(PROMPT "\n 选择对象 : ")
(SETQ SSet (SSGET))
(COND
((NULL SSet)(ALERT "没有选中对象!"))
(T (SETQ loop nil))
)
)
(setq p1 (getpoint "指定基点: "))
(PRINC "\n Press key:")
(PRINC "\n\t w --- UP")
(PRINC "\n\t s --- DOWN")
(PRINC "\n\t a --- LEFT")
(PRINC "\n\t d --- RIGHT")
(PRINC "\n 请按方向键 W S A D")
(TERPRI)
(SETQ KeyList '(119 115 97 100))
(WHILE (/= (SETQ n (CADR (GRREAD))) 13)
(if (MEMBER n KeyList)
(COND
((= n 119)(COMMAND "ROTATE" SSet "" p1 15)(PRINC "\r< 上 15度 >"))
((= n 115)(COMMAND "ROTATE" SSet "" p1 180)(PRINC "\r< 下 180度 >"))
((= n 97) (COMMAND "ROTATE" SSet "" p1 90)(PRINC "\r< 左90度>"))
((= n 100)(COMMAND "ROTATE" SSet "" p1 -90)(PRINC "\r< 右 -90度>"))
)
)
);WHILE
(SETVAR "CMDECHO" cmd)
(PRINC)
)
(PRINC "按键旋转 w a s d 命令XZ ")
ZZXXQQ 发表于 2012-12-1 19:14 static/image/common/back.gif
Z版 貌似 还是 退出不了哦。 已经修改了代码 大小写 已经都能 通用,但是 空格回车的时候 会报错~
((= n 32)(exit)) 这么写应该不对~~
另外问下 鼠标右键的 键码是多少呢? 望高手出手相助~~~ 这个要做记号的 小改一下,除了定义的那几个键,按其它任意键都会退出。;;; ----------------------------------------------------------------------------
;;; ----------------------= = = =主 函 数= = = =------------------------
;;; ----------------------------------------------------------------------------
;;; ( 通过键盘旋转目标 )
;;; ----------------------------------------------------------------------------
(DEFUN C:xz (/ cmd loop SSet KeyList n step BasePoint0 BasePoint1 BasePoint2)
(SETQ cmd (GETVAR "CMDECHO"))
(SETVAR "CMDECHO" 0)
(SETQ loop 1)
(WHILE loop
(PROMPT "\n 选择对象 : ")
(SETQ SSet (SSGET))
(COND
((NULL SSet)(ALERT "没有选中对象!"))
(T (SETQ loop nil))
)
)
(setq p1 (getpoint "指定基点: "))
(PRINC "\n Press key:")
(PRINC "\n\t 《1键- 1度》《2键-1度》《Q键 15度》《W键 -15度》《E键 45度》 ")
(PRINC "\n\t 《A键 90度》《E键 -90度》 《D键 180度》")
(TERPRI)
(SETQ KeyList '(3249 50 65 68 81 83 87 119 101 113 32 115 97 100))
(WHILE (and(/= (SETQ n (CADR (GRREAD))) 13)
(MEMBER n KeyList))
(COND
((= n 49)(COMMAND "ROTATE" SSet "" p1 1)(PRINC "\r< +1度 >"))
((= n 50)(COMMAND "ROTATE" SSet "" p1 -1)(PRINC "\r< -1度 >"))
((= n 113)(COMMAND "ROTATE" SSet "" p1 15)(PRINC "\r< q 15度 >"))
((= n 81)(COMMAND "ROTATE" SSet "" p1 15)(PRINC "\r< Q 15度 >"))
((= n 119)(COMMAND "ROTATE" SSet "" p1 -15)(PRINC "\r< w -15度 >"))
((= n 87)(COMMAND "ROTATE" SSet "" p1 -15)(PRINC "\r< W -15度 >"))
((= n 101)(COMMAND "ROTATE" SSet "" p1 45)(PRINC "\r< e 45度 >"))
((= n 69)(COMMAND "ROTATE" SSet "" p1 45)(PRINC "\r< E45度 >"))
((= n 115)(COMMAND "ROTATE" SSet "" p1 -90)(PRINC "\r< s -90度 >"))
((= n 83)(COMMAND "ROTATE" SSet "" p1 -90)(PRINC "\r< S -90度 >"))
((= n 97) (COMMAND "ROTATE" SSet "" p1 90)(PRINC "\r< a90度>"))
((= n 65) (COMMAND "ROTATE" SSet "" p1 90)(PRINC "\r< A90度>"))
((= n 100)(COMMAND "ROTATE" SSet "" p1 180)(PRINC "\r< d 180度>"))
((= n 68)(COMMAND "ROTATE" SSet "" p1 180)(PRINC "\r< D 180度>"))
((= n 32)(nil))
)
);WHILE
(SETVAR "CMDECHO" cmd)
(PRINC)
)
(PRINC "按键旋转1 2 q w e a s d 命令XZ ")
学习了 确实强大。。
页:
[1]
2