;GetAcre.lsp - Get the area of a selected polyline entity.
;Warning....This will also return an area for an entity that is not enclosed.
;By: Jeffery P Sanders 11/11/02 jps@jefferypsanders.com
(defun C:GA()
;turn the system echo off
(setvar "cmdecho" 0)
;set up the exit message
(setq ernote "\n ...GA.lsp Complete. ")
;set up a variable to hold the area
(setq myArea 0)
;select one object
(setq ent(entsel))
;if an object was selected and not some point in space
(if (car ent)
(progn
;get AutoCAD to find the area of the polyline...cheap yet effective way out
;Note: AutoCAD stores the information in the system variable "Area"
(command "area" "Object" (car ent))
;get the area from the system variable "Area" and convert from
;square inches to square feet
(setq myarea (/(getvar "Area")144.0))
;print the sq feet to the command line
(princ "\n Total Square Feet : ")(princ (rtos myArea))
;print the acreage to the command line after converting
(princ "\n Total Acreage : ")(princ (rtos (/ myArea 43560.0)))
;ask the user for an insertion point for the text
;if the user presses enter then by pass the insertion procedure
(if(setq pt1(getpoint "\n Insertion Point: "))
(progn
;print the sq feet on the drawing
(command "text" pt1 "" "" (strcat "Total Square Feet : " (rtos myArea)))
;move the text starting point down and print the acreage on the drawing
(command "text"
(polar pt1 (* pi 1.5) (* 1.5 (getvar "textsize")))
"" "" (strcat "Total Acreage : " (rtos (/ myArea 43560.0)))
)
) ;close the if progn for point selection
) ;close the if
) ;close the if progn for object selection
;if nothing was selected then change the exit note to be unsuccessful
(setq ernote "\n Error - Nothing Selected.")
) ;close the if statement
;print the exit note to the command line
(princ ernote)
;reset the system echo variable
(setvar "cmdecho" 1)
;supress the last echo
(princ)
)