Hi All,
Does anyone have a routine where I could keep picking on my exit arrow blocks (showing how many persons exiting from each space) one-by-one and the program would add up the numbers. For example I pick on blocks with numbers of 2, 4 & 3 and I would get 9.
Thank you,
GS
@Anonymous wrote:....
Does anyone have a routine where I could keep picking on my exit arrow blocks (showing how many persons exiting from each space) one-by-one and the program would add up the numbers. For example I pick on blocks with numbers of 2, 4 & 3 and I would get 9.
....
I don't, but maybe something like this:
has something already at least close to what you want, with some things you could forgo [writing out to a file, for instance]. You may find something even closer if you do some Searching -- that's just one close to the top of the list when I put "total attributes" into the Search window.
Try this one from my storage, change attribute tags
within the code
(defun C:sumat (/ acsp adoc blk blkname blkobj blkset en objlst summ) (vl-load-com) (setq adoc (vla-get-activedocument (vlax-get-acad-object)) acsp (vla-get-block (vla-get-activelayout adoc))) (vla-startundomark adoc) (setq blkname (getstring T "\Enter the block name (case-sensitive): ")) (princ "\nSelect blocks one by one:") (while (setq en (entsel)) (setq blkobj (vlax-ename->vla-object (car en))) (if (and (eq blkname (vla-get-effectivename blkobj)) (eq :vlax-true(vla-get-hasattributes blkobj))) (setq objlst (cons blkobj objlst))) ) (setq summ 0) (foreach blkobj objlst (foreach at (vlax-invoke blkobj 'getattributes) (if (eq (strcase (vla-get-tagstring at)) "KP");<-- source attribute tag (setq summ (+ summ (atof (vla-get-textstring at)))) ) ) ) (princ "\nSelect a single block to write sum:") (setq blkset (ssget ":S" (list (cons 0 "insert")(cons 66 1)))) (setq blk (vlax-ename->vla-object (ssname blkset 0))) (foreach at (vlax-invoke blk 'getattributes) (if (eq (strcase (vla-get-tagstring at)) "KP");<-- resulting attribute tag, may be another then source tag (vla-put-textstring at (rtos summ 2 0)))) (vla-regen adoc acActiveViewport) (vla-endundomark adoc) (princ) ) (princ "\n\t\t---\tStart with command SUMAT... \t---") (prin1) (or (vl-load-com) (princ))
~'J'~