Scroll down to Measurement and Dimensiong. It's called elen.lsp.
http://www.asmitools.com/Files/Programs.html
Thanks to ASMI!
Registered forum members do not see this ad.
Hey everyone, I have seen Lisp routines before where you can select multiple lines and/or plines and it will add up the total length. Tried doing a search on here but I guess I'm not having any luck.... can anyone point to one? Thanks in advance. If not, no worries, just thought of something that might be of interest to our estimators here in the office....![]()
Tannar Frampton | Facilities Engineering | Revit 2013
Personal Projects | Fender Squier Stratocaster | Custom Smoker | Concrete Patio
Scroll down to Measurement and Dimensiong. It's called elen.lsp.
http://www.asmitools.com/Files/Programs.html
Thanks to ASMI!
"I have only come here seeking knowledge. Things they wouldn't teach me of in college." The Police
Eat brains...gain more knowledge!
Or this 1:
http://www.cadtutor.net/faq/question...ISP+routine%3F
-David
R12 (Dos) - A2K
Or this...
or this one extracts them to excel
Code:(defun c:ple (/ layer layer_list leng row ss sumlen total xlApp xlCells) (vl-load-com) (if (setq ss (ssget "_X" (list (cons 0 "*POLYLINE")))) (progn (setq xlApp (vlax-get-or-create-object "Excel.Application") xlCells (vlax-get-property (vlax-get-property (vlax-get-property (vlax-invoke-method (vlax-get-property xlApp "Workbooks") "Add") "Sheets") "Item" 1) "Cells")) (vla-put-visible xlApp :vlax-true) (vlax-put-property xlCells "Item" 1 1 "Layer") (vlax-put-property xlCells "Item" 1 2 "Length") (setq row 2 total 0) (mapcar '(lambda (z) (if (not (member z layer_list)) (setq layer_list (append (list z) layer_list)))) (mapcar '(lambda (z) (cdr (assoc 8 (entget z)))) (mapcar 'cadr (ssnamex ss)))) (repeat (length layer_list) (setq layer (car layer_list)) (setq ss (ssget "_X" (list (cons 0 "*POLYLINE")(cons 8 layer))) sumlen 0) (mapcar '(lambda (z) (setq sumlen (+ sumlen (vla-get-length (vlax-ename->vla-object (cadr z)))))) (ssnamex ss)) (vlax-put-property xlCells "Item" row 1 layer) (vlax-put-property xlCells "Item" row 2 (rtos sumlen 2 3)) (setq total (+ total sumlen)) (setq layer_list (cdr layer_list)) (setq row (+ row 1)) ) (setq row (+ row 1)) (vlax-put-property xlCells "Item" row 1 "Total:") (vlax-put-property xlCells "Item" row 2 (rtos total 2 3)) (vlax-release-object xlApp) (alert "Close Excel file manually") (gc)(gc) (princ) ) (alert "There are no Polylines on your drawing!")) )
***Commandobill***
Abusing AutoCad Since 1999
"Caddatude... Do you has it?"
Sorry for my poor English, I'm American...
This is in desperate need of an update, but I've just been too lazy and don't use it much, but since everyone is posting theirs, I just thought I'd be part of the gang.
TotalLength.gif
Last edited by alanjt; 3rd Jun 2010 at 01:58 pm.
DropBox | finding the light...
Seann: ...it went crazy ex-girlfriend on me...
eric_monceaux...its pretty funny seeing two AutoCAD Gods give each other flak...
I guess it's something you can use.
I think I'll sit down and do an update tonight, after the baby goes to sleep, and I'll def. add circle.
Because I'm retarded.I needed it badly a while back, wrote it, used it a few times and haven't really touched it. A buddy of mine uses it all the time for As-Built surveys.
I'll at least add circles and fix the units tonight.![]()
DropBox | finding the light...
Seann: ...it went crazy ex-girlfriend on me...
eric_monceaux...its pretty funny seeing two AutoCAD Gods give each other flak...
Hi guys, i have code thats similar to this but i have a few problems with it.
The problem is that it calculates the lenghths of ALL polylines in the drawing.
I would like it if it only calculated the lengths of the polylines from my selection and send the totals to excel by layer.
The code i have currently looks like this:
Code:(defun c:ple (/ elist en i layer layer_list leng pline row ss sumlen total x xlApp xlBook xlBooks xlCells xlSheet xlSheets ) (vl-load-com) (setq xlApp (vlax-get-or-create-object "Excel.Application") xlBooks (vlax-get-property xlApp "Workbooks") xlBook (vlax-invoke-method xlBooks "Add") xlSheets (vlax-get-property xlBook "Sheets") xlSheet (vlax-get-property xlSheets "Item" 1) xlCells (vlax-get-property xlSheet "Cells") ) (vla-put-visible xlApp :vlax-true) ;headers (vlax-put-property xlCells "Item" 1 1 "Layer") (vlax-put-property xlCells "Item" 1 2 "Length") (setq row 2 total 0) (setq ss (ssget "_X" (list (cons 0 "*POLYLINE"))) i -1) (repeat (sslength ss) (setq en (ssname ss (setq i (1+ i))) elist (entget en) layer (cdr (assoc 8 elist))) (if (not (member layer layer_list)) (setq layer_list (cons layer layer_list)))) (repeat (length layer_list) (setq layer (car layer_list)) (vlax-put-property xlCells "Item" row 1 layer) (setq ss (ssget "_X" (list (cons 0 "*POLYLINE")(cons 8 layer))) i -1 sumlen 0) (repeat (sslength ss) (setq row (1+ row)) (setq pline (vlax-ename->vla-object (ssname ss (setq i (1+ i))))) (setq leng (vlax-curve-getdistatparam pline (vlax-curve-getendparam pline))) (vlax-put-property xlCells "Item" row 2 (rtos leng 2 3)) ;;; (vlax-put-property xlCells "Item" row 2 (rtos leng 2 3)); for metric units (setq sumlen (+ sumlen leng))) (setq row (1+ row)) (vlax-put-property xlCells "Item" row 1 "SubTotal:") (vlax-put-property xlCells "Item" row 2 (rtos sumlen 2 3)) (setq total (+ total sumlen)) ;;; (vlax-put-property xlCells "Item" row 2 (rtos sumlen 2 3)); for metric units (setq layer_list (cdr layer_list)) (setq row (+ row 2)) ) ; footers: (vlax-put-property xlCells "Item" row 1 "Total:") (vlax-put-property xlCells "Item" row 2 (rtos total 2 3)) ;;;(vlax-put-property xlCells "Item" row 2 (rtos total 2 3)); for metric units (mapcar (function (lambda(x) (vl-catch-all-apply (function (lambda() (progn (vlax-release-object x) (setq x nil))))))) (list xlCells xlSheet xlSheets xlBook xlBooks xlApp) ) (alert "Close Excel file manually") (gc)(gc) (princ) ) (princ "\t\t***\t Type PLE to write polines length to Excel\t***") (princ)




A man who never made mistakes never made anything
Bookmarks