Author Topic: tcount for blocks?  (Read 3553 times)

0 Members and 1 Guest are viewing this topic.

Robb

  • Guest
tcount for blocks?
« on: December 08, 2006, 06:44:07 PM »
I have tons of door and window tags that need to be renumbered. If we make modifications to a room or area where doors/windows are affected then we need to renumber the whole plan. Is there a quick way to bump a specific attribute of a block with a certain block_name up/down one vaule or a user defined value so that door/window numbering will be less time consuming?

I use tcount for similar stuff like sheet numbering in a drawing index but tcount wont work on blocks. I was wondering if there is another command or if someone has written a lisp or VBA that they don't mind sharing.

Appreciate it.

Rob

dan19936

  • Guest
Re: tcount for blocks?
« Reply #1 on: December 08, 2006, 08:31:12 PM »

whdjr

  • Guest
Re: tcount for blocks?
« Reply #2 on: December 19, 2006, 11:15:51 AM »
This something I pieced together from a larger routine so it may have some "features" along with.

This was written for specific attribute tagstrings so you will need to change them for your blocks.  It will update multiple attributes with the same block.  It will error out if you select something that is not an attributed block.

Good Blockin'

Code: [Select]
(defun c:inc (/ ref tobj tstr ttag sel)
;;;
 (defun *dxf* (gcode elist)
  (cdr (assoc gcode elist))
 )
;;;
 (defun *get_atts* (obj)
  (vlax-invoke
   (if (eq (type obj) 'ENAME)
    (vlax-ename->vla-object obj)
    obj
   )
   'getattributes
  )
 )
;;;
 (defun find (attlist nlst)
  (vl-remove-if-not
   '(lambda (x)
     (vl-remove-if-not
      '(lambda (y)
(eq (vla-get-tagstring x) y)
       )
      nlst
     )
    )
   attlist
  )
 )
;;;
 (defun put (obj str lst)
  (mapcar '(lambda (x)
    (vl-catch-all-apply
     'vla-put-textstring
     (list (rt:remove obj x) str)
    )
   )
  lst
  )
 )
;;;
 (defun rt:remove (obj str)
  (car
   (vl-remove-if-not
    '(lambda (x)
      (eq (vla-get-tagstring x) str)
     )
    (*get_atts* obj)
   )
  )
 )
;;;
 (if (and (setq ref (car (entsel "\nSelect reference block:  ")))
  (eq "INSERT" (*dxf* 0 (entget ref)))
     )
  (progn
   (setq tobj (car
       (find (*get_atts* ref)
                     ;;;;Change these to your tagstrings.
     '("DOOR#" "999" "1" "101-1" "101-2" "DR360")
       )
      )
ttag (vla-get-tagstring tobj)
   )
   (if (eq "" (setq tstr (vla-get-textstring tobj)))
    (setq tstr "0")
   )
   (while tstr
    (setvar "ErrNo" 0)
    (if (not
(setq
  sel (car (entsel "\nSelect attribute to update:  "))
)
)
     (if (/= 52 (getvar "ErrNo"))
      (princ "\nNo object selected, please try again: ")
      (progn
       (princ "\nRight click detected - Terminate program. ")
       (setq tstr nil)
      )
     )
     ;;;Change these to your tagstrings
     (cond ((not (setq tstr (itoa (1+ (atoi tstr))))))
   ((eq ttag "1") (put sel tstr '("1")))
   ((eq ttag "DR360") (put sel tstr '("DR360")))
   ((eq ttag "DOOR#")
    (put sel tstr '("DOOR#" "240-DOOR#" "96-DOOR#"))
   )
   ((eq ttag "999") (put sel tstr '("999" "101")))
   ((eq ttag "101-1") (put sel tstr '("101-1" "101-2")))
     )
    )
   )
  )
  (*error* (princ "\nNothing selected.  *INVALID*"))
 )
)