Moving attributes text from one block to another block

Moving attributes text from one block to another block

ryan.jones34
Explorer Explorer
372 Views
4 Replies
Message 1 of 5

Moving attributes text from one block to another block

ryan.jones34
Explorer
Explorer

Hello,

 

I was wondering if it was possible for anyone to do a lisp that can move the attribute text from one block to another attribute block.

 

I have looked on the site and cannot find anything that can do what I need exactly and the lisps I did find I was unable to adjust to do what I needed.

 

I have attached the drawing and with the attributes on it.

 

I would like to move the attribute with:

 

AREA

NAME

AUX

 

And move it to the other attribute block which is labelled:

Room_Category

Room_Number

Room_SQM

Room_Owner

Room_Code

 

I need the information in the first attribute block to have AREA going to Room_SQM, NAME to go to Room_Number and AUX to go to Room_Category.

 

Thanks

 

0 Likes
Accepted solutions (1)
373 Views
4 Replies
Replies (4)
Message 2 of 5

pendean
Community Legend
Community Legend
If I may inquire, simply editing your block to add those attributes would have taken less time by now: by chance do you just need help adding your fixed block with the extra attributes into other DWG files with the old attribute definition instead?
Message 3 of 5

ryan.jones34
Explorer
Explorer

This was only a sample drawing I have about 400 attributes on a plan and I have about 100 plans that I need to do this on. As it is such a huge quantity I wanted to see if there was a quicker way then me doing it individually and typing everything over. 

0 Likes
Message 4 of 5

EnM4st3r
Advocate
Advocate
Accepted solution

I took a Lisp i found online and added an adjustment for your specific attributes

 

;;  match block attributes
;;
;;  source: https://www.theswamp.org/index.php?topic=3763.0
;;
;;
(princ "\nType MB to Run")
(defun C:MB (/ baselist ename ename1 elist etype tag val ename1 elist1 etype1 attval)
   (setq baselist (list))      
   (setq ename (car (entsel "\nSelect Base Block:")))
   (while (= ename nil)
      (princ "\nNothing Picked")
      (setq ename (car (entsel "\nSelect Base Block:")))
   );end while
   (setq ename (entnext ename))
   (setq elist (entget ename))   ;the entity list of the base border
   (setq etype (cdr (assoc 0 elist)))   ;should be attrib
   (while (= etype "ATTRIB")      ;puts all the attribute in a list
      (setq tag (cdr (assoc 2 elist)))      ;the attribute tag
      (setq val (cdr (assoc 1 elist)));the attribute value
      (setq baselist (append (list (list tag val)) baselist));put the attribute in list
      (setq ename (entnext ename))         ;move onto the next attribute
      (setq elist (entget ename))
      (setq etype (cdr (assoc 0 elist)))
   );end while
  
  ;;----------------------------------- Adjust baselist -----------------------------
   (setq baselist (mapcar '(lambda (x)  (cond
                                          ((= "AREA" (car x))
                                           (cons "ROOM_SQM" (vl-remove "AREA" x)))
                                          ((= "NAME" (car x))
                                           (cons "ROOM_NUMBER" (vl-remove "NAME" x)))
                                          ((= "AUX" (car x))
                                           (cons "ROOM_CATEGORY" (vl-remove "AUX" x)))
                                        );cond
                           )baselist);mapcar
   );setq
  ;;----------------------------------- End of Adjustment --------------------------------
  
   (while t 
     (setq ename1 (car (entsel "\nSelect Block To Apply Changes:")))
      (while (= ename1 nil) 
        (princ "\nNothing Picked")
        (setq ename1 (car (entsel "\nSelect Block To Apply Changes:")))
      );end while
     (setq ename1 (entnext ename1)) ;get the next entity, should be "ATTRIB"
     (setq elist1 (entget ename1)) ;the entity list of the border
     (setq etype1 (cdr (assoc 0 elist1))) ;should be attrib
     (while (= etype1 "ATTRIB")
       (setq attval nil)
       (setq tag (cdr (assoc 2 elist1))) ;the attribute tag
       (foreach item baselist 
         (if (= tag (nth 0 item)) 
           (progn 
             (setq attval (nth 1 item))
           ) ;end then
           (progn) ;else do nothing go to next in list till tag matches
         ) ;end if
       ) ;end foreach
       (if (/= attval nil) 
         (progn (setq elist1 (subst (cons 1 attval) (assoc 1 elist1) elist1)) 
                (entmod elist1)
         ) ;end then
         (progn) ;end else
       ) ;end if
       (setq ename1 (entnext ename1)) ;move onto the next attribute
       (setq elist1 (entget ename1))
       (setq etype1 (cdr (assoc 0 elist1)))
     ) ;end while
     (command "REGEN")
   );while t
);end defun
(princ)

 

 

 

Message 5 of 5

ryan.jones34
Explorer
Explorer

@EnM4st3r That has worked great. Thank you so much for your help.