我就常用这程序来统计所选线段长度总和!(命令是 LL ,您可以改成您想用的字符)
(defun CL(/ sumlen ss n curve ObjectName len) (princ"\n统计<直线、圆弧、多义线、样条线、圆、椭圆>等图元的长度") (princ"\n For 中华钢结构论坛 \n 版本2004.03.03") (vl-load-com) (setq sumlen 0) (setq ss (ssget '((0 . "CIRCLE,ELLIPSE,LINE,*POLYLINE,SPLINE,ARC")))) (setq n 0) (repeat (sslength ss) (setq curve (vlax-ename->vla-object (ssname ss n))) (setq ObjectName (vlax-get-property curve 'ObjectName)) (setq ObjectName (substr ObjectName 5)) (setq len (vlax-curve-getdistatparam curve (vlax-curve-getendparam curve) )) (setq sumlen (+ sumlen len)) (setq n (1+ n))
(princ (strcat "\n第" (rtos n) "条是 " ObjectName )) (princ (strcat " 长度: " (rtos len 2 5))) ) (princ (strcat "\n共" (rtos n) "条 " )) (princ (strcat "总长度: " (rtos sumlen 2 5))) (textscr) (princ) )
|