**modified with updates**
For line 5 whenever you're writing a statement and it contains a quote " then you have to precede it with a slash \:
(write-line "(member \"PDF.A1\"(get_pgsetup_lst))" scrFile)
But instead of what you're doing I would include as much as possible inside the single lisp file such as testing if
"PDF.A1" is there or not and if not then bring it in :
PS2A-PageSetup2AllLayout.lsp:
; PS2A-PageSetup2AllLayout.lsp
; name - the Page Setup Name
; dwt - drawing template that contains the page setup name
; all - a flag, T for all nil for current layout
(defun SetNamePageSetupAllLayouts (name dwt all / get_pgsetup_lst lst)
(defun get_pgsetup_lst (/ pgsob1 pgsob2)
(setq pgsob1(cdr(assoc -1(dictsearch(namedobjdict)"ACAD_PlotSettings"))))
(setq pgslst '())
(while (setq pgsob2 (dictnext pgsob1 (not pgsob2)))
(setq pgslst(cons (cdr(assoc 1 pgsob2)) pgslst))
)
(if(> (length pgslst) 1)(setq pgslst (aec_sort_lst pgslst <)))
pgslst
)
; first test to see if pagesetup name is already in dwg
(if(not(member name (get_pgsetup_lst)))
(command "._-PSETUPIN" dwt name) ; if not then insert from template
)
(or adoc (setq adoc (vla-get-ActiveDocument (vlax-get-acad-object))))
(if (vl-position
name
(vlax-for pltcfg (vla-get-plotconfigurations adoc)
(setq lst (cons (vlax-get pltcfg 'Name) lst))
)
)
(progn
(vlax-for layt (vla-get-Layouts adoc)
(if (/= (vla-get-name layt) "Model")
(if all
(vla-copyfrom layt (vla-item (vla-get-PlotConfigurations adoc) name))
(if (= (vla-get-name layt) (getvar 'ctab))
(vla-copyfrom layt (vla-item (vla-get-PlotConfigurations adoc) name))
)
)
)
)
(vla-Regen adoc acActiveViewport)
)
)
)
To call the main function:
; to change to PageSetup eg:"PDF.A1" all layouts
(defun c:PS2A nil
(SetNamePageSetupAllLayouts "PDF.A1" "Yaesu.dwt" T)
(princ)
)
; to change to PageSetup eg:"PDF.A1" just the active layout
(defun c:PA21 nil
(SetNamePageSetupAllLayouts "PDF.A1" "Yaesu.dwt" nil)
(princ)
)
Then the one that writes the script file will just need to include the following lines to load the lisp & run either (c:PS2A) or (c:PS21):
(write-line ".Open" scrFile)
(write-line dwgName scrFile)
(write-line "(load\"PS2A-PageSetup2AllLayout\")" scrFile)
(write-line "(c:PS2A)" scrFile) ; for applying name to all layouts
; (write-line "(c:PS21)" scrFile) ; for applying name to current layouts
(write-line "_.Autopublish " scrFile)
(write-line "(command)" scrFile)
(write-line ".zoom e" scrFile)
(write-line "_.CLOSE _Y " scrFile)
)
(close scrFil)