Try this
Code:
; Pick blocks get attributes and put in another block
; By Alan H Nov 2018
; hard coded to suit
(defun getblk-putblk ( / ss x y k blk lstlst2 att att1 att2)
(defun do-att (y attt / k)
(setq k 0)
(foreach att (vlax-invoke (vlax-ename->vla-object (car blk)) 'getattributes)
(if (= k y) (vla-put-textstring att attt))
(setq k (+ k 1))
)
)
(setq blk (entsel "Pick detail block"))
(alert "Select all blocks for this section \n\npick nothing to leave blank\n\n expects 4 selections")
(setq L 0)
(setq lst3 '(1 13 25 37))
(repeat 4
(setq N (nth L lst3))
(if (/= (setq ss (ssget (list (cons 0 "insert")))) nil)
(progn
(setq lst '())
(repeat (setq x (sslength ss))
(setq lst2 '())
(foreach att (vlax-invoke (vlax-ename->vla-object (ssname SS (setq x (- X 1)))) 'getattributes)
(setq lst2 (cons (cadr (vlax-safearray->list (vlax-variant-value (vla-get-insertionpoint att)))) lst2))
(setq lst2 (cons (vla-get-textstring att) lst2))
)
(setq lst (reverse lst))
(setq lst (cons lst2 lst))
)
(setq lst (vl-sort lst
'(lambda (x y)
(cond
((= (cadr x)(cadr y))
(< (car x)(car y)))
((< (cadr x)(cadr y)))
)
)
)
)
(setq lst (reverse lst))
(repeat (setq x (length lst))
(setq att(nth (setq x (- x 1)) lst))
(setq att2 (caddr att))
(do-att N att2)
(setq N (+ N 1))
)
)) ; end while ?
(setq L (+ L 1))
)
(do-att 0 (nth 0 lst2))
)
(getblk-putblk)