在cad中有时会遇到对多条线段一下求和,不用li命令一条一条相加
采用加载LISP命令进行,加载xdqh.lsp,输入命令LENON;
以下为xdqh.lsp的源代码:
;;;-----------------------------------------------------
;;;计算线加总长度
;;;-----------------------------------------------------
(defun C:LENOF (/ CURVE TLEN SS N SUMLEN)
(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 TLEN (vlax-curve-getdistatparam
CURVE
(vlax-curve-getendparam CURVE)
)
)
(setq SUMLEN (+ SUMLEN TLEN))
(setq N (1+ N))
)
(print (strcat "总长度: " (rtos SUMLEN 2 5)))
(princ)
)
加载lisp方法:https://wenku.baidu.com/view/548a553583c4bb4cf7ecd12e.html;
参考文献:https://wenku.baidu.com/view/b969b72d7375a417866f8f5a.html