Hello All,

I wonder if I can get some help. I am very basic with lisp right now, but trying to get better. I hope I can explain this so it makes sense without being long winded. I am redoing our titleblocks. We have about 15 different titleblocks varying in size or layout based off the type of application. I revised it down to 8. The old ones were basically made with 3 separate blocks: the border, the title info (with attributes), and an additional drawing number. I am redoing this now all as one block. The way the lisp worked was replacing the 3 blocks with the new blocks of the same name. The main problem now is because of the change (layout & size), some of the attribute tags had to change to be consistent with the different titleblocks so all the attributes are the same.

The titleblocks were named based off of size so the sizes now are different. Since we are condensing several borders into one size, the lisp I am trying to write would allow me to tell lisp which files I want to replace.

Here is the code I have so far. The original code renamed all the titleblocks with the following block names: border, title_number, & title_block. My question is how can I pull the attribute info out & put it in the new titleblock once inserted? I'm sure I'm missing a lot of info. I tried reusing some of the previous code. I'm sure there is a better way. Any help would be appreciated.


Code:
 ;valuelist extracts each attributes information.
(defun valuelist ()
   (setq oldattlst (list "draw_no" "rev_num" "sta_name" "address_l" "address"
                         "address_r" "title1" "title2" ""co_num" "sta_no"
                         "scale1" "scale2" "scale3" "drawn_by" "drawn_date"
                         "draft_chk" "engr_chk" "eng_chk1" "eng_chk2"
                         "eng_chk3" "eng_chk4" "approved" "approved1"
                         "app_date" "dept" "arch_app" "arch_app1"
                         "elec_app" "elec_app1" "mech_app" "mech_app1"
                         "civ_app" "civ_app1" "ofe_num" "wmis_no"
                         "sta_code1" "sta_code2" "sta_code3" "sta_code4"
                         "sta_code5" "sta_code6" "doc_filter1" "doc_filter2"
                         "doc_filter3" "doc_filter4" "doc_filter5"
                         "funct1" "funct2" "funct3" "funct4" "funct5"
                         "funct6" "funct7" "funct8" "funct9" "funct10"
                         "pnl1" "pnl2" "pnl3" "pnl4" "pnl5" "pnl6" "pnl7"
                         "pnl8" "pnl9" "pnl10" "old_dwgno" "barcode"
                         "user" "dos_name" "dos_date" "dos_time"
                         "plot_index" "plot_scale" "work_with"))
)


;newvaluelist takes attribute info of newly inserted block
(defun newvaluelist ()
   (setq newattlst (list "draw_no" "rev_num" "sta_name" "address_l" "address"
                         "address_r" "title1" "title2" ""co_num" "sta_no"
                         "scale1" "scale2" "scale3" "drawn_by" "drawn_date"
                         "draft_chk" "engr_chk" "eng_chk1" "eng_chk2"
                         "eng_chk3" "eng_chk4" "approved" "approved1"
                         "app_date" "dept" "arch_app" "arch_app1"
                         "elec_app" "elec_app1" "mech_app" "mech_app1"
                         "civ_app" "civ_app1" "ofe_num" "wmis_no"
                         "sta_code1" "sta_code2" "sta_code3" "sta_code4"
                         "sta_code5" "sta_code6" "doc_filter1" "doc_filter2"
                         "doc_filter3" "doc_filter4" "doc_filter5"
                         "funct1" "funct2" "funct3" "funct4" "funct5"
                         "funct6" "funct7" "funct8" "funct9" "funct10"
                         "pnl1" "pnl2" "pnl3" "pnl4" "pnl5" "pnl6" "pnl7"
                         "pnl8" "pnl9" "pnl10" "old_dwgno" "barcode"
                         "user" "dos_name" "dos_date" "dos_time"
                         "plot_index" "plot_scale" "work_with"))
)


 ;|AttCollection collects all attribute
information from old (existing) titleblock.|;

(defun attcollection ()
     (setq ssnumblk (ssget "x" (list (cons 2 "TITLE_NUMBER"))))
     (setq ssbordr (ssget "x" (list (cons 2 "BORDER"))))
     (if (setq ss (ssget "x" (list (cons 2 "TITLE_BLOCK"))))
 ;place name of old titleblock in quotes above.
	  (valuelist)
     )
)


 ;|AttReplace replaces all attribute information
from old titleblock to new titleblock.|;

(defun attreplace ()
     (if (setq ssa (ssget "x" (list (cons 2 "TITLE_BLOCK"))))
 ;place name of new titleblock in quotes above.
	 (progn
	  (newvaluelist)
	 (replist)
	  )
     )
)


(defun blockinfo ()
     (setq info	  (ssname ss 0)
	   inlist (entget info)
	   layer  (cdr (assoc 8 inlist))
;	   inspt  (trans (cdr (assoc 10 inlist)) 0 1)
	   rang	  (atof (angtos (cdr (assoc 50 inlist)) 0))
     )
)

;In progress
(defun replist ()
     (entmod (subst ss ssa newattlst))
)


;|routine to extract information from titleblock dlctiaa,
erase and purge it; then replace it with the new version
and replace the former attribute information.|;


(defun c:repblock ()
     (setq clay (getvar "clayer"))
     (attcollection)
     (blockinfo)
     (command ".erase" ssnumblk "" ".purge" "b" "TITLE_NUMBER" "n")
     (command ".erase" ssbordr "" ".purge" "b" "border" "n")
     (command ".erase" ss "" ".purge" "b" "TITLE_BLOCK" "n")
     (setvar "clayer" layer)
	(setq ESIZETTL "DLCTITLE_E")
	(command "-INSERT" (strcat lisp_path_tblk ESIZETTL) "0,0" (GETVAR "DIMSCALE") "" "0")
;     (command ".insert" "DLCTITLE_E" inspt (GETVAR "DIMSCALE") "" rang)
  (COMMAND "EXPLODE" "L")
  (command "-purge" "b" "DLCTITLE_E" "n")
  (command "-rename" "b" "e size" "title_block")
     (attreplace)
     (setvar "clayer" clay)
     (princ)
)