I am looking for a lisp that can match attribute data from one attribute tag say NAME to another attribute tag say DESIGNER_NAME. The tag or attribute name are different but they actually mean the same thing. I have found mav.lsp and mtb.lsp that do the job quite well but they both require the attribute names to be the same.
I came across a code that can do the job in spite of the attributes tag between different. The only problem is that it can only be applied once. It is a program by LEE MAC
(defun c:ca ( / _SelectBlockWithTag a b des src tag ) (vl-load-com) (setq src "DESIGNER" ; Source Attribute Tag des "NOM_DESSINATEUR" ; Destination Attribute Tag ) (defun _SelectBlockWithTag ( tag / e a ) (setq tag (strcase tag)) (while (progn (setvar 'ERRNO 0) (setq e (car (entsel (strcat "\nSelect Block with attribute " tag ": ")))) (cond ( (= 7 (getvar 'ERRNO)) (princ "\nMissed, Try Again.") ) ( (not e) nil ) ( (and (eq "INSERT" (cdr (assoc 0 (entget e)))) (= 1 (cdr (assoc 66 (entget e)))) ) (if (not (setq a (vl-some (function (lambda ( x ) (if (eq tag (strcase (vla-get-tagstring x))) x) ) ) (vlax-invoke (vlax-ename->vla-object e) 'getattributes) ) ) ) (princ (strcat "\nBlock does not contain tag " tag ".")) ) ) ( (princ "\nInvalid Object Selected.") ) ) ) ) a ) (while (and (setq a (_SelectBlockWithTag src)) (setq b (_SelectBlockWithTag des)) ) (vla-put-textstring b (vla-get-textstring a)) ) (princ) ) Lee Mac Programming
In this case, I have input the first tag as DESIGNER and the second as NOM_DESSINATEUR. However I have a set of attributes to change. However I have about 8 more to include.
Many Thanks to Lee Mac, for your prompt response. It is just awesome. Great that you are always doing the extra mile and has always been thinking big in your applications. I will be able to start working the modifications to a set of more than 400 plans this week. Following number of changes, I have to change datum in two blocks, one in french, one in english. The standard copy attribute from one block to another lisp do not work because they are based on similar tag names. It would be well if you can show me how you can add additional
Source Attribute Tag and Destination Attribute Tag
Hence I will be able to automatically transfer every data in one go and save some additional time.
How can this code be altered to specify the source and destination blocks by name instead of selection?
I have a client titleblock with attribute tag names that cant be modified (because of how they extract block infomation into their edms system) yet we would like to map their attributes tags to our titleblock attribute tags so that we can pull this information into our edms system.
The idea being I can then load and run a script to update a titleblock from sytax such as:
(ca srcBlk src desBlk des)
script:
(ca "ISO_D" "TOP_LINE_DESCRIPTION" "MTitleblock" "TITLE1")
(ca "ISO_D" "Second_LINE_DESCRIPTION" "MTitleblock" "TITLE2")