谢谢Marko,如果SamiFox的意图是始终使用(*pi编号),那么:
- (defun C:PLR ( / cen n ang)
- (setq cen '(20.9463 13.5021 0.0))
- (while (setq n (getreal "\nEnter a factor (* pi n) - n: "))
- (setq ang (* pi n))
- (while (> ang (* pi 2))
- (setq ang (- ang (* pi 2)))
- )
- (command "line" "_non"
- cen "_non"
- (polar cen ang 50) ""
- )
- (princ (Strcat "(* pi " (rtos n) ") : " (angtos ang 0 2)))
- )
- (princ)
- )
但是如果每次都想输入一个不同的表达式,那么你可以使用这样的东西
- (defun C:PLR (/ cen n ang)
- (setq cen '(20.9463 13.5021 0.0))
- (while [color="blue"](/= (setq n (getstring T "\nEnter lisp expression :")) "")[/color]
- [color="blue"](setq _n n
- ang (eval (read n))
- )[/color]
- (while (> ang (* pi 2))
- (setq ang (- ang (* pi 2)))
- )
- (command "line"
- "_non"
- cen
- "_non"
- (polar cen ang 50)
- ""
- )
- [color="blue"] (princ (Strcat _n " : " (angtos ang 0 2)))[/color]
- )
- (princ)
- )
**注:无错误陷阱[its for the OP to add]**(即输入的有效性)
HTH公司 |