If you are new to LISP progamming, this is actually a very complicated routine to start off with.
Take a look at this routine I call Getval to see if you can use it to learn from it. I try and place as much comments as possible to explain the lines of code are doing.
Save to location and then use APPLOAD command to select and load then enter Getval at command line.
Select your first Block with Attribute then hit Enter to complete selection.
Next select your second Block with Attribute that you want to place the result and hit Enter to complete that selection. Now see if that's the result you want to get.
There are many ways to improve the routine more like changing it so you only select the Block with the matching Name. I including this in the code but commented out. Also you can change the code so that you don't have to hit an Enter after selecting the object. Lastly, you can learn how to use Visual Lisp functions to do similar steps.
; getval.lsp
(defun c:getval (/ ss1 ss2 en ed sen sed val1 val)
(princ"\nSelect 1st Block with Attribute Values: ")
(setq ss1 (ssget ":L" '((0 . "INSERT")(66 . 1)))) ; select block with attribute on unlock layer
; (setq ss1 (ssget ":L" '((0 . "INSERT")(2 . "RMNUM")(66 . 1)))) ; select block with name set as "RMNUM" & attribute on unlock layer
(if ss1
(progn
(princ"\nSelect 2nd Block to Place Attribute Value: ")
(setq ss2 (ssget ":L" '((0 . "INSERT")(66 . 1)))) ; select block with attribute to place
; (setq ss2 (ssget ":L" '((0 . "INSERT")(2 . "RMNUM")(66 . 1)))) ; select block with name set as "RMNUM" & attribute on unlock layer
(if ss2
(progn
(setq val "" val1 "") ; set initial value
(setq en (ssname ss1 0)) ; get obj
(setq ed (entget en)) ; get obj data
(setq sen (entnext en)) ; get subentity's name
(while sen ; while there are subentities
(setq sed (entget sen)) ; get subentity's data
(if (/= (cdr(assoc 0 sed)) "SEQEND") ; look for Attribute subentity
(progn
(setq val (cdr(assoc 1 sed))) ; get attribute value
(if (= val "")
(progn
(setq sen nil) ; if value is empty then end while loop
(setq val val1) ; use previous val
)
(progn
(setq sen (entnext sen)) ; else continue to next
(setq val1 val) ; store non empty value
)
)
) ; progn get val
(setq sen nil) ; stop while loop
) ; if
) ; while
(setq sen (entnext (ssname ss2 0))) ; get placement subentity's name
(setq sed (entget sen)) ; get subentity's data
(setq sed (subst (cons 1 val) (assoc 1 sed) sed)) ; substitute new value
(entmod sed) ; modify its' data
(entupd sen) ; update obj
) ; progn
(progn
(princ"\nNo Object Selected.")
)
) ; if
) ; progn
(progn
(princ"\nNo Object Selected.")
)
) ; if
(princ)
) ; defun
(princ"\nGetVal command loaded")(princ)