Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
*Adams, Steve
Message 1 of 4 (805 Views)

Lisp routine that will add up the lengths of all lines, arcs and polylines in

805 Views, 3 Replies
10-15-2003 11:45 AM
Hello Everybody,

I need a lisp routine that will add up the lengths of all
lines, arcs and polylines in a given layer.

Any ideas?

Thanks, Steve (Win98, A2K)
*Repetto, Alex
Message 2 of 4 (805 Views)

Re: Lisp routine that will add up the lengths of all lines, arcs and polyline

10-15-2003 03:18 PM in reply to: *Adams, Steve
Steve,

Below the content of an earlier posting from Jaysen Long (Date: 21-09-1999,
Subject: Total length of selected lines)

Alex


LL sums the length of all objects on selected layers.
OBL sums the length of selected objects.

Both print the output to the command line giving the lengths for different
layers as well as a total.


(defun c:ll ( / ) (ll:smileysurprised:utput "X" "\nSelect objects on layers to total...")
(princ))
(defun c:smileysurprised:bl ( / ) (ll:smileysurprised:utput "P" "\nSelect objects to total...") (princ))


(defun ll:smileysurprised:utput (ll:sstype ll:smileytongue:rompt / ll:ss i ll:ename ll:elist ll:layer
ll:layerlist ll:totallength
ll:layerlength ll:arcdelta
ll:smileysurprised:bjlength ll:space)
(prompt "\nLayer Lengths by Jaysen D. Long\nCopyright \2511998-1999. All
Rights Reserved.")
(setq ll:layerlist nil)
(prompt ll:smileytongue:rompt)
(if (setq ll:ss (ssget '((0 .
"ARC,CIRCLE,ELLIPSE,LINE,*POLYLINE,REGION,SPLINE"))))
(progn
(repeat (setq i (sslength ll:ss))
(setq ll:elist (entget (ssname ll:ss (setq i (1- i)))))
(if (not (member (setq ll:layer (cdr (assoc 8 ll:elist)))
ll:layerlist))
(setq ll:layerlist (append ll:layerlist (list ll:layer)))
)
)
(setq ll:totallength 0.0)
(foreach x ll:layerlist
(setq ll:layerlength 0.0)
(command "._select" ll:ss "")
(setq ll:ss (ssget ll:sstype (list (cons 0
"ARC,CIRCLE,ELLIPSE,LINE,*POLYLINE,REGION,SPLINE") (cons 8 x))))
(repeat (setq i (sslength ll:ss))
(setq ll:ename (ssname ll:ss (setq i (1- i))))
(setq ll:elist (entget ll:ename))
(cond
( (eq (cdr (assoc 0 ll:elist)) "ARC")
(if (> (cdr (assoc 50 ll:elist)) (cdr (assoc 51 ll:elist)))
(setq ll:arcdelta (+ (abs (- (cdr (assoc 50 ll:elist)) (*
2.0 pi))) (cdr (assoc 51 ll:elist))))
(setq ll:arcdelta (- (cdr (assoc 51 ll:elist)) (cdr (assoc
50 ll:elist))))
)
(setq ll:smileysurprised:bjlength (* (cdr (assoc 40 ll:elist)) ll:arcdelta))
)
( (eq (cdr (assoc 0 ll:elist)) "LINE")
(setq ll:smileysurprised:bjlength (distance (cdr (assoc 10 ll:elist)) (cdr
(assoc 11 ll:elist))))
)
( (wcmatch (cdr (assoc 0 ll:elist))
"*POLYLINE,CIRCLE,ELLIPSE,REGION,SPLINE")
(command "._area" "_obj" ll:ename)
(setq ll:smileysurprised:bjlength (getvar "perimeter"))
)
)
(setq ll:layerlength (+ ll:layerlength ll:smileysurprised:bjlength))
)
(setq ll:space "" ll:smileytongue:rompt (strcat x ": " (rtos ll:layerlength 2 2)
" LF"))
(prompt (strcat "\n" x ": " (repeat (- 52 (strlen ll:smileytongue:rompt)) (setq
ll:space (strcat ll:space " "))) (rtos ll:layerlength 2 2) " LF"))
(setq ll:totallength (+ ll:totallength ll:layerlength))
)
(setq ll:space "" ll:smileytongue:rompt (strcat "Total: " (rtos ll:totallength 2
2) " LF"))
(prompt (strcat "\nTotal: " (repeat (- 52 (strlen ll:smileytongue:rompt)) (setq
ll:space (strcat ll:space " "))) (rtos ll:totallength 2 2) " LF"))
)
)
)


Jaysen


New Member
cwk1975
Posts: 2
Registered: ‎10-16-2003
Message 3 of 4 (805 Views)

Re: Lisp routine that will add up the lengths of all lines, arcs and polyline

