Jump to content

Changing All Block Attribute values together like a normal block


Hsanon

Recommended Posts

Hi, In our architectural drawings, we mark out Doors and windows using a single block, where we feed in the Block tag, and Size depending on the location on the plan. 

For example, we insert the block "Doortag", and feed in the attributes of Door Tag, and Size. We would have several instances of inserting this same block with different tags and sizes.

IN a normal block, we would change one block, and all similar blocks would change, however, with attributes, all similar blocks with similar tags and sizes do not change. we would need to identify all similar blocks manually and use a lisp routine to change the tags and sizes. 

Is there a way of picking one such item (all are similar blocks unfortunately), change the tag and / or size, and all the similar blocks would get changed ????

Also, as another request, could we make a table to tabulate the blocks, tags, sizes, and numbers.????

 

I'm attaching a simple drawing to illustrate the issue.

Thanks & Regards

 

 

blocktag example.dwg

Link to comment
Share on other sites

When you say "mark" what does that mean. if its a text with the relevant information. should be easy  enough to

  • make a selection set of the door tab block
  • make a selection set of the text call outs
  • process the door tags and pull information from the closest text call out. maybe add a fuzz distance so if text is outside a given distance nothing is applied.

using this logic

 

Link to comment
Share on other sites

Part 2 "Also, as another request, could we make a table to tabulate the blocks, tags, sizes, and numbers.????"

 

Out of the box has small cost think Cup of coffee.

 

image.png.2913e01892667875f5ac9b9ae652e315.png

Link to comment
Share on other sites

Hi guys... Thanks for the response 

Mhupp : im gonna try this logic out in autolisp, as im a big zero in vlisp  (age / experience factor probably) will ask for help when i get stuck

Marko_ribar :  This does not work as it doesn't list and sort out the attributes in the block in the table 

BigAl : Ready for a coffee whenever you are... 😊😊

 

Thanks guys !!!

Link to comment
Share on other sites

Posted (edited)

OP, I don't know how to implement blocks previews, but for BIGAL's suggestion here is my version that does the same thing without previews...

 

