@scotth066 wrote:
@pbejse Thanks for the reply.
I am wanting to prompt the user to "/n Select a RMNAME block", have it store the value of the "room#" ...
Here are two options:
1. Select the Rmname block and select the doors [ single/multiple selection ] as per first post.
(defun c:TaggerS ( / _some *spc suf roomtag RoomNum Doors drs mid dtag chn )
(defun _some (tag e)
(vl-some '(lambda (at)
(if (eq tag (vla-get-tagstring at))
(list (Vla-get-textstring at) at)))
(vlax-invoke e 'GetAttributes))
)
(setq *spc (vlax-get(vla-get-ActiveLayout
(vla-get-activedocument
(vlax-get-acad-object))) 'Block))
(and
(tblsearch "BLOCK" "DOOR_TAG")
(while
(and
(setq suf "" roomtag
(ssget "_+.:S:E" '((0 . "INSERT") (66 . 1) (2 . "`*U*,RMNAME"))))
(eq "RMNAME" (strcase (vla-get-effectivename
(setq de (vlax-ename->vla-object (ssname roomtag 0))))))
(setq RoomNum (car (_some "ROOM#" de)))
(princ "\nSelect Doors to tag:")
(setq Doors (ssget '((0 . "INSERT") (2 . "`*U*,DOOR"))))
)
(repeat (sslength doors)
(setq drs (vlax-ename->vla-object (ssname doors 0)))
(and
(eq "DOOR" (strcase (vla-get-EffectiveName drs)))
(not (vla-getboundingbox drs 'll 'ur))
(setq mid (mapcar (function (lambda (a b) (/ (+ a b) 2)))
(vlax-safearray->list ll)(vlax-safearray->list ur)))
(setq dtag (vlax-invoke *spc 'InsertBlock mid "DOOR_TAG" 1 1 1 0))
(setq dtag (Cadr (_some "DOORNUM" dtag)))
(not (vla-put-textstring dtag (strcat RoomNum suf)))
(setq chn (if (eq "" suf) 97 (1+ chn)))
(setq suf (chr chn))
)
(ssdel (ssname doors 0) doors)
)
)
)
(princ)
)
2. Select the Rmname block then proceed to insert the Door_tag on each pickpoint, as you requested
(defun c:Tagger ( / _some *spc suf roomtag RoomNum Doors drs mid dtag chn )
(defun _some (tag e)
(vl-some '(lambda (at)
(if (eq tag (vla-get-tagstring at))
(list (Vla-get-textstring at) at)))
(vlax-invoke e 'GetAttributes))
)
(setq *spc (vlax-get(vla-get-ActiveLayout
(vla-get-activedocument
(vlax-get-acad-object))) 'Block))
(if
(and
(tblsearch "BLOCK" "DOOR_TAG")
(setq suf "" roomtag
(ssget "_+.:S:E" '((0 . "INSERT") (66 . 1) (2 . "`*U*,RMNAME"))))
(eq "RMNAME" (strcase (vla-get-effectivename
(setq de (vlax-ename->vla-object (ssname roomtag 0))))))
(setq RoomNum (car (_some "ROOM#" de)))
(setq fp (vlax-get de 'Insertionpoint))
)
(while (setq pt (getpoint fp "\nPick point for Door tag"))
(setq dtag (vlax-invoke *spc 'InsertBlock pt "DOOR_TAG" 1 1 1 0))
(setq dtag (Cadr (_some "DOORNUM" dtag)))
(not (vla-put-textstring dtag (strcat RoomNum suf)))
(setq chn (if (eq "" suf) 97 (1+ chn)))
(setq suf (chr chn))
)
)
(princ)
)
HTH