10-16-2003 02:08 AM in reply to: *Adams, Steve
I did this one with the help of newsgroups, so, thanks everyone..
*Adams, Steve
Message 4 of 4 (805 Views)

Re:

10-16-2003 10:25 AM in reply to: *Adams, Steve
Thanks a lot! I appreciate it.

Steve


"Alex Repetto" wrote in message
news:C58F2DE457B9D03E14AB6C1537968A4D@in.WebX.maYIadrTaRb...
> Steve,
>
> Below the content of an earlier posting from Jaysen Long (Date:
21-09-1999,
> Subject: Total length of selected lines)
>
> Alex
>
>
> LL sums the length of all objects on selected layers.
> OBL sums the length of selected objects.
>
> Both print the output to the command line giving the lengths for different
> layers as well as a total.
>
>
> (defun c:ll ( / ) (ll:smileysurprised:utput "X" "\nSelect objects on layers to total...")
> (princ))
> (defun c:smileysurprised:bl ( / ) (ll:smileysurprised:utput "P" "\nSelect objects to total...") (princ))
>
>
> (defun ll:smileysurprised:utput (ll:sstype ll:smileytongue:rompt / ll:ss i ll:ename ll:elist ll:layer
> ll:layerlist ll:totallength
> ll:layerlength ll:arcdelta
> ll:smileysurprised:bjlength ll:space)
> (prompt "\nLayer Lengths by Jaysen D. Long\nCopyright \2511998-1999. All
> Rights Reserved.")
> (setq ll:layerlist nil)
> (prompt ll:smileytongue:rompt)
> (if (setq ll:ss (ssget '((0 .
> "ARC,CIRCLE,ELLIPSE,LINE,*POLYLINE,REGION,SPLINE"))))
> (progn
> (repeat (setq i (sslength ll:ss))
> (setq ll:elist (entget (ssname ll:ss (setq i (1- i)))))
> (if (not (member (setq ll:layer (cdr (assoc 8 ll:elist)))
> ll:layerlist))
> (setq ll:layerlist (append ll:layerlist (list ll:layer)))
> )
> )
> (setq ll:totallength 0.0)
> (foreach x ll:layerlist
> (setq ll:layerlength 0.0)
> (command "._select" ll:ss "")
> (setq ll:ss (ssget ll:sstype (list (cons 0
> "ARC,CIRCLE,ELLIPSE,LINE,*POLYLINE,REGION,SPLINE") (cons 8 x))))
> (repeat (setq i (sslength ll:ss))
> (setq ll:ename (ssname ll:ss (setq i (1- i))))
> (setq ll:elist (entget ll:ename))
> (cond
> ( (eq (cdr (assoc 0 ll:elist)) "ARC")
> (if (> (cdr (assoc 50 ll:elist)) (cdr (assoc 51 ll:elist)))
> (setq ll:arcdelta (+ (abs (- (cdr (assoc 50 ll:elist)) (*
> 2.0 pi))) (cdr (assoc 51 ll:elist))))
> (setq ll:arcdelta (- (cdr (assoc 51 ll:elist)) (cdr (assoc
> 50 ll:elist))))
> )
> (setq ll:smileysurprised:bjlength (* (cdr (assoc 40 ll:elist))
ll:arcdelta))
> )
> ( (eq (cdr (assoc 0 ll:elist)) "LINE")
> (setq ll:smileysurprised:bjlength (distance (cdr (assoc 10 ll:elist)) (cdr
> (assoc 11 ll:elist))))
> )
> ( (wcmatch (cdr (assoc 0 ll:elist))
> "*POLYLINE,CIRCLE,ELLIPSE,REGION,SPLINE")
> (command "._area" "_obj" ll:ename)
> (setq ll:smileysurprised:bjlength (getvar "perimeter"))
> )
> )
> (setq ll:layerlength (+ ll:layerlength ll:smileysurprised:bjlength))
> )
> (setq ll:space "" ll:smileytongue:rompt (strcat x ": " (rtos ll:layerlength 2
2)
> " LF"))
> (prompt (strcat "\n" x ": " (repeat (- 52 (strlen ll:smileytongue:rompt))
(setq
> ll:space (strcat ll:space " "))) (rtos ll:layerlength 2 2) " LF"))
> (setq ll:totallength (+ ll:totallength ll:layerlength))
> )
> (setq ll:space "" ll:smileytongue:rompt (strcat "Total: " (rtos ll:totallength 2
> 2) " LF"))
> (prompt (strcat "\nTotal: " (repeat (- 52 (strlen ll:smileytongue:rompt)) (setq
> ll:space (strcat ll:space " "))) (rtos ll:totallength 2 2) " LF"))
> )
> )
> )
>
>
> Jaysen
>
>
>

>
>
>
Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.