帮助计算线条长度
您好,我需要计算所有选定行的长度,但我的脚本一直给我这个错误:lentyp nil。有人能帮忙吗?
试试这个。。。我从这个论坛上得到这个,但不记得是谁
道歉
(defun C:TLEN (/ ss tl n ent itm obj l)
(setq ss (ssget)
tl 0
n (1- (sslength ss)))
(while (>= n 0)
(setq ent (entget (setq itm (ssname ss n)))
obj (cdr (assoc 0 ent))
l (cond
((= obj "LINE")
(distance (cdr (assoc 10 ent))(cdr (assoc 11 ent))))
((= obj "ARC")
(* (cdr (assoc 40 ent))
(if (minusp (setq l (- (cdr (assoc 51 ent))
(cdr (assoc 50 ent)))))
(+ pi pi l) l)))
((or (= obj "CIRCLE")(= obj "SPLINE")(= obj "POLYLINE")
(= obj "LWPOLYLINE")(= obj "ELLIPSE"))
(command "_.area" "_o" itm)
(getvar "perimeter"))
(T 0))
tl (+ tl l)
n (1- n)))
(alert (strcat "Total length of selected objects is " (rtos tl)))
(princ)
)
请在此处尝试:http://www.cadtutor.net/forum/showthread.php?42734-线路长度计算器 可能是这样的:
(defun c:tLen nil
;; © Lee Mac 2010
(
(lambda ( SelSet Total i / entity )
(if SelSet
(princ
(strcat "\nTotal Length: "
(rtos
(while (setq entity (ssname SelSet (setq i (1+ i))))
(setq Total
(+
(vlax-curve-getDistAtParam entity
(vlax-curve-getEndParam entity)
)
Total
)
)
)
)
)
)
)
)
(ssget
(list (cons 0 "ARC,CIRCLE,ELLIPSE,LINE,*POLYLINE,SPLINE")
(cons -4 "<NOT")
(cons -4 "<AND")
(cons 0 "POLYLINE")
(cons -4 "<OR")
(cons -4 "&=") (cons 70 16)
(cons -4 "&=") (cons 70 64)
(cons -4 "OR>")
(cons -4 "AND>")
(cons -4 "NOT>")
)
)
0 -1
)
(princ)
)
页:
[1]