Rakesh H M Posted April 7 Posted April 7 On 4/4/2025 at 9:37 AM, Saxlle said: Can you upload a drawing with all that blocks on which you want to reorder "TAGS"? Expand Find the attached file. I need to do sort all the blocks at a time. Wood Master for testing.dwgFetching info... Quote
Rakesh H M Posted April 7 Posted April 7 On 4/4/2025 at 10:15 PM, BIGAL said: @Rakesh H M even if you have a 1000 blocks if they are one block name and you do the BEDIT and Battman then as shown above they should be updated, after Apply do Sync. Expand Can you please try this with attached file? I need to do sort all the blocks at a time. Wood Master for testing.dwgFetching info... Quote
BIGAL Posted April 7 Posted April 7 The blocks appear to be identical apart from the fact that each block is given an individual name. They appear to have the same attributes but in different order. So my question is why do you not just have one block ? But with all the details different each time you insert that block. Are you using some form of software to make the blocks ? The blocks just look to random. Are you copying and pasting from other dwg's ? I think if you give us some background on how your getting to this point we may be able to fix it for the next dwg. 1 Quote
Saxlle Posted April 7 Posted April 7 (edited) Hey @Rakesh H M, Try this: ; **************************************************************************************** ; Functions : RETAGS ; Description : Reorder TAG names with appropriate text values and layer names ; Author : SAXLLE ; Date : April 07, 2025 ; **************************************************************************************** (prompt "\nTo run a LISP type: RETAGS") (princ) (defun c:RETAGS ( / old_nomutt lst_tags_valid lst_layer_names ss len i lst_attribs tag_val tag_val_lst tag_val_lst_final data tag val n j new_lst1 new_lst2 subst_lst) (setq old_nomutt (getvar 'nomutt)) (setvar 'nomutt 1) (setq lst_tags_valid (list "UNIT#" "OPTSTYLE" "OPTSUFFIX" "SELFPRICE" "ZZPART" "ZZDETAIL" "ROOM" "FLOOR" "BUILDING" "PHASE" "KEYING" "ASSOCIATED" "HEIGHT" "DEPTH" "LENGTH" "ARCHNO" "LINE" "DEALER") ;; Valid order of the TAGS names lst_layer_names (list "ATT_UNITNO" "ATT_OPTSTYLE" "ATT_OPTSUFFIX" "ATT_SELFPRICE" "ATT_ZZPART" "ATT_ZZDETAIL" "ATT_ROOMNUMBER" "ATT_FLOOR" "ATT_BUILDING" "ATT_PHASE" "ATT_KEYING" "ATT_ASSOCIATED" "ATT_HEIGHT" "ATT_DEPTH" "ATT_LENGTH" "ATT_ARCHNO" "ATT_LINE" "ATT_DEALER") ;; Valid list of layer names ) (princ "\nSelect the BLOCK's to reorder TAGS names:") (setq ss (ssget '((0 . "INSERT"))) len (sslength ss) i 0 ) (while (< i len) (setq lst_attribs (list) tag_val (list) tag_val_lst (list) tag_val_lst_final (list) ) (setq data (entget (ssname ss i))) (while (not (equal (cdr (assoc 0 data)) "SEQEND")) (if (equal (cdr (assoc 0 data)) "ATTRIB") (progn (setq lst_attribs (cons data lst_attribs)) (setq data (entget (entnext (cdr (assoc -1 data))))) ) (setq data (entget (entnext (cdr (assoc -1 data))))) ) ) (foreach n lst_attribs (setq tag (cdr (assoc 2 n)) val (cdr (assoc 1 n)) tag_val (list tag val) tag_val_lst (cons tag_val tag_val_lst) ) ) (setq n 0) (while (< n (length lst_attribs)) (if (equal (nth n lst_tags_valid) (car (nth n tag_val_lst))) (setq tag_val_lst_final (cons (nth n tag_val_lst) tag_val_lst_final)) (progn (setq k 0) (while (not (equal (nth n lst_tags_valid) (car (nth k tag_val_lst)))) (setq k (1+ k)) ) (setq tag_val_lst_final (cons (nth k tag_val_lst) tag_val_lst_final)) ) ) (setq n (1+ n)) ) (setq tag_val_lst_final (reverse tag_val_lst_final) j 0 lst_attribs (reverse lst_attribs) new_lst1 (list) ;; List of TAGS new_lst2 (list) ;; List of text values ) ;; Reorder TAGS (repeat (length lst_attribs) (setq subst_lst (entmod (subst (cons 2 (car (nth j tag_val_lst_final))) (cons 2 (cdr (assoc 2 (nth j lst_attribs)))) (nth j lst_attribs)))) (setq new_lst1 (cons subst_lst new_lst1)) (setq j (1+ j)) ) (setq new_lst1 (reverse new_lst1) j 0) ;; Put the right text value into the Reorder TAGS (repeat (length lst_attribs) (setq subst_lst (entmod (subst (cons 1 (cadr (nth j tag_val_lst_final))) (cons 1 (cdr (assoc 1 (nth j new_lst1)))) (nth j new_lst1)))) (setq new_lst2 (cons subst_lst new_lst2)) (setq j (1+ j)) ) (setq j 0) (setq new_lst2 (reverse new_lst2)) ;; Substitue layer names (repeat (length lst_attribs) (entmod (subst (cons 8 (nth j lst_layer_names)) (cons 8 (cdr (assoc 8 (nth j new_lst2)))) (nth j new_lst2))) (setq j (1+ j)) ) (setq i (1+ i)) ) (setvar 'nomutt old_nomutt) (prompt (strcat "\nThe " (itoa i) " BLOCK's with attribute TAGS has been reorder!")) (princ) ) I tested it on your an example drawing (just on few blocks), and it works. See attached picture. I hope it will be helpful. P.S. I agree with what @BIGAL was mention. Best regards. Notice: not fully tested, maybe some unexpected occurrence can happen. NOT YET VALID AS ACCEPTABLE SOLUTION!!! Edited April 9 by Saxlle Not yet acceptable! 1 Quote
Rakesh H M Posted April 8 Posted April 8 On 4/7/2025 at 11:29 AM, Saxlle said: Hey @Rakesh H M, Try this: ; **************************************************************************************** ; Functions : RETAGS ; Description : Reorder TAG names with appropriate text values and layer names ; Author : SAXLLE ; Date : April 07, 2025 ; **************************************************************************************** (prompt "\nTo run a LISP type: RETAGS") (princ) (defun c:RETAGS ( / old_nomutt lst_tags_valid lst_layer_names ss len i lst_attribs tag_val tag_val_lst tag_val_lst_final data tag val n j new_lst1 new_lst2 subst_lst) (setq old_nomutt (getvar 'nomutt)) (setvar 'nomutt 1) (setq lst_tags_valid (list "UNIT#" "OPTSTYLE" "OPTSUFFIX" "SELFPRICE" "ZZPART" "ZZDETAIL" "ROOM" "FLOOR" "BUILDING" "PHASE" "KEYING" "ASSOCIATED" "HEIGHT" "DEPTH" "LENGTH" "ARCHNO" "LINE" "DEALER") ;; Valid order of the TAGS names lst_layer_names (list "ATT_UNITNO" "ATT_OPTSTYLE" "ATT_OPTSUFFIX" "ATT_SELFPRICE" "ATT_ZZPART" "ATT_ZZDETAIL" "ATT_ROOMNUMBER" "ATT_FLOOR" "ATT_BUILDING" "ATT_PHASE" "ATT_KEYING" "ATT_ASSOCIATED" "ATT_HEIGHT" "ATT_DEPTH" "ATT_LENGTH" "ATT_ARCHNO" "ATT_LINE" "ATT_DEALER") ;; Valid list of layer names ) (princ "\nSelect the BLOCK's to reorder TAGS names:") (setq ss (ssget '((0 . "INSERT"))) len (sslength ss) i 0 ) (while (< i len) (setq lst_attribs (list) tag_val (list) tag_val_lst (list) tag_val_lst_final (list) ) (setq data (entget (ssname ss i))) (while (not (equal (cdr (assoc 0 data)) "SEQEND")) (if (equal (cdr (assoc 0 data)) "ATTRIB") (progn (setq lst_attribs (cons data lst_attribs)) (setq data (entget (entnext (cdr (assoc -1 data))))) ) (setq data (entget (entnext (cdr (assoc -1 data))))) ) ) (foreach n lst_attribs (setq tag (cdr (assoc 2 n)) val (cdr (assoc 1 n)) tag_val (list tag val) tag_val_lst (cons tag_val tag_val_lst) ) ) (setq n 0) (while (< n (length lst_attribs)) (if (equal (nth n lst_tags_valid) (car (nth n tag_val_lst))) (setq tag_val_lst_final (cons (nth n tag_val_lst) tag_val_lst_final)) (progn (setq k 0) (while (not (equal (nth n lst_tags_valid) (car (nth k tag_val_lst)))) (setq k (1+ k)) ) (setq tag_val_lst_final (cons (nth k tag_val_lst) tag_val_lst_final)) ) ) (setq n (1+ n)) ) (setq tag_val_lst_final (reverse tag_val_lst_final) j 0 lst_attribs (reverse lst_attribs) new_lst1 (list) ;; List of TAGS new_lst2 (list) ;; List of text values ) ;; Reorder TAGS (repeat (length lst_attribs) (setq subst_lst (entmod (subst (cons 2 (car (nth j tag_val_lst_final))) (cons 2 (cdr (assoc 2 (nth j lst_attribs)))) (nth j lst_attribs)))) (setq new_lst1 (cons subst_lst new_lst1)) (setq j (1+ j)) ) (setq new_lst1 (reverse new_lst1) j 0) ;; Put the right text value into the Reorder TAGS (repeat (length lst_attribs) (setq subst_lst (entmod (subst (cons 1 (cadr (nth j tag_val_lst_final))) (cons 1 (cdr (assoc 1 (nth j new_lst1)))) (nth j new_lst1)))) (setq new_lst2 (cons subst_lst new_lst2)) (setq j (1+ j)) ) (setq j 0) (setq new_lst2 (reverse new_lst2)) ;; Substitue layer names (repeat (length lst_attribs) (entmod (subst (cons 8 (nth j lst_layer_names)) (cons 8 (cdr (assoc 8 (nth j new_lst2)))) (nth j new_lst2))) (setq j (1+ j)) ) (setq i (1+ i)) ) (setvar 'nomutt old_nomutt) (prompt (strcat "\nThe " (itoa i) " BLOCK's with attribute TAGS has been reorder!")) (princ) ) I tested it on your an example drawing (just on few blocks), and it works. See attached picture. I hope it will be helpful. P.S. I agree with what @BIGAL was mention. Best regards. Notice: not fully tested, maybe some unexpected occurrence can happen. Expand @Saxlle It works perfectly for my needs. Thank you so much! @BIGAL Thank you! Quote
Rakesh H M Posted April 8 Posted April 8 On 4/7/2025 at 6:58 AM, BIGAL said: The blocks appear to be identical apart from the fact that each block is given an individual name. They appear to have the same attributes but in different order. So my question is why do you not just have one block ? But with all the details different each time you insert that block. Are you using some form of software to make the blocks ? The blocks just look to random. Are you copying and pasting from other dwg's ? I think if you give us some background on how your getting to this point we may be able to fix it for the next dwg. Expand Its Architect request. They need individual blocks. Each block represents each product number. It's not same. We use wblock command while creating. these are old blocks but Architect requested us to maintain Attributes consistency forrmat. Quote
Rakesh H M Posted April 8 Posted April 8 On 4/7/2025 at 11:29 AM, Saxlle said: Hey @Rakesh H M, Try this: ; **************************************************************************************** ; Functions : RETAGS ; Description : Reorder TAG names with appropriate text values and layer names ; Author : SAXLLE ; Date : April 07, 2025 ; **************************************************************************************** (prompt "\nTo run a LISP type: RETAGS") (princ) (defun c:RETAGS ( / old_nomutt lst_tags_valid lst_layer_names ss len i lst_attribs tag_val tag_val_lst tag_val_lst_final data tag val n j new_lst1 new_lst2 subst_lst) (setq old_nomutt (getvar 'nomutt)) (setvar 'nomutt 1) (setq lst_tags_valid (list "UNIT#" "OPTSTYLE" "OPTSUFFIX" "SELFPRICE" "ZZPART" "ZZDETAIL" "ROOM" "FLOOR" "BUILDING" "PHASE" "KEYING" "ASSOCIATED" "HEIGHT" "DEPTH" "LENGTH" "ARCHNO" "LINE" "DEALER") ;; Valid order of the TAGS names lst_layer_names (list "ATT_UNITNO" "ATT_OPTSTYLE" "ATT_OPTSUFFIX" "ATT_SELFPRICE" "ATT_ZZPART" "ATT_ZZDETAIL" "ATT_ROOMNUMBER" "ATT_FLOOR" "ATT_BUILDING" "ATT_PHASE" "ATT_KEYING" "ATT_ASSOCIATED" "ATT_HEIGHT" "ATT_DEPTH" "ATT_LENGTH" "ATT_ARCHNO" "ATT_LINE" "ATT_DEALER") ;; Valid list of layer names ) (princ "\nSelect the BLOCK's to reorder TAGS names:") (setq ss (ssget '((0 . "INSERT"))) len (sslength ss) i 0 ) (while (< i len) (setq lst_attribs (list) tag_val (list) tag_val_lst (list) tag_val_lst_final (list) ) (setq data (entget (ssname ss i))) (while (not (equal (cdr (assoc 0 data)) "SEQEND")) (if (equal (cdr (assoc 0 data)) "ATTRIB") (progn (setq lst_attribs (cons data lst_attribs)) (setq data (entget (entnext (cdr (assoc -1 data))))) ) (setq data (entget (entnext (cdr (assoc -1 data))))) ) ) (foreach n lst_attribs (setq tag (cdr (assoc 2 n)) val (cdr (assoc 1 n)) tag_val (list tag val) tag_val_lst (cons tag_val tag_val_lst) ) ) (setq n 0) (while (< n (length lst_attribs)) (if (equal (nth n lst_tags_valid) (car (nth n tag_val_lst))) (setq tag_val_lst_final (cons (nth n tag_val_lst) tag_val_lst_final)) (progn (setq k 0) (while (not (equal (nth n lst_tags_valid) (car (nth k tag_val_lst)))) (setq k (1+ k)) ) (setq tag_val_lst_final (cons (nth k tag_val_lst) tag_val_lst_final)) ) ) (setq n (1+ n)) ) (setq tag_val_lst_final (reverse tag_val_lst_final) j 0 lst_attribs (reverse lst_attribs) new_lst1 (list) ;; List of TAGS new_lst2 (list) ;; List of text values ) ;; Reorder TAGS (repeat (length lst_attribs) (setq subst_lst (entmod (subst (cons 2 (car (nth j tag_val_lst_final))) (cons 2 (cdr (assoc 2 (nth j lst_attribs)))) (nth j lst_attribs)))) (setq new_lst1 (cons subst_lst new_lst1)) (setq j (1+ j)) ) (setq new_lst1 (reverse new_lst1) j 0) ;; Put the right text value into the Reorder TAGS (repeat (length lst_attribs) (setq subst_lst (entmod (subst (cons 1 (cadr (nth j tag_val_lst_final))) (cons 1 (cdr (assoc 1 (nth j new_lst1)))) (nth j new_lst1)))) (setq new_lst2 (cons subst_lst new_lst2)) (setq j (1+ j)) ) (setq j 0) (setq new_lst2 (reverse new_lst2)) ;; Substitue layer names (repeat (length lst_attribs) (entmod (subst (cons 8 (nth j lst_layer_names)) (cons 8 (cdr (assoc 8 (nth j new_lst2)))) (nth j new_lst2))) (setq j (1+ j)) ) (setq i (1+ i)) ) (setvar 'nomutt old_nomutt) (prompt (strcat "\nThe " (itoa i) " BLOCK's with attribute TAGS has been reorder!")) (princ) ) I tested it on your an example drawing (just on few blocks), and it works. See attached picture. I hope it will be helpful. P.S. I agree with what @BIGAL was mention. Best regards. Notice: not fully tested, maybe some unexpected occurrence can happen. Expand @Saxlle Attributes arranged correctly but I just find one issue with attributes locations. See attached pics. Its moving everywhere not in original position. Is it possible fix this issue? Quote
Saxlle Posted April 9 Posted April 9 @Rakesh H M, Honestly, I really don't know how to do reorder as it can be done in BATTMAN. Tried some options, but everytime I get as from the an example: Maybe someone can help in this (it will be a good lisp for every other situation which are someone is going to have). Quote
BIGAL Posted April 10 Posted April 10 Thanks @Saxlle for comment, I was looking at using vla getattributes reorder the list produced to match desired order then putattributes. I am not sure if it will work. I was editing the block definition so do a attsync after update of block. Working on one block may be easier. Will have a play when I have time. Quote
Saxlle Posted April 10 Posted April 10 On 4/10/2025 at 12:01 AM, BIGAL said: I was editing the block definition so do a attsync after update of block Expand I'm also tried that, after reorder TAGs, use attsync, but then somehow the all TAGs again change the order. On 4/10/2025 at 12:01 AM, BIGAL said: Will have a play when I have time. Expand Happy for that, maybe we can find a right solution for that. Quote
Rakesh H M Posted April 11 Posted April 11 On 4/10/2025 at 1:50 PM, Saxlle said: I'm also tried that, after reorder TAGs, use attsync, but then somehow the all TAGs again change the order. Happy for that, maybe we can find a right solution for that. Expand @Saxlle We're almost there, but this is the only issue we're facing. Thank you for hopping in and creating the Autoslip. @BIGAL Let us know if you find the right solution to fix both issues. Quote
Recommended Posts
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.