This is a routine that will insert an attributed block into a space, then asks the user the bldg and floor number then asks the user to select the lwpolyline
for this space (to get the area) then ask what spid number to start with and then update the attributed block with all of the information, then
continue to the next space repeating until user cancels or finish's.
I want this to ask the user only 1 time within a session for the building/floor number so that it is nor repeated each time.
This is suppose to automatically select the last block inserted to update the information. Right now it does not.
Also, the Autoupdate of the attributers to the block is not working correctly as well.
I also want this routine to keep repeating until the user cancels for finishes.
Can you guys test this out and fill me in on how to accomplish this?
(defun c:AreaTag ( / )
(command "style" "standard" "simplex.shx" "6" "" "" "" "" "")
(do-work1)
(mkspid-lyr)
(get-spid)
(UpdateAtts)
(command ".layer" "s" "0" "")
)
(defun do-work1 ()
(vl-load-com)
(mkblk-lyr)
(setq BldgNum (strcase (getstring T"\nType in Building Number \n" )))
(setq FloorNum (getstring T"\nType in Floor Number \n" ))
(setq grablock (ssadd))
(setq curPoint (getpoint "\npick label insertion point: "))
(command "-insert" "space" curpoint "" "" "")
(ssadd (entlast) grablock)
(while
(setq curEnt (car (entsel "\nPlease select polyline: ")))
(setq curObj (vlax-ename->vla-object curEnt)
curArea (vla-get-area curObj))
; (alert "Requires selection of Polyline!")
)
(setq rar (strcat (rtos (/ (vla-get-area curObj) 144) 2 2 ) " Sq. Ft. "))
;(do-work1)
)
(defun get-spid () ;(/ minlen startc pt txtht)
(setvar "cmdecho" 0)
(or start (setq start "01"))
(setq startc "")
(while (not (numberp (distof startc)))
(setq startc (getstring (strcat "\nStarting number <" start ">: ")))
(and (= startc "") (setq startc start))
)
(setq minlen (strlen startc))
(setq pt curPoint)
(command ".text" "M" pt "" startc)
(setq startc (itoa (1+ (atoi startc))))
(while (< (strlen startc) minlen) ; prepend zeros
(setq startc (strcat "0" startc))
)
(setq start startc)
(princ)
)
(defun mkblk-lyr ()
(setq lay1 (tblsearch "layer" "A-AREA-IDEN"))
(if (= lay1 nil)
(entmake (list
'(0 . "LAYER")
'(100 . "AcDbSymbolTableRecord")
'(100 . "AcDbLayerTableRecord")
'(2 . "A-AREA-IDEN")
'(6 . "CONTINUOUS")
'(62 . 7)
'(70 . 0)
)
);end entmake
);end if
(command ".layer" "s" "A-AREA-IDEN" "")
)
(defun mkspid-lyr ()
(setq lay2 (tblsearch "layer" "3"))
(if (= lay2 nil)
(entmake (list
'(0 . "LAYER")
'(100 . "AcDbSymbolTableRecord")
'(100 . "AcDbLayerTableRecord")
'(2 . "3")
'(6 . "CONTINUOUS")
'(62 . 7)
'(70 . 0)
)
);end entmake
);end if
(command ".layer" "s" "3" "")
)
(defun UpdateAtts ()
(cond ((setq sset (ssget '((2 . "SPACE") (66 . 1))))
(setq a 0)
(repeat (sslength sset)
(setq ent (ssname sset a)
a (1+ a)
)
(changeAtt ent "AREA" rar) ;<- Area SF
(changeAtt ent "SPID" startc) ;<- Spid #
(changeAtt ent "BLDGID" BldgNum) ;<- Bldg #
(changeAtt ent "FLRID" FloorNum) ;<- Floor #
)
)
)
(princ)
)
(defun changeAtt (ent tag val / entl ins)
(setq ins ent)
(while (and ent
(/= "SEQEND" (cdr (assoc 0 (setq entl (entget ent))))))
(if (and (= (cdr (assoc 0 entl)) "ATTRIB")
(= (cdr (assoc 2 entl)) tag))
(entmod (subst (cons 1 val) (assoc 1 entl) entl)))
(setq ent (entnext ent)))
(entupd ins)
)