CompuServe Messages

area command

#: 21582 S2/AutoLISPForum unknown
    06-Apr-88 14:31:05
Sb: #21562-area command
Fm: Training [ADESK] 73417,2235
To: Emmanuel Paul 72117,177

This message turned up in search, but its forum couldn’t be identified from the original transcript, so it may not be linked into its thread.

Emmanuel — Try this. It doesn't write to a file, but you should be able to modify the code to do so. ; AutoCAD Command function P-AREA for Version 2.6 and Release 9 ; Returns total area of all POLYLINES on a user-specified LAYER. ; Does NOT trap for invalid layer name, nor for empty selection set. ; No claims are made as to the validity of the data ; which this function returns. (defun C:P-AREA (/ LNAME SSET1 INDEX ENAME) ;local variable list (setvar "cmdecho" 0) ;turn off "Comand:" prompt echo (setq LNAME (getstring "\nLayer name: ")) ;prompt for layer name (setq SSET1 ;make selection set SSET1 (ssget "x" (list ;make filter list (cons 8 LNAME) ;entity must be on layer LNAME (cons 0 "POLYLINE") ;and must be a POLYLINE ) ) ) (setq INDEX 0) ;initialize INDEX to zero (setq ENAME (ssname SSET1 INDEX)) ;get first entity from SSET1 (command "AREA" "a" "e") ;start AREA command and Add Entities (while ENAME ;if there's another entity… (command ENAME) ;add it to total area (setq INDEX (1+ INDEX)) (setq ENAME (ssname SSET1 INDEX)) ;get next entity from SSET1 ) (command "" "") ;normal end to AREA command (princ ;print to screen… (strcat ;concatenate the following strings… "\nTotal area all POLYLINES on Layer " (strcase LNAME) ;convert LNAME to caps " : " (rtos (getvar "AREA")) ;convert last AREA from real to string ) ) (princ) ;suppress nil normally returned by defun )