本帖最后由 作者 于 2009-9-23 15:37:36 编辑
用了5楼的源码,为何不能统计多段线长度?我做了如下修改,不知对否 (vl-load-com) (defun C:SUMLEN (/) (setq LST '(("LINE" "直线") ("ARC" "圆弧") ("CIRCLE" "圆") ("LWPOLYLINE" "多段线") ("ELLIPSE" "椭圆") ("SPLINE" "样条线") ) ) (if (setq SS (ssget '((0 . "LINE,ARC,CIRCLE,LWPOLYLINE,ELLIPSE,SPLINE")) ) ) (progn ;;1.逐个统计 (setq I 0) (repeat (sslength SS) (setq EN (ssname SS I) ENT (entget EN) STR (cdr (assoc 0 ENT)) ) (if (setq TMP (assoc STR LST)) (setq LEN (vlax-curve-getdistatparam EN (vlax-curve-getendparam EN) ) LST (subst (append TMP (list LEN)) TMP LST) ) ) (setq I (1+ I)) ) ;;2.显示 (setq PRTXT "线条长度分类统计\n\n类型\t根数\t长度\n----------------------" ) (foreach N LST (if (> (length N) 2) (setq LEN (apply '+ (cddr N)) PRTXT (strcat PRTXT "\n" (cadr N) "\t" (itoa (- (length N) 2)) "\t" (rtos LEN 2 3) ) ) ) ) (setq PRTXT (strcat PRTXT "\n\n总数:" (itoa (- (length (apply 'append LST)) (* 2 (length LST)) ) ) " 总长度:" (rtos (apply '+ (apply 'append (mapcar 'cddr LST)) ) 2 3 ) ) ) (princ PRTXT) (alert PRTXT) ) ) (princ) )
|