Author Topic: Area Calculation Table  (Read 1827 times)

0 Members and 1 Guest are viewing this topic.

GDF

  • Water Moccasin
  • Posts: 2081
Area Calculation Table
« on: July 31, 2016, 02:10:34 PM »
I have found two hatch area label routines to use as examples:

;;http://www.theswamp.org/index.php?topic=35609.new
;;By Juan Villarreal

;;http://www.lee-mac.com/arealabel.html
;;AreaLabelV1-9.lsp
;;by LeeMac

My goal is to modify my code below to label the hatch areas in lieu of numbering them as per the codes above.
Here is what I am currently using below; where I have to do a lot of manual picking. I would like the automation process
of the the two examples above, in lieu of creating the Area Calculation Table.

Please refer to the Picture posted.

Code: [Select]
(defun SelectAreaObject (/ SFOBJ obj ObjLayerName ObjLayer)       
  (setq SFOBJ (entsel "\n* Select Object To Get Area of *"))
  (setq obj (entget (car SFOBJ)))
  (setq ObjLayer (cdr (assoc 8 Obj)))
  (if (> (strlen ObjLayer) 7)(setq ObjLayerName (substr ObjLayer 8 (- (strlen ObjLayer) 4))))
  (cond       
        ((= ObjLayerName "BRCK")(setq ARCH#NAM "Brick Masonry"))
        ((= ObjLayerName "CBRK")(setq ARCH#NAM "Cultured Brick"))
        ((= ObjLayerName "CSTN")(setq ARCH#NAM "Cultured Stone"))
        ((= ObjLayerName "STON")(setq ARCH#NAM "Stone Masonry"))
        ((= ObjLayerName "SIDE")(setq ARCH#NAM "Hardie Siding"))
        ((= ObjLayerName "PLAS")(setq ARCH#NAM "Cement Plaster"))
        ((= ObjLayerName "METL")(setq ARCH#NAM "Metal Siding"))

        ((= ObjLayerName "HEAT")(setq ARCH#NAM "Heated Living Area"))
        ((= ObjLayerName "GARG")(setq ARCH#NAM "Garage/ Stair"))
        ((= ObjLayerName "OLIV")(setq ARCH#NAM "Outdoor Living"))
        ((= ObjLayerName "PORC")(setq ARCH#NAM "Porch"))
        ((= ObjLayerName "STOR")(setq ARCH#NAM "Storage"))
        ((= ObjLayerName "COCH")(setq ARCH#NAM "Porte Cochere"))
        ((= ObjLayerName "")(setq ARCH#NAM "Area"))
  ) 
  (command "AREA" "o" SFOBJ) 
  (princ))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun ERROR-SSF ()
  (ARCH:MsgBox2
    " Arch Program : Error"
    16
    "
     Pick Error : SFF
---------------------------------------------------------------------------
     You did NOT Pick on the Table!     
     Pick Location for Text in [ Area Calculation Table ]

     Please try again...
  " 4
  )
)
;;;
(defun SFFit (/ apoint sqftx atext1 atext2)
  ;;(ARCH:F_S-VAR)   
  (setvar "osmode" 2)   
  (SelectAreaObject)
  (setq APOINT (osnap (getpoint "\n* Pick Location for Text in Area Calculation Table *") "Mid"))
  (while (= APOINT nil)
    (progn
      (ERROR-SSF) 
      (setq APOINT (osnap (getpoint "\n* Pick Location for Text in Table *") "Mid"))   
    )     
  )
  (setq SQFTX (/ (getvar "AREA") 144))
  (setq ATEXT1 (strcat "" (rtos SQFTX 2 (atoi ARCH#DECI)) " S.F.   "))
  (setq ATEXT2 (strcat "     " ARCH#NAM))
  ;;(ARCH:LYR "A-SYMB")
  ;;(ARCH:SET-ARIAL)
  (command "text" "j" "mr" APOINT ARCH#SC-A 0 ATEXT1)
  (setq SSET (ssadd (entlast) SSET))
  (command "text" "j" "ml" APOINT ARCH#SC-A 0 ATEXT2) 
  (setq SFOBJ nil apoint nil)
  ;;(ARCH:F_R-VAR)
  (princ))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun C:SFF ()
  (setq SSET (ssadd))   
  (SFFit)
  (while (= SFOBJ nil)(SFFit))   
  (princ))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun C:ASF (/ s1 lg index count c x a d atext3 atext4 totalarea apoint2)
  ;;(ARCH:F_S-VAR) 
  (setq APOINT2 (getpoint "\n* Pick Location for Text in Table *")) 
  (setq S1 SSET
        ;;S1 (ssget)
        LG    (sslength S1)
        INDEX 0
        COUNT 0
        C     0)
  (while (/= INDEX LG)
    (setq X (ssname S1 INDEX)
          A (entget X)
          D (cdr (assoc 0 A)))
    (if (= D "TEXT")
      (progn (setq B     (atof (cdr (assoc 1 A)))
                   C     (+ C B)
                   COUNT (1+ COUNT))))
    (setq INDEX (1+ INDEX)))
  (setq TOTALAREA (rtos C 2 (atoi ARCH#DECI))) 
  (setq ATEXT3 (strcat "" TOTALAREA " S.F.   "))
  (setq ATEXT4 (strcat "    " " Total Slab Area ")) 
  ;;(ARCH:LYR "A-SYMB")
  ;;(ARCH:SET-ARIAL)
  (command "text" "j" "mr" APOINT2 ARCH#SC-A 0 ATEXT3)
  (command "text" "j" "ml" APOINT2 ARCH#SC-A 0 ATEXT4) 
  (setq SSET nil)
  ;;(ARCH:F_R-VAR)
  (princ))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(princ)
« Last Edit: July 31, 2016, 02:13:36 PM by GDF »
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

GDF

  • Water Moccasin
  • Posts: 2081
Re: Area Calculation Table
« Reply #1 on: August 01, 2016, 06:54:48 PM »
I decided to go the attributed block route. This is more in my abilities.

Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

GDF

  • Water Moccasin
  • Posts: 2081
Re: Area Calculation Table
« Reply #2 on: August 02, 2016, 04:39:43 PM »
Well for what it's worth...here is my final results:

 :idea:
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

danallen

  • Guest
Re: Area Calculation Table
« Reply #3 on: August 02, 2016, 07:48:53 PM »
thanks for sharing, need to embark on site area diagram myself soon. Your lisp is missing some helper routines? for example ARCH:ATTUPDATE

Dan

GDF

  • Water Moccasin
  • Posts: 2081
Re: Area Calculation Table
« Reply #4 on: August 03, 2016, 10:03:21 AM »
;; EN   entity name of insert
;; TAG  attribute tag
;; NEW  new attribute value [string]
;;
;; Replaces current attribute value stored in
;; drawing with the NEW string value.
;;
(defun ARCH:ATTUPDATE  (EN TAG NEW / EL)
  (setq EN (entnext EN)
        ;;skip INSERT
        EL (entget EN)
           ;;get ATTRIB
        )
  ;; Search attribs for match of tag name
  (while (and (= (cdr (assoc 0 EL)) "ATTRIB") (/= (cdr (assoc 2 EL)) TAG))
    (setq EN (entnext EN)
          ;;next ATTRIB
          EL (entget EN)))
  (if (= (cdr (assoc 0 EL)) "ATTRIB")
    (progn (entmod ;;modify entity data
                   (subst ;;substitute in list
                          (cons 1 NEW)
                          ;;new data
                          (assoc 1 EL)
                          ;;old data
                          EL
                          ;;list
                          ))
           (entupd EN)
           ;;force regen of entity
           )))
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64