This is when I wish there was a remove post.
Sorry I did not read your post well enough. Mine will just copy the layouts.
I did that not too long ago for someone.
Try this.
;;; ==============================================================================
;;; Lisp Name: foo.lsp
;;; Author: Lonnie
;;; Date Created: 2024-07-02
;;; Last Edited: [Insert Last Edit Date]
;;;
;;; DESCRIPTION:
;;; A routine to set up page configurations by importing them from a specified DWG file.
;;;
;;; Usage:
;;; 1. Load the Lisp routine.
;;; 2. Run the command "foo" in AutoCAD.
;;;
;;; Parameters:
;;; None explicitly, but internally uses the DWG path and page setup name.
;;;
;;; Returns:
;;; None
;;;
;;; Notes:
;;; - This routine imports the "3624 PDF" page setup from the specified DWG file
;;; ("x:\\xx\\Page Setups.dwg") and applies it to the current drawing.
;;;
;;; Related URL:
;;; https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/copy-objects-in-one-dwg-files-with-lots-of-layouts-sheets/td-p/12949888
;;; https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/set-a-page-setup-current-with-lsp/td-p/12917953
;;;
;;; ---------------------------- Main Program --------------------------------
(defun C:foo ()
(command "._-PSETUPIN" "x:\\xx\\Page Setups.dwg" "3624 PDF")
(vlax-for x
(vla-get-plotconfigurations
(setq d (vla-get-activedocument (vlax-get-acad-object))))
(if (= (strcase "3624 PDF") (strcase (vla-get-name x)))
(vl-catch-all-apply 'vla-copyfrom (list (vla-get-activelayout d) x))
)
)
)
When I made that I kept messing up on the names so I created this one to list all the names.
(defun C:3624PageSetup ()
(command "._-PSETUPIN" "x:\\xx\\trash1.dwg" "3624 PDF")
(defun lm:psetup2tab (/ d found setup-list)
(setq found nil) ; Initialize a variable to track if the page setup is found
(setq setup-list "") ; Initialize a string to collect page setup names
(vlax-for x (vla-get-plotconfigurations
(setq d (vla-get-activedocument (vlax-get-acad-object))))
(setq setup-list (strcat setup-list (vla-get-name x) "\n")) ; Append each page setup name to setup-list
(if (= (strcase "3624 PDF") (strcase (vla-get-name x)))
(progn
(setq found T) ; Set found to true if the page setup is found
(vl-catch-all-apply 'vla-copyfrom (list (vla-get-activelayout d) x))
)
)
)
(if (not found) ; If the page setup is not found, display an alert
(alert (strcat "The page setup '3624 PDF' was not found.\nAvailable page setups:\n" setup-list))
)
)
(lm:psetup2tab)
)