@jtm2020hyo wrote:
request for one lisp to export layout names to .csv, edit .csv, then import that .csv to rename layouts with another lisp.
Instead of csv I'll use txt file. Here you got two functions.
Function LAY_TO_TXT writes out all layouts to txt file you chose and at the end open that txt file to notepad
After you finish renaming layouts save it and close,
Start command LAY_FROM_TXT to apply those changes you have made.
Warning: Retain layer sequence, don't delete any name, and leave MODEL where it is.
Text file will remain in directory you have created it, but you can use it to rewrite, and apply changes in some other document. First all layer names out to file, then apply changes.
(defun c:lay_to_txt ( / app doc layouts f file name *error*)
;write layout names to csw
(defun *error* () (close file) (princ))
(vl-load-com)
(setq
app (vlax-get-acad-object)
doc (vla-get-activedocument app)
layouts (vla-get-layouts doc)
f (getfiled "Open File to write layout names" (getvar "dwgprefix") "txt" 3)
file (open f "w")
)
(vlax-for lay layouts(write-line (vla-get-name lay) file))
(close file)
(startapp "notepad" f)
(princ)
)
(defun c:lay_from_txt ( / app doc layouts f file old_name new_name *error*)
(defun *error* () (close file) (princ))
;write layout names to csw
(vl-load-com)
(setq
app (vlax-get-acad-object)
doc (vla-get-activedocument app)
layouts (vla-get-layouts doc)
f (getfiled "Open File to read new layout names" (getvar "dwgprefix") "txt" 2)
file (open f "r")
)
(vlax-for lay layouts
(setq
old_name (vla-get-name lay)
new_name (read-line file)
)
(if (not (eq "MODEL" (strcase old_name)))
(vla-put-name lay new_name)
)
)
(close file)
(princ)
)
Usage:
lay_to_text
Layout1
Layout2
Model
Rename layouts
New layout name 1
New layout name 2
Model
Miljenko Hatlak

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.