This should get you started,watch the word-wrap,Thank jaysen Long for the MASSOC routine
hope it helps
-J-
"And know on to scene 24...."
------------------------------------------------
;;polycount by Jonathan Trostad
;;finds polys on a layer, & gets their endpoints
(defun c:polycount (/ POLYENT MULTI TOTLNGTH RTOTLNGTH SSPART CNT CNT1 LIMIT ptlngt EPTS)
(setq POLYENT (car (entsel "\nSelect Polyline")))
(initget "Yes No")
(setq MULTI (getkword "\nAll Polylines on this layer? [Yes/No] :"))
(setq TOTLNGTH 0
RTOTLNGTH 0)
(if (equal "Yes" MULTI)
(progn
(setq POLYENT (entget POLYENT))
(setq SSPART (list'(0 . "POLYLINE,LWPOLYLINE")(assoc 8 POLYENT)));;find layer
(setq SSPART (ssget "x" SSPART));;find all polys on layer
(setq cnt 0)
(setq LIMIT (sslength SSPART));;how many polys?
(repeat LIMIT
(setq POLYENT (ssname SSPART cnt))
(setq EPTS (massoc 10 (entget POLYENT)));;get endpts
(setq ptlngt (1- (length EPTS))
cnt1 0)
(while
(> ptlngt (+ cnt1 1))
(setq POLYLNGTH (distance (nth cnt1 EPTS) (nth (+ cnt1 1)EPTS));;find segment dist
TOTLNGTH (+ TOTLNGTH POLYLNGTH);; add to total distance
cnt1 (+ cnt1 1))
);end while
(setq RTOTLNGTH (+ RTOTLNGTH TOTLNGTH))
(setq cnt (1+ cnt))
);end limit
);end progn
(progn
(setq EPTS (massoc 10 (entget POLYENT)));;get endpts
(setq ptlngt (1- (length EPTS))
cnt1 0)
(while
(> ptlngt (+ cnt1 1))
(setq POLYLNGTH (distance (nth cnt1 EPTS) (nth (+ cnt1 1)EPTS));;find segment dist
RTOTLNGTH (+ RTOTLNGTH POLYLNGTH);; add to total distance
cnt1 (+ cnt1 1))
);end while
);end else progn
);end if
(princ RTOTLNGTH)
(princ)
);end defun
-------------------------------------------
;Example: (massoc 10 (entget (car (entsel "\nSelect a polyline: "))))
;by Jaysen Long
(defun massoc (key alist / x nlist)
(foreach x alist
(if
(eq key (car x))
(setq nlist (cons (cdr x) nlist))
);end if
);end foreach
(reverse nlist)
);end defun