AutoLISP计算所选图元总长度,代码如下。
(defun c:cd ()
(vl-load-com)
(setq len 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 temp (vlax-curve-getdistatparam
curve
(vlax-curve-getendparam curve)
)
)
(setq len (+ len temp))
(setq n (1+ n))
)
(print (strcat "总长度: " (rtos len 2 5)))
(princ)
)
代码完。
明经通道的源码,选中单个图元就是计算单个图元的长度。