-
Notifications
You must be signed in to change notification settings - Fork 0
/
SUMLEN.lsp
59 lines (47 loc) · 1.5 KB
/
SUMLEN.lsp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
;;; Lisp to sum Total lengths of objects.
(defun C:SUMLEN()
(setvar "cmdecho" 0)
(defun getArc(en)
(command "lengthen" en "")
(getvar "perimeter")
)
(defun getLine(en)
(setq enlist(entget en))
(distance (cdr(assoc 10 enlist)) (cdr(assoc 11 enlist)))
)
(defun getPoly(en)
(command "area" "Object" en)
(getvar "perimeter")
)
(if(setq eset(ssget))
(progn
(setq totalLen 0)
(setq cntr 0)
(while(< cntr (sslength eset))
(setq en(ssname eset cntr))
(setq enlist(entget en))
(setq enType(cdr(assoc 0 enlist)))
(cond
((= enType "ARC" )(setq len(getArc en)))
((= enType "CIRCLE" )(setq len(getPoly en)))
((= enType "ELLIPSE" )(setq len(getPoly en)))
((= enType "LINE" )(setq len(getLine en)))
((= enType "LWPOLYLINE")(setq len(getPoly en)))
((= enType "POLYLINE" )(setq len(getPoly en)))
((= enType "SPLINE" )(setq len(getPoly en)))
(T (setq len 0.0))
)
(while(< (strlen enType) 12)(setq enType(strcat enType " ")))
(princ "\n Found ")
(princ enType)
(princ " with a length of: ")
(princ (rtos len))
(setq totalLen(+ totalLen len))
(setq cntr (+ cntr 1))
)
)
)
(setvar "cmdecho" 1)
(alert (strcat "\n Found " (itoa cntr) " entitie(s) with a Total Length of " (rtos totalLen)))
(princ)
)