PDA

View Full Version : calculating total length of solids in dwg



cwjean76
2009-05-26, 06:43 PM
I have a drawing attached that was created in vanilla 2009. It's a 3D cage for a jeep. What I'm looking for is some type of LISP routine that will calculate all the lengths of the pipe, which are all solids. Can anyone help with this? :?

dgorsman
2009-05-26, 06:44 PM
You could throw in a polyline along the center of each pipe, then calculate the total length from those.

cwjean76
2009-05-26, 06:46 PM
forgot to attach the file. well, there's a lot of segments and i would like to avoid having to do that.

cwjean76
2009-05-26, 07:25 PM
Most of the routines out there are dependent on polylines only and do not add arc lengths. However, I did find one that seems to work with ALL objects. Give me exactly what I want. I do not know how the author is. Here it is:

(defun C:TL (/ 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)
)