PDA

View Full Version : how long are those plines?



Maverick91
2005-04-27, 01:50 PM
Howdy y'all,

Part of customization is based on laziness. Please indulge mine.

I'm doing a take-off of track work in a train yard. Is there a quick and easy way to get just the lengths of multiple plines by picking them? I could list them all, but I'd have to scroll though every vertex of every pline. LISP? VBA? Measuring scale?

rad.77676
2005-04-27, 03:43 PM
Try this:


(defun tlines ()
(setq lbeg (cdr (assoc '10 ent)))
(setq lend (cdr (assoc '11 ent)))
(setq llen (distance lbeg lend))
(setq tlen (+ tlen llen))
(ssdel sn ss1)
)

(defun tarcs ()
(setq cen (cdr (assoc '10 ent)))
(setq rad (cdr (assoc '40 ent)))
(setq dia (* rad 2.0))
(setq circ (* (* rad pi) 2.0))
(setq sang (cdr (assoc '50 ent)))
(setq eang (cdr (assoc '51 ent)))
(if (< eang sang)
(setq eang (+ eang (* pi 2.0)))
)
(setq tang (- eang sang))
(setq tang2 (* (/ tang pi) 180.0))
(setq circ2 (/ tang2 360.0))
(setq alen (* circ2 circ))
(setq tlen (+ tlen alen))
(princ)
(ssdel sn ss1)
)

(defun tplines ()
(command "area" "e" sn)
(setq tlen (+ tlen (getvar "perimeter")))
(ssdel sn ss1)
)

(defun tsplines ()
(command "area" "e" sn)
(setq tlen (+ tlen (getvar "perimeter")))
(ssdel sn ss1)
)

(DEFUN C:TOTL (/ tlen ss1 sn sn2 et)
(setq cmdecho (getvar "cmdecho"))
(setvar "cmdecho" 0)
(setq tlen 0)
(prompt "\nSelect only those entities you want for total length: ")
(setq ss1 (ssget))
(while (> (sslength ss1) 0)
(setq sn (ssname ss1 0))
(setq ent (entget sn))
(setq et (cdr (assoc '0 ent)))
(cond
((= et "LINE") (tlines))
((= et "ARC") (tarcs))
((= et "LWPOLYLINE") (tplines))
((= et "POLYLINE") (tplines))
((= et "SPLINE") (tsplines))
((or
(/= et "LINE")
(/= et "ARC")
(/= et "LWPOLYLINE")
(/= et "POLYLINE")
(/= et "SPLINE")
)
(ssdel sn ss1)
)
)
)
(princ (strcat "\nThe Total Length of Selected Lines, Polylines, and Arcs is: " (rtos tlen 2 2)))
(setvar "cmdecho" cmdecho)
(princ)
)

Mike.Perry
2005-04-27, 09:40 PM
Hi

Have a browse of the following threads and the associated links found within -

Extracting a 'Tally of Line Lengths' into a Spreadsheet

Total polyline length

LISP to get total length including ARC, Pline & lines?

Have a good one, Mike