; Total area of closed polylines (c) Chris Hardwicke 1996

(DEFUN C:ADD ()
  (PROMPT "\n(c) Chris Hardwicke 1996")
  (PROMPT "\nSELECT AREAS TO ADD TOGETHER: ")
  (SETQ P_AREA 0)
  (SETQ SS (SSGET))
  ;(SETQ AREA_FILE (OPEN "AREAS.FIL" "a"))
  (WHILE (> (SSLENGTH SS) 0)
    (SETQ EN (SSNAME SS 0))
    (SETQ ED (ENTGET EN))
    (SETQ AS (CDR (ASSOC '0 ED)))
    (IF (AND (OR (= AS "POLYLINE") (= AS "LWPOLYLINE")) (= (CDR (ASSOC '70 ED)) 1))
      (PROGN
        (COMMAND "AREA" "O" EN)
        (SETQ P_AREA (+ P_AREA (GETVAR "AREA")))
        ;(WRITE-LINE (RTOS (GETVAR "AREA") 2 2) AREA_FILE)
        (SSDEL EN SS)
      )
      (SSDEL EN SS)
    )
  )
  ;(CLOSE AREA_FILE)
  (PROMPT (STRCAT "\nTOTAL AREA IS : " (RTOS P_AREA 2 2)))
  (setq txtPt (getpoint "\nInsertion point for total value: "))
  (command "._text" "middle" txtpt)
  (if (= 0.0 (cdr (assoc 40 (tblsearch "style" (getvar "textstyle")))))
           (command "" "" (RTOS P_AREA 2 2))
           (command "" (RTOS P_AREA 2 2))
        )

)
