我的矩形每次都将以相同的方式绘制,因为它将来自之前制作的LISP。
因此,我想我可以将这些值绑定到我的“I”变量,但我的条件语句每次都输出“Nothing”。为什么程序没有认识到“i”的价值?
- (defun Test (e ed / i vt)
- (setq i 0)
- (repeat (length ed)
- (if (= (car (nth i ed)) 10) ;if item is a vertex
- (progn
- (setq vt (cdr (nth i ed))) ; get vertex values
- (setq X (car vt)) ; get the x value
- (setq Y (cadr vt)) ; get the y value
- (cond
- ((or (= i 0) (= i 1));or
- (setq Y (+ 15 Y)) ; increse the Y value by 15 units
- (setq vt (subst Y (nth 1 vt) vt)); replace the old y value with the new y value
- (setq ed (subst (cons 10 vt) (nth i ed) ed)); update the entity definition with new vertex information
- );cond1
- ((or (= i 2) (= i 3));or
- (setq Y (- 15 Y)) ; decrease the Y value by 15 units
- (setq vt (subst Y (nth 1 vt) vt)); replace the old y value with the new y value
- (setq ed (subst (cons 10 vt) (nth i ed) ed)); update the entity definition with new vertex information
- );cond2
- (t (princ "\nNothing"))
- );cond
- (entmod ed) ; update the drawing
- ) ;progn
- ) ;if
- (setq i (1+ i))
- ) ;repeat
- ) ;Test
- (defun C:MyTest (/ e ed)
- (setq e (car (entsel))
- ed (entget e)
- )
- (if (= (cdr (assoc 0 ed)) "LWPOLYLINE")
- (test e ed)
- ) ;if
- ) ;C:MyTest
|