phoenixdjq发表于2009-10-22 11:59:00做个循环是最重要的,楼主看看关于“循环”方面的教材吧
找的半天,没有发现相关材料,能给个链接吗?用死办法写了一个: (defun c:1() (setq ss (ssget)) (setq sl (sslength ss)) (setq a1 (cdr (assoc 1 (entget (ssname ss 0))))) (if (= sl 1) (alert a1)) (if (= sl 2) (alert (setq a2 (STRCAT a1 "," (cdr (assoc 1 (entget (ssname ss 1)))))))) (if (= sl 3) (alert (setq a3 (STRCAT a1 "," (cdr (assoc 1 (entget (ssname ss 1)))) "," (cdr (assoc 1 (entget (ssname ss 2)))))))) (if (= sl 4) (alert (setq a4 (STRCAT a1 "," (cdr (assoc 1 (entget (ssname ss 1)))) "," (cdr (assoc 1 (entget (ssname ss 2)))) "," (cdr (assoc 1 (entget (ssname ss 3)))))))) (if (= sl 5) (alert (setq a5 (STRCAT a1 "," (cdr (assoc 1 (entget (ssname ss 1)))) "," (cdr (assoc 1 (entget (ssname ss 2)))) "," (cdr (assoc 1 (entget (ssname ss 3)))) "," (cdr (assoc 1 (entget (ssname ss 4)))))))) (if (= sl 6) (alert (setq a6 (STRCAT a1 "," (cdr (assoc 1 (entget (ssname ss 1)))) "," (cdr (assoc 1 (entget (ssname ss 2)))) "," (cdr (assoc 1 (entget (ssname ss 3)))) "," (cdr (assoc 1 (entget (ssname ss 4)))) "," (cdr (assoc 1 (entget (ssname ss 5)))))))) (if (= sl 7) (alert (setq a7 (STRCAT a1 "," (cdr (assoc 1 (entget (ssname ss 1)))) "," (cdr (assoc 1 (entget (ssname ss 2)))) "," (cdr (assoc 1 (entget (ssname ss 3)))) "," (cdr (assoc 1 (entget (ssname ss 4)))) "," (cdr (assoc 1 (entget (ssname ss 5)))) "," (cdr (assoc 1 (entget (ssname ss 6)))))))) (if (= sl 8) (alert (setq a8 (STRCAT a1 "," (cdr (assoc 1 (entget (ssname ss 1)))) "," (cdr (assoc 1 (entget (ssname ss 2)))) "," (cdr (assoc 1 (entget (ssname ss 3)))) "," (cdr (assoc 1 (entget (ssname ss 4)))) "," (cdr (assoc 1 (entget (ssname ss 5)))) "," (cdr (assoc 1 (entget (ssname ss 6)))) "," (cdr (assoc 1 (entget (ssname ss 7)))))))) (if (= sl 9) (alert (setq a9(STRCAT a1 "," (cdr (assoc 1 (entget (ssname ss 1)))) "," (cdr (assoc 1 (entget (ssname ss 2)))) "," (cdr (assoc 1 (entget (ssname ss 3)))) "," (cdr (assoc 1 (entget (ssname ss 4)))) "," (cdr (assoc 1 (entget (ssname ss 5)))) "," (cdr (assoc 1 (entget (ssname ss 6)))) "," (cdr (assoc 1 (entget (ssname ss 7)))) "," (cdr (assoc 1 (entget (ssname ss 8)))))))) (if (= sl 10) (alert (setq a10(STRCAT a1 "," (cdr (assoc 1 (entget (ssname ss 1)))) "," (cdr (assoc 1 (entget (ssname ss 2)))) "," (cdr (assoc 1 (entget (ssname ss 3)))) "," (cdr (assoc 1 (entget (ssname ss 4)))) "," (cdr (assoc 1 (entget (ssname ss 5)))) "," (cdr (assoc 1 (entget (ssname ss 6)))) "," (cdr (assoc 1 (entget (ssname ss 7)))) "," (cdr (assoc 1 (entget (ssname ss 8)))) "," (cdr (assoc 1 (entget (ssname ss 9)))))))) ) |