Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Need a way to calc the sum of the areas of MANY closed polylines.

4 REPLIES 4
Reply
Message 1 of 5
lsaapedd
156 Views, 4 Replies

Need a way to calc the sum of the areas of MANY closed polylines.

As stated, I have a LOT of polylines in a drawing that I need the sum of the areas for. I don't care how it is displayed, I just need the number so I can put it elsewhere and use it.

I know nothing at all about programming in Acad. If someone has a lisp or other program, I would be grateful for it.

TIA,

Jerry
4 REPLIES 4
Message 2 of 5
Anonymous
in reply to: lsaapedd

lsaapedd wrote:
> As stated, I have a LOT of polylines in a drawing that I need the sum of the areas for. I don't care how it is displayed, I just need the number so I can put it elsewhere and use it.
>
> I know nothing at all about programming in Acad. If someone has a lisp or other program, I would be grateful for it.
>
> TIA,
>
> Jerry

this may help you
Dave
DDP

; AREAS.LSP
; Michael Weaver Fri 08-06-1993 Compuserv #71461,1775

;This routine will write the area and perimeter of selected closed
; polylines to an ascii file. This file will have an area, a user
; input comment and a perimter on each line. The file is tab
; delimited.

(defun c:areas(; write area and perimeter of selected
; plines out to a file
/; no formal arguments
)
(if (and
(setq fname (getfiled "Output filename" "" "txt" 1))
(setq fileh (open fname "w"))
)
(progn
(write-line "Area\tPerimeter" fileh)
(setq cmdecho (getvar "cmdecho"))
(setvar "cmdecho" 0)
(while (setq ent (entsel "\nSelect a closed polyline. "))
(redraw (car ent) 3)
(setq elist (entget (car ent)))
(cond
((= "POLYLINE" (cdr (assoc 0 elist)))
(if (= 1 (logand (cdr (assoc 70 elist)) 1))
(progn
(command "area" "e" ent)
(setq
area (getvar "area")
perimeter (getvar "perimeter")
)
(if (= 4 (getvar "lunits"))
(setq
area (/ area 144.0)
perimeter (/ perimeter 12.0)
)
)
(write-line
(strcat
(rtos area 2 4)
"\t"
(rtos perimeter 2 4)
); strcat
fileh
); write-line
); progn
(princ "\nSelected pline is not closed. ")
); end if
); end polyline
(T (princ "\nSelected entity is not a pline. "))
); end cond
); end while
(setq fileh (close fileh))
(setvar "cmdecho" cmdecho)
); end progn if filename and handle aquired
); end if
(princ)
)

(progn
(princ "\nC:AREAS by Michael Weaver Compuserv #71461,1775")
(princ)
)
Message 3 of 5
Anonymous
in reply to: lsaapedd

because i am in a good mood today, hope it works
just copy the atteched file in one of your search paths of acad
(load "sumarea.lsp")
and than start it with
sumarea
If you want to change the displayed accuracy of the area, just change
the (setq GEN 2) line to the desired digits of your area



(defun c:sumarea (/ GEN SS GIDX GSUMAREA GELEMENT CMDOLD)
(setq CMDOLD (getvar "CMDECHO"))
(setvar "CMDECHO" 0)
(prompt "\n Calc the sum of all closed Polylines and lw polylines")
(setq GEN 2)
(setq GFILTER '((-4 . " "LWPOLYLINE") (-4 . "OR>") (70 . 1) (-4 . "AND>")))
(setq SS (ssget "_X" GFILTER))
(if SS
(progn
(prompt (strcat "\n Found " (itoa (sslength SS)) " closed
Polylines, LWPolylines."))
(setq GIDX 0)
(setq GSUMAREA 0)
(repeat (sslength SS)
(setq GELEMENT (ssname SS GIDX))
(setq GIDX (1+ GIDX))
(command "_area" "_o" GELEMENT)
(prompt (strcat "\n Area (" (itoa GIDX) "):" (rtos (getvar
"AREA") 2 GEN)))
(setq GSUMAREA (+ GSUMAREA (getvar "AREA")))
)
(prompt "\n ----------------------")
(prompt (strcat "\n Sum-Area:" (rtos GSUMAREA 2 GEN)))
)
(prompt "\n No closed Polylines or LWPolylines found.")
)
(setvar "CMDECHO" CMDOLD)
(princ)
)

lsaapedd wrote:
> As stated, I have a LOT of polylines in a drawing that I need the sum of the areas for. I don't care how it is displayed, I just need the number so I can put it elsewhere and use it.
>
> I know nothing at all about programming in Acad. If someone has a lisp or other program, I would be grateful for it.
>
> TIA,
>
> Jerry
Message 4 of 5
lsaapedd
in reply to: lsaapedd

Thank you.

Jerry
Message 5 of 5
lsaapedd
in reply to: lsaapedd

Thank you. This looks like what I need.

Jerry

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost