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.
(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)