问题已经解决如下: (setq ptlist '((0 0)(100 125)(125 126)(0 0)(200 125)(380 128)(0 0)(280 125)(320 126))) (setq n (length ptlist)) (setq i 0 num0 0) (command "pline") ( while (< i n) (if (= (car (nth i ptlist)) 0) (setq num0 (+ num0 1)) ) ;(while (car (nth i ptlist))) (if (< num0 2) ;计算第一段线 (progn (setq pt (list (car (nth i ptlist)) (cadr (nth i ptlist)))) (command pt) ) );;;此段无问题 (if ( and (= (car (nth i ptlist)) 0) ( > num0 1)) (progn (command "") ;结束上个多段线 (command "ucs" (list 420 0)) (command "") ;结束UCS (command "pline") ;开始本段多段线 (setq pt (list (car (nth i ptlist)) (cadr (nth i ptlist)))) (command pt) ;输入0起点 ) ) (if ( and (/= (car (nth i ptlist)) 0) ( > num0 1)) (progn (setq pt (list (car (nth i ptlist)) (cadr (nth i ptlist)))) (command pt) ) ) (setq i (+ i 1)) ) (command "") ;;改为函数 (defun transdraw ( ptlt / i n num0 pt ptzero) (setq ptzero (getpoint "请选择第一张图纸零点:")) (command "UCS" ptzero "") (setq n (length ptlt)) (setq i 0 num0 0) (command "pline") ( while (< i n) ;统计每次的0的个数 (if (= (car (nth i ptlt)) 0) (setq num0 (+ num0 1)) ) (if (< num0 2) ;计算第一段线 (progn (setq pt (list (car (nth i ptlt)) (cadr (nth i ptlt)))) (command pt) ) );;;此段无问题 (if ( and (= (car (nth i ptlt)) 0) ( > num0 1)) ;判断0段起点并添入第一点(含0) (progn (command "") ;结束上个多段线 (command "ucs" (list 420 0)) (command "") ;结束UCS (command "pline") ;开始本段多段线 (setq pt (list (car (nth i ptlt)) (cadr (nth i ptlt)))) (command pt) ;输入0起点 ) ) (if ( and (/= (car (nth i ptlt)) 0) ( > num0 1));顺序输入该段除0点后的其他点 (progn (setq pt (list (car (nth i ptlt)) (cadr (nth i ptlt)))) (command pt) ) ) (setq i (+ i 1)) ;i+1,后进入下一循环 );所有多段线输入后,结束while循环 |