(defun c:count-table-doortag ( / lst2table groupbynum assoc++ blk+tagname+tagval ss idx tmp xrf fil lst pt )

  (or (not (vl-catch-all-error-p (vl-catch-all-apply (function vlax-get-acad-object) nil))) (vl-load-com))

  (defun lst2table ( lst pt / as cols rh cw ttl data rows sty tbl r k )
    (setq rh
      (vla-gettextheight
        (setq sty
          (vla-item
            (vla-item (vla-get-dictionaries (vla-get-activedocument (vlax-get-acad-object))) "acad_tablestyle")
            (getvar (quote ctablestyle))
          )
        )
        acdatarow
      )
    )
    (setq pt (vlax-3d-point (trans pt 1 0)))
    (setq as (vla-get-block (vla-get-activelayout (vla-get-activedocument (vlax-get-acad-object)))))
    (setq cols (if (listp (caadr lst)) (length (caadr lst)) (length (car lst))))
    (setq ttl (if (not (listp (car lst))) (car lst)))
    (setq data (if (not (listp (car lst))) (cadr lst) lst))
    (setq data (mapcar (function (lambda ( x ) (mapcar (function (lambda ( y ) (if (null y) "" y))) x))) data))
    (setq rows (if (not (listp (car lst))) (1+ (length data)) (length data)))
    (if ttl
      (vla-enablemergeall sty "Title" :vlax-true)
      (vla-enablemergeall sty "Title" :vlax-false)
    )
    (setq cw (apply (function max) (mapcar (function (lambda ( x ) (strlen x))) (list "Preview" "Block Name" "DTYPE" "DSIZE" "Count"))))
    (setq tbl (vla-addtable as pt rows cols (* 2.5 rh) (* 0.8 cw)))
    (if (vlax-property-available-p tbl 'regeneratetablesuppressed t)
      (vla-put-regeneratetablesuppressed tbl :vlax-true)
    )
    (vla-put-stylename tbl (getvar (quote ctablestyle)))
    (if ttl
      (progn
        (vla-settext tbl 0 0 ttl)
        (setq r 1)
      )
      (setq r 0)
    )
    (foreach i data
      (setq k -1)
      (foreach ii i
        (vla-settext tbl r (setq k (1+ k)) ii)
        (cond
          ( (and ttl (> r 1))
            (vla-setcellalignment tbl r k acmiddleleft)
          )
          ( (and (not ttl) (= r 0))
            nil
          )
          ( t
            (vla-setcellalignment tbl r k acmiddleleft)
          )
        )
      )
      (setq r (1+ r))
    )
    (setq cw (apply (function max) (mapcar (function (lambda ( x ) (strlen x))) (list "Preview" "Block Name" "DTYPE" "DSIZE" "Count"))))
    (setq k -1)
    (repeat cols
      (vla-setcolumnwidth tbl (setq k (1+ k)) (* cw rh))
    )
    (if (vlax-property-available-p tbl (quote regeneratetablesuppressed) t)
      (vla-put-regeneratetablesuppressed tbl :vlax-false)
    )
    (if (vlax-method-applicable-p tbl (quote scaleentity))
      (vla-scaleentity tbl pt 50.0)
    )
    (vla-update tbl)
    (princ)
  )

  (defun groupbynum ( lst n / sub lll )

    (defun sub ( m n / ll q )
      (cond
        ( (and m (< (length m) n))
          (repeat (- n (length m))
            (setq m (append m (list nil)))
          )
          (setq ll (vl-remove-if-not (function (lambda ( x ) (setq q (if (not q) 0 (1+ q))) (< q n))) m))
          (setq lll (cons ll lll))
          (setq q nil)
          (sub (vl-remove-if (function (lambda ( x ) (setq q (if (not q) 0 (1+ q))) (< q n))) m) n)
        )
        ( m
          (setq ll (vl-remove-if-not (function (lambda ( x ) (setq q (if (not q) 0 (1+ q))) (< q n))) m))
          (setq lll (cons ll lll))
          (setq q nil)
          (sub (vl-remove-if (function (lambda ( x ) (setq q (if (not q) 0 (1+ q))) (< q n))) m) n)
        )
        ( t
          (reverse lll)
        )
      )
    )

    (sub lst n)
  )

  (defun assoc++ ( key lst / itm )
    (if (setq itm (assoc key lst))
      (subst (cons key (1+ (cdr itm))) itm lst)
      (cons  (cons key 1) lst)
    )
  )

  (defun blk+tagname+tagval ( ent / blk enx lst )
    (setq blk (cdr (assoc 2 (entget ent))))
    (while (= (cdr (assoc 0 (setq enx (entget (setq ent (entnext ent)))))) "ATTRIB")
      (setq lst (cons (list (cdr (assoc 2 enx)) (cdr (assoc 1 enx))) lst))
    )
    (cons blk lst)
  )

  (while (setq tmp (tblnext "block" (null tmp)))
    (if (= 4 (logand 4 (cdr (assoc 70 tmp))))
      (setq xrf (vl-list* "," (cdr (assoc 2 tmp)) xrf))
    )
  )
  (if xrf
    (setq fil (list (cons 0 "INSERT") (cons -4 "<NOT") (cons 2 (apply (function strcat) (cdr xrf))) (cons -4 "NOT>") (cons 66 1)))
    (setq fil (list (cons 0 "INSERT") (cons 66 1)))
  )
  (prompt "\nSelect attributed blocks <all>...")
  (if (not (setq ss (ssget fil)))
    (setq ss (ssget "_A" fil))
  )
  (repeat (setq idx (sslength ss))
    (setq lst (assoc++ (blk+tagname+tagval (ssname ss (setq idx (1- idx)))) lst))
  )
  (setq lst (vl-sort lst (function (lambda ( a b ) (> (cdr a) (cdr b))))))
  (setq lst (groupbynum (apply (function append) (mapcar (function (lambda ( x ) (cons "" (list (caar x) (cadr (cadar x)) (cadr (caddar x)) (itoa (cdr x)))))) lst)) 5))
  (initget 1)
  (setq pt (getpoint "\nPick or specify point for table : "))
  (lst2table (list "LEGEND" (append (list (list "Preview" "Block Name" "DTYPE" "DSIZE" "Count")) lst)) pt)
  (princ)
)

 

I hope that this helps, if you don't care for previews...

M.R.

count-table-doortag.png

Edited by marko_ribar
  • Like 1
Link to comment
Share on other sites

54 minutes ago, marko_ribar said:

OP, I don't know how to implement blocks previews

 

 

;; get the block table (block definitions collection)
(setq blockTable (vla-get-Blocks (vla-get-ActiveDocument (vlax-get-acad-object))))

;; get a block by name
;; (throws an error if the the block table does not contain a block names as blockName)
(setq block (vla-Item blockTable blockName))

;; get the block ObjectId
(setq blockId (vla-get-ObjectId block))

;in the table
(vla-SetBlockTableRecordId table row colum blockId :vlax-true)

 

  • Like 1
Link to comment
Share on other sites

Posted (edited)

Now there is preview, but it can detect only single block+attributes combination... Look at picture...

 

(defun c:count-table-doortag ( / lst2table groupbynum assoc++ blk+tagname+tagval setblocktablerecord objectid effectivename ss idx tmp xrf fil lst pt )

  (or (not (vl-catch-all-error-p (vl-catch-all-apply (function vlax-get-acad-object) nil))) (vl-load-com))

  (defun lst2table ( lst pt / block blockid as cols rh cw ttl data rows sty tbl r k )
    (setq rh
      (vla-gettextheight
        (setq sty
          (vla-item
            (vla-item (vla-get-dictionaries (vla-get-activedocument (vlax-get-acad-object))) "acad_tablestyle")
            (getvar (quote ctablestyle))
          )
        )
        acdatarow
      )
    )
    (setq pt (vlax-3d-point (trans pt 1 0)))
    (setq cols (if (listp (caadr lst)) (length (caadr lst)) (length (car lst))))
    (setq ttl (if (not (listp (car lst))) (car lst)))
    (setq data (if (not (listp (car lst))) (cadr lst) lst))
    (setq data (mapcar (function (lambda ( x ) (mapcar (function (lambda ( y ) (if (null y) "" y))) x))) data))
    (setq rows (if (not (listp (car lst))) (1+ (length data)) (length data)))
    (if ttl
      (vla-enablemergeall sty "Title" :vlax-true)
      (vla-enablemergeall sty "Title" :vlax-false)
    )
    (setq cw (apply (function max) (mapcar (function (lambda ( x ) (strlen x))) (list "Preview" "Block Name" "DTYPE" "DSIZE" "Count"))))
    (setq tbl (vla-addtable spc pt rows cols (* 2.5 rh) (* 0.8 cw)))
    (if (vlax-property-available-p tbl 'regeneratetablesuppressed t)
      (vla-put-regeneratetablesuppressed tbl :vlax-true)
    )
    (vla-put-stylename tbl (getvar (quote ctablestyle)))
    (if ttl
      (progn
        (vla-settext tbl 0 0 ttl)
        (setq r 1)
      )
      (setq r 0)
    )
    (foreach i data
      (setq k -1)
      (foreach ii i
        (vla-settext tbl r (setq k (1+ k)) ii)
        (if (and (> r 1) (= k 1))
          (setblocktablerecord tbl r 0 ii)
        )
        (cond
          ( (and ttl (> r 1))
            (vla-setcellalignment tbl r k acmiddleleft)
          )
          ( (and (not ttl) (= r 0))
            nil
          )
          ( t
            (vla-setcellalignment tbl r k acmiddleleft)
          )
        )
      )
      (setq r (1+ r))
    )
    (setq cw (apply (function max) (mapcar (function (lambda ( x ) (strlen x))) (list "Preview" "Block Name" "DTYPE" "DSIZE" "Count"))))
    (setq k -1)
    (repeat cols
      (vla-setcolumnwidth tbl (setq k (1+ k)) (* cw rh))
    )
    (if (vlax-property-available-p tbl (quote regeneratetablesuppressed) t)
      (vla-put-regeneratetablesuppressed tbl :vlax-false)
    )
    (if (vlax-method-applicable-p tbl (quote scaleentity))
      (vla-scaleentity tbl pt 50.0)
    )
    (vla-update tbl)
    (princ)
  )

  (defun groupbynum ( lst n / sub lll )

    (defun sub ( m n / ll q )
      (cond
        ( (and m (< (length m) n))
          (repeat (- n (length m))
            (setq m (append m (list nil)))
          )
          (setq ll (vl-remove-if-not (function (lambda ( x ) (setq q (if (not q) 0 (1+ q))) (< q n))) m))
          (setq lll (cons ll lll))
          (setq q nil)
          (sub (vl-remove-if (function (lambda ( x ) (setq q (if (not q) 0 (1+ q))) (< q n))) m) n)
        )
        ( m
          (setq ll (vl-remove-if-not (function (lambda ( x ) (setq q (if (not q) 0 (1+ q))) (< q n))) m))
          (setq lll (cons ll lll))
          (setq q nil)
          (sub (vl-remove-if (function (lambda ( x ) (setq q (if (not q) 0 (1+ q))) (< q n))) m) n)
        )
        ( t
          (reverse lll)
        )
      )
    )

    (sub lst n)
  )

  (defun assoc++ ( key lst / itm )
    (if (setq itm (assoc key lst))
      (subst (cons key (1+ (cdr itm))) itm lst)
      (cons  (cons key 1) lst)
    )
  )

  (defun blk+tagname+tagval ( ent / blk enx lst )
    (setq blk (effectivename ent))
    (while (= (cdr (assoc 0 (setq enx (entget (setq ent (entnext ent)))))) "ATTRIB")
      (setq lst (cons (list (cdr (assoc 2 enx)) (cdr (assoc 1 enx))) lst))
    )
    (cons blk lst)
  )

  (defun setblocktablerecord ( obj row col bli )
    (eval
      (list 'defun 'setblocktablerecord '( obj row col bli )
        (cons
          (if (vlax-method-applicable-p obj 'setblocktablerecordid32)
            'vla-setblocktablerecordid32
            'vla-setblocktablerecordid
          )
          (list
            'obj 'row 'col
            (list 'objectid (list 'vla-item blk 'bli))
            ':vlax-true
          )
        )
      )
    )
    (setblocktablerecord obj row col bli)
  )

  (defun objectid ( obj )
    (eval
      (list 'defun 'objectid '( obj )
        (cond
          ( (not (wcmatch (getenv "PROCESSOR_ARCHITECTURE") "*64*"))
           '(vla-get-objectid obj)
          )
          ( (= 'subr (type vla-get-objectid32))
           '(vla-get-objectid32 obj)
          )
          ( (list 'vla-getobjectidstring (vla-get-utility doc) 'obj ':vlax-false) )
        )
      )
    )
    (objectid obj)
  )

  (defun effectivename ( ent / blk rep )
    (if (wcmatch (setq blk (cdr (assoc 2 (entget ent)))) "`**")
      (if
        (and
          (setq rep
            (cdadr
              (assoc -3
                (entget
                  (cdr
                    (assoc 330
                      (entget
                          (tblobjname "block" blk)
                      )
                    )
                  )
                 '("AcDbBlockRepBTag")
                )
              )
            )
          )
          (setq rep (handent (cdr (assoc 1005 rep))))
        )
        (setq blk (cdr (assoc 2 (entget rep))))
      )
    )
    blk
  )

  (or cad (setq cad (vlax-get-acad-object)))
  (or doc (setq doc (vla-get-activedocument cad)))
  (or alo (setq alo (vla-get-activelayout doc)))
  (or spc (setq spc (vla-get-block alo)))
  (or blk (setq blk (vla-get-blocks doc)))
  (while (setq tmp (tblnext "block" (null tmp)))
    (if (= 4 (logand 4 (cdr (assoc 70 tmp))))
      (setq xrf (vl-list* "," (cdr (assoc 2 tmp)) xrf))
    )
  )
  (if xrf
    (setq fil (list (cons 0 "INSERT") (cons -4 "<NOT") (cons 2 (apply (function strcat) (cdr xrf))) (cons -4 "NOT>") (cons 66 1)))
    (setq fil (list (cons 0 "INSERT") (cons 66 1)))
  )
  (prompt "\nSelect attributed blocks <all>...")
  (if (not (setq ss (ssget fil)))
    (setq ss (ssget "_A" fil))
  )
  (repeat (setq idx (sslength ss))
    (setq lst (assoc++ (blk+tagname+tagval (ssname ss (setq idx (1- idx)))) lst))
  )
  (setq lst (vl-sort lst (function (lambda ( a b ) (> (cdr a) (cdr b))))))
  (setq lst (groupbynum (apply (function append) (mapcar (function (lambda ( x ) (cons "" (list (caar x) (cadr (cadar x)) (cadr (caddar x)) (itoa (cdr x)))))) lst)) 5))
  (initget 1)
  (setq pt (getpoint "\nPick or specify point for table : "))
  (lst2table (list "LEGEND" (append (list (list "Preview" "Block Name" "DTYPE" "DSIZE" "Count")) lst)) pt)
  (princ)
)

 

I don't know why after insertion of blocks into table, attributes can't be changed to match descriptions of DTYPE and DSIZE...

Nevertheless this was lesson for me to try to help...

I hope this helps after all, just a little...

Regards, M.R.

count-table-doortag.png

 

count-table-doortag.dwg

Edited by marko_ribar
Link to comment
Share on other sites

Posted (edited)

There is a cheats way around displaying the correct block with attributes, I did something similar for Lines, you could copyclip the block or make new and paste it over the top of the table cell resizing to suit.

 

A side note trying to find an answer vla-SetBlockTableRecordId does a block there is a set objectID to a cell for a table but I could not get it to work. Have a look in the table methods. I deleted my play code will try to find again.

 

image.thumb.png.3bc726555f0e0a4b8be9ae2422eb28b7.png

 

 

 

 

Edited by BIGAL
Link to comment
Share on other sites

Posted (edited)

OP, I managed to do this with table to be OK...

You just have to copybase each of your blocks into blank *.DWG, and when table is created, just go to cell double click and go to Browse... From there, navigate to adequate *.DWG with symbol... In table should be populated adequate symbol you've choosen...

Here is the code and *.ZIP file with all relevant symbols pulled out from master *.DWG, so just unpack *.ZIP in some folder you choose for table...

 

(defun c:count-table-doortag ( / lst2table groupbynum assoc++ blk+tagname+tagval setblocktablerecord objectid effectivename ss idx tmp xrf fil lst pt )

  (or (not (vl-catch-all-error-p (vl-catch-all-apply (function vlax-get-acad-object) nil))) (vl-load-com))

  (defun lst2table ( lst pt / block blockid as cols rh cw ttl data rows sty tbl r k )
    (setq rh
      (vla-gettextheight
        (setq sty
          (vla-item
            (vla-item (vla-get-dictionaries (vla-get-activedocument (vlax-get-acad-object))) "acad_tablestyle")
            (getvar (quote ctablestyle))
          )
        )
        acdatarow
      )
    )
    (setq pt (vlax-3d-point (trans pt 1 0)))
    (setq cols (if (listp (caadr lst)) (length (caadr lst)) (length (car lst))))
    (setq ttl (if (not (listp (car lst))) (car lst)))
    (setq data (if (not (listp (car lst))) (cadr lst) lst))
    (setq data (mapcar (function (lambda ( x ) (mapcar (function (lambda ( y ) (if (null y) "" y))) x))) data))
    (setq rows (if (not (listp (car lst))) (1+ (length data)) (length data)))
    (if ttl
      (vla-enablemergeall sty "Title" :vlax-true)
      (vla-enablemergeall sty "Title" :vlax-false)
    )
    (setq cw (apply (function max) (mapcar (function (lambda ( x ) (strlen x))) (list "Preview" "Block Name" "DTYPE" "DSIZE" "Count"))))
    (setq tbl (vla-addtable spc pt rows cols (* 2.5 rh) (* 0.8 cw)))
    (if (vlax-property-available-p tbl 'regeneratetablesuppressed t)
      (vla-put-regeneratetablesuppressed tbl :vlax-true)
    )
    (vla-put-stylename tbl (getvar (quote ctablestyle)))
    (if ttl
      (progn
        (vla-settext tbl 0 0 ttl)
        (setq r 1)
      )
      (setq r 0)
    )
    (foreach i data
      (setq k -1)
      (foreach ii i
        (vla-settext tbl r (setq k (1+ k)) ii)
        (if (and (> r 1) (= k 1))
          (setblocktablerecord tbl r 0 ii)
        )
        (cond
          ( (and ttl (> r 1))
            (vla-setcellalignment tbl r k acmiddleleft)
          )
          ( (and (not ttl) (= r 0))
            nil
          )
          ( t
            (vla-setcellalignment tbl r k acmiddleleft)
          )
        )
      )
      (setq r (1+ r))
    )
    (setq cw (apply (function max) (mapcar (function (lambda ( x ) (strlen x))) (list "Preview" "Block Name" "DTYPE" "DSIZE" "Count"))))
    (setq k -1)
    (repeat cols
      (vla-setcolumnwidth tbl (setq k (1+ k)) (* cw rh))
    )
    (if (vlax-property-available-p tbl (quote regeneratetablesuppressed) t)
      (vla-put-regeneratetablesuppressed tbl :vlax-false)
    )
    (if (vlax-method-applicable-p tbl (quote scaleentity))
      (vla-scaleentity tbl pt 50.0)
    )
    (vla-update tbl)
    (princ)
  )

  (defun groupbynum ( lst n / sub lll )

    (defun sub ( m n / ll q )
      (cond
        ( (and m (< (length m) n))
          (repeat (- n (length m))
            (setq m (append m (list nil)))
          )
          (setq ll (vl-remove-if-not (function (lambda ( x ) (setq q (if (not q) 0 (1+ q))) (< q n))) m))
          (setq lll (cons ll lll))
          (setq q nil)
          (sub (vl-remove-if (function (lambda ( x ) (setq q (if (not q) 0 (1+ q))) (< q n))) m) n)
        )
        ( m
          (setq ll (vl-remove-if-not (function (lambda ( x ) (setq q (if (not q) 0 (1+ q))) (< q n))) m))
          (setq lll (cons ll lll))
          (setq q nil)
          (sub (vl-remove-if (function (lambda ( x ) (setq q (if (not q) 0 (1+ q))) (< q n))) m) n)
        )
        ( t
          (reverse lll)
        )
      )
    )

    (sub lst n)
  )

  (defun assoc++ ( key lst / itm )
    (if (setq itm (assoc key lst))
      (subst (cons key (1+ (cdr itm))) itm lst)
      (cons  (cons key 1) lst)
    )
  )

  (defun blk+tagname+tagval ( ent / blk enx lst )
    (setq blk (effectivename ent))
    (while (= (cdr (assoc 0 (setq enx (entget (setq ent (entnext ent)))))) "ATTRIB")
      (setq lst (cons (list (cdr (assoc 2 enx)) (cdr (assoc 1 enx))) lst))
    )
    (cons blk lst)
  )

  (defun setblocktablerecord ( obj row col bli )
    (eval
      (list 'defun 'setblocktablerecord '( obj row col bli )
        (cons
          (if (vlax-method-applicable-p obj 'setblocktablerecordid32)
            'vla-setblocktablerecordid32
            'vla-setblocktablerecordid
          )
          (list
            'obj 'row 'col
            (list 'objectid (list 'vla-item blk 'bli))
            ':vlax-true
          )
        )
      )
    )
    (setblocktablerecord obj row col bli)
  )

  (defun objectid ( obj )
    (eval
      (list 'defun 'objectid '( obj )
        (cond
          ( (not (wcmatch (getenv "PROCESSOR_ARCHITECTURE") "*64*"))
           '(vla-get-objectid obj)
          )
          ( (= 'subr (type vla-get-objectid32))
           '(vla-get-objectid32 obj)
          )
          ( (list 'vla-getobjectidstring (vla-get-utility doc) 'obj ':vlax-false) )
        )
      )
    )
    (objectid obj)
  )

  (defun effectivename ( ent / blk rep )
    (if (wcmatch (setq blk (cdr (assoc 2 (entget ent)))) "`**")
      (if
        (and
          (setq rep
            (cdadr
              (assoc -3
                (entget
                  (cdr
                    (assoc 330
                      (entget
                          (tblobjname "block" blk)
                      )
                    )
                  )
                 '("AcDbBlockRepBTag")
                )
              )
            )
          )
          (setq rep (handent (cdr (assoc 1005 rep))))
        )
        (setq blk (cdr (assoc 2 (entget rep))))
      )
    )
    blk
  )

  (or cad (setq cad (vlax-get-acad-object)))
  (or doc (setq doc (vla-get-activedocument cad)))
  (or alo (setq alo (vla-get-activelayout doc)))
  (or spc (setq spc (vla-get-block alo)))
  (or blk (setq blk (vla-get-blocks doc)))
  (while (setq tmp (tblnext "block" (null tmp)))
    (if (= 4 (logand 4 (cdr (assoc 70 tmp))))
      (setq xrf (vl-list* "," (cdr (assoc 2 tmp)) xrf))
    )
  )
  (if xrf
    (setq fil (list (cons 0 "INSERT") (cons -4 "<NOT") (cons 2 (apply (function strcat) (cdr xrf))) (cons -4 "NOT>") (cons 66 1)))
    (setq fil (list (cons 0 "INSERT") (cons 66 1)))
  )
  (prompt "\nSelect attributed blocks <all>...")
  (if (not (setq ss (ssget fil)))
    (setq ss (ssget "_A" fil))
  )
  (setq idx -1)
  (repeat (sslength ss)
    (setq lst (assoc++ (blk+tagname+tagval (ssname ss (setq idx (1+ idx)))) lst))
  )
  (setq lst (vl-sort lst (function (lambda ( a b ) (> (cdr a) (cdr b))))))
  (setq lst (groupbynum (apply (function append) (mapcar (function (lambda ( x ) (cons "" (list (caar x) (cadr (cadar x)) (cadr (caddar x)) (itoa (cdr x)))))) lst)) 5))
  (initget 1)
  (setq pt (getpoint "\nPick or specify point for table : "))
  (lst2table (list "LEGEND" (append (list (list "Preview" "Block Name" "DTYPE" "DSIZE" "Count")) lst)) pt)
  (princ)
)

 

count-table-doortag.png

 

 

count-table-doortag.zip

Edited by marko_ribar
Link to comment
Share on other sites

sorry, I went off .....

Thanks Marko_ribar

The table come in later. That could be a separate program. (as you have nicely already completed) Thanks

 

 

My initial issue was changing all instances like a normal autocad block.

All the blocks are called doortag

while insertion we have 2 prompts - 1.  Dype - Which could be ED, BD1, BD2 TW1, TW2 etc...

                                                                 2. Dsize- could be 900, 1000,750, 1500 etc

Many such instances are created / copied in different areas of the drawing.

Say we have an instance of ED/1200

Now That ED/1200 needs to be changed to (say) ED1/1000

Basically all instances of ED/1200 should change to the new size of ED1/1000

We should be able to choose one instance, update any dtype of dsize or both, and it needs to update all the relevant instances

 

Like how we work with normal Autocad blocks. 

We have Lee's program AttModSuite which can update blocks one at a time. (Thanks Lee)

All autocad attribute edit commands  do it one at a time, but this means choosing them one by one all over the drawing (this leads to omissions) since all the blocks have the same name (different attributes) I cant filter them out.

Is there a way to do this ???

Thank you so much 

 

 

Link to comment
Share on other sites

Posted (edited)

I don't think so... Attributes are separate instances and therefore they don't behave like nested entities of block references/definitions...

If I made you angry, I am sorry, but that's the way it is...

But if you have normal TEXT entities instead of ATTRIB entities, then it should work exactly you described... Just tested and it worked...

Sorry and happy coding...

M.R.

Edited by marko_ribar
Link to comment
Share on other sites

@Hsanon Might have a solution upload a drawing with a few blocks in question and ill see what i can do.

Link to comment
Share on other sites

heyyyyy.... angry ???? not at all .... I'm highly obliged that you took so much effort....please please don't even get that thought !!!! 

Its sad that we cant modify attribute blocks like normal autocad blocks..... otherwise, im sure one of you geniuses would have taken out a solution for it !!!! really do appreciate the fact that you made out that table program. Will probably go back to making out individual door and window tags as individual blocks !!!!

 

thanks guys  

and apologies for any misunderstandings or inconveniences !!!!!

regards

 

Link to comment
Share on other sites

Have you tried the Express Tools GATTE command? This will sync the attrib values of all blocks of the same name. The only drawback is that you have to process each attribute through the command.

Link to comment
Share on other sites

Posted (edited)

Code only really works on the door block but could be modified to be more dynamic. also its case sensitive when inputting the current DTYPE

 

Also remember ATTout with express tools it outputs the block handle and attributes to a text file. open text file in excel & update what you want save file then use ATTin to update attributes in mass.

 

 

 

DoorAttributes.lsp

Edited by mhupp
Link to comment
Share on other sites

Dear Mhupp

This works for me !!!! many many thanks...... 

really do appreciate your effort and your genius !!!! 

and a big thanks to everyone who put their brains into this 

you guys are the best !!!! 🙏
Harsh

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...