NetBee 发表于 2009-8-2 20:15:00

线长分类统计数量及长度和总数量及总长(源)

<p>需要统计图中各种线长有用,&nbsp;如图</p><p>&nbsp;</p><p>&nbsp;</p>

KO你 发表于 2022-9-13 23:26:08

zgssd 发表于 2009-9-23 13:49
本帖最后由 作者 于 2009-9-23 15:37:36 编辑用了5楼的源码,为何不能统计多段线长度?我做了如下修改, ...

怎样加上面域的线呢   论坛找了很多线长与面积的,但就没有面域的。

Giuly09 发表于 2018-5-9 11:27:15

谢谢分享
程序不错

taoyi0727 发表于 2018-4-24 15:47:05

这个好用 学习下

qyr_0_0 发表于 2009-9-9 11:28:00

<strong><font color="#000000">&nbsp;错误: no function definition: NBTF_DXF----请问版主什么原因?</font></strong>

AMTONNY 发表于 2009-9-9 12:53:00

<p>楼主,请教如何在程序中过滤掉同心圆,只选取最大直径的圆呢?</p><p></p>

zml84 发表于 2009-9-9 16:04:00

(DEFUN nbtf_dxf (I EN)
(CDR (ASSOC I (ENTGET EN)))
)

zml84 发表于 2009-9-9 16:50:00

学习1楼代码,修改后

(vl-load-com)
(defun C:SUMLEN (/)
    (setq LST '(("LINE" "直线")
("ARC" "圆弧")
("CIRCLE" "圆")
("LPOLYLINE" "多段线")
("ELLIPSE" "椭圆")
("SPLINE" "样条线")
      )
    )
    (if (setq SS (ssget '((0 . "LINE,ARC,CIRCLE,LPOLYLINE,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)
)

asdfxx 发表于 2009-9-11 17:33:00

zgssd 发表于 2009-9-23 13:49:00

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

追风 发表于 2010-1-27 12:20:00

好东东,下载了,谢谢分享!

lianheai 发表于 2010-2-8 16:08:00

很受用啊,谢谢了

xotoo 发表于 2011-2-26 17:17:33

留名备用
程序不错
页: [1] 2 3
查看完整版本: 线长分类统计数量及长度和总数量及总长(源)