发布网友 发布时间:2023-04-23 12:47
共3个回答
热心网友 时间:2023-10-09 14:14
不知道你的“一种线”是什么?我这有一个选择一些直线,统计总长度的LISP,供你参考,有问题可追问。
热心网友 时间:2023-10-09 14:14
(defun c:dl ( )追答(defun c:dl ( )
(if (null vlax-mp-object)
(vl-load-com)
)
(princ "\n选择要进行线长统计的对象")
(if (setq #si 0 &ss (ssget))
(progn
(setq #lc 0 #ll 0 #lp 0 #lr 0 #le 0 #ls 0 #nc 0 #nl 0 #np 0 #nr 0 #ne 0 #ns 0)
(repeat (sslength &ss)
(setq &cs (vlax-ename->vla-object (ssname &ss #si)) #si (1+ #si))
(cond
((= (vla-get-objectname &cs) "AcDbCircle")
(setq #lc (+ #lc (vla-get-circumference &cs)) #nc (1+ #nc))
)
((= (vla-get-objectname &cs) "AcDbArc")
(setq #lr (+ #lr (vla-get-arclength &cs)) #nr (1+ #nr))
)
((= (vla-get-objectname &cs) "AcDbPolyline")
(setq #lp (+ #lp (vla-get-length &cs)) #np (1+ #np))
)
((= (vla-get-objectname &cs) "AcDbLine")
(setq #ll (+ #ll (vla-get-length &cs)) #nl (1+ #nl))
)
((= (vla-get-objectname &cs) "AcDbEllipse")
(setq #le (+ #le (vlax-curve-getdistatparam &cs (vlax-curve-getendparam &cs))) #ne (1+ #ne))
)
((= (vla-get-objectname &cs) "AcDbSpline")
(setq #ls (+ #ls (vlax-curve-getdistatparam &cs (vlax-curve-getendparam &cs))) #ns (1+ #ns))
)
)
)
(princ (strcat "\n选择的 " (itoa (sslength &ss)) " 个对象中:"))
(princ (strcat "\n圆形对象 = " (itoa #nc) " 个,线长 = " (rtos #lc 2 3) " ,"))
(princ (strcat "\n圆弧对象 = " (itoa #nr) " 个,线长 = " (rtos #lr 2 3) " ,"))
(princ (strcat "\n直线对象 = " (itoa #nl) " 个,线长 = " (rtos #ll 2 3) " ,"))
(princ (strcat "\n聚合对象 = " (itoa #np) " 个,线长 = " (rtos #lp 2 3) " ,"))
(princ (strcat "\n椭圆对象 = " (itoa #ne) " 个,线长 = " (rtos #le 2 3) " ,"))
(princ (strcat "\n云形对象 = " (itoa #ns) " 个,线长 = " (rtos #ls 2 3) " ,"))
(princ (strcat "\n所有对象总线长 = " (rtos (+ #lc #lr #ll #lp #le #ls) 2 3) " ."))
)
)
(princ)
)
热心网友 时间:2023-10-09 14:14
椭圆和样条曲线也可加进去,