<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Script (or other automation) to apply page setup to layout in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-or-other-automation-to-apply-page-setup-to-layout/m-p/13161259#M6080</link>
    <description>&lt;P&gt;I run the PS2L lisp and the following window pops up:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="lhaydenWCHJH_0-1732050677094.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1435956i96FC229A1CC4A780/image-size/medium?v=v2&amp;amp;px=400" role="button" title="lhaydenWCHJH_0-1732050677094.png" alt="lhaydenWCHJH_0-1732050677094.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The only way to select UEU is with mouse clicks.&amp;nbsp; Typing UEU or down arrow both do nothing to change which page setup is selected.&amp;nbsp;&amp;nbsp;&amp;nbsp; (I need no mouse input so I can batch apply these across multiple drawings)&amp;nbsp; Perhaps I'm missing some step here, or I need a different function.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 19 Nov 2024 21:23:30 GMT</pubDate>
    <dc:creator>lhaydenWCHJH</dc:creator>
    <dc:date>2024-11-19T21:23:30Z</dc:date>
    <item>
      <title>Script (or other automation) to apply page setup to layout</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-or-other-automation-to-apply-page-setup-to-layout/m-p/13160995#M6074</link>
      <description>&lt;P&gt;Howdy All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm pretty new to automating CAD tasks, so I've been scouring forums and other corners of the internet trying to create a script to select and apply a different page setup in my paperspace layout.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Backstory: Many of my drawings have PDF or None as the current page setup. I need to apply the already-loaded page setup "UEU" to be the current page setup for my active layout.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The following keystrokes work when I type them into my command line.&amp;nbsp;&lt;/P&gt;&lt;P&gt;pagesetup&lt;/P&gt;&lt;P&gt;u; selecting the page setup I want, based on the first letter of the setup name&lt;/P&gt;&lt;P&gt;alt+s; set current&lt;/P&gt;&lt;P&gt;alt+c; close&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I attempt to run this as a script, the popup window opens but does not highlight the appropriate page setup and thusly hangs up the rest of the script.&amp;nbsp; --After fixing the page setup selection, I'll need to figure out how to write alt+ into a script... but that's next step.--&amp;nbsp; &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried recording these steps as a macro but replay also hangs up after opening the page setup manager window.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried inserting and redefining the page setup from another file, but it didn't apply the new setup as current.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried various lisps and scripts from forums/chatgpt, but these have only returned errors.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Anyone have a suggestion of what to try next?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Nov 2024 18:55:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-or-other-automation-to-apply-page-setup-to-layout/m-p/13160995#M6074</guid>
      <dc:creator>lhaydenWCHJH</dc:creator>
      <dc:date>2024-11-19T18:55:09Z</dc:date>
    </item>
    <item>
      <title>Re: Script (or other automation) to apply page setup to layout</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-or-other-automation-to-apply-page-setup-to-layout/m-p/13161040#M6075</link>
      <description>&lt;P&gt;try this ps2lay.lsp from Lee Mac:&lt;/P&gt;&lt;P&gt;&lt;A href="https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/apply-page-setup-to-multiple-layouts/m-p/4653905/highlight/true#M317293" target="_blank"&gt;https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/apply-page-setup-to-multiple-layouts/m-p/4653905/highlight/true#M317293&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Nov 2024 19:18:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-or-other-automation-to-apply-page-setup-to-layout/m-p/13161040#M6075</guid>
      <dc:creator>paullimapa</dc:creator>
      <dc:date>2024-11-19T19:18:09Z</dc:date>
    </item>
    <item>
      <title>Re: Script (or other automation) to apply page setup to layout</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-or-other-automation-to-apply-page-setup-to-layout/m-p/13161092#M6076</link>
      <description>&lt;P&gt;Thanks for the suggestion. Unfortunately, this solution gets me stuck in a page setup selection window which I cannot edit or trigger via command line. So, similar to what I've run into with other attempts.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Nov 2024 19:56:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-or-other-automation-to-apply-page-setup-to-layout/m-p/13161092#M6076</guid>
      <dc:creator>lhaydenWCHJH</dc:creator>
      <dc:date>2024-11-19T19:56:11Z</dc:date>
    </item>
    <item>
      <title>Re: Script (or other automation) to apply page setup to layout</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-or-other-automation-to-apply-page-setup-to-layout/m-p/13161106#M6077</link>
      <description>&lt;P&gt;Did you try the other one called Test that's on the same thread:&lt;/P&gt;&lt;P&gt;&lt;A href="https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/apply-page-setup-to-multiple-layouts/m-p/4651451/highlight/true#M317264" target="_blank"&gt;https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/apply-page-setup-to-multiple-layouts/m-p/4651451/highlight/true#M317264&lt;/A&gt;&lt;/P&gt;&lt;P&gt;What you enter is case sensitive &amp;amp; I did make one minor modification to allow for pagesetup names entries with a space and I'm calling this one Ps2L.lsp&lt;/P&gt;&lt;LI-CODE lang="general"&gt;; Ps2L.lsp type pagesetup name to assign to layouts (case sensitive)
; https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/apply-page-setup-to-multiple-layouts/m-p/4651451/highlight/true#M317264
(defun C:Ps2L (/ page_setup config l)
  (vl-load-com)
  (or acDoc (setq acDoc (vla-get-activedocument (vlax-get-acad-object))))
  (princ "\n************************************\n")
  (if
    (and
      (&amp;gt; (vla-get-Count (setq page_setup (vla-get-plotconfigurations acDoc))) 0)
      (vlax-for a page_setup (princ (strcat "\n" (car (setq l (cons (vla-get-name a) l))))))
      (not (textscr))
      (member (setq config (getstring T "\nSelect page setup: ")) l)
      )
     (vlax-for layout (vla-get-layouts acDoc)
       (if (not (eq (strcase (vla-get-name layout)) "MODEL"))
         (vla-copyfrom layout (vla-item page_setup config))
         )
       )
    )
;;;  (vla-regen acDoc acAllViewPorts)
  (graphscr)
  (princ)
  )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Nov 2024 20:04:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-or-other-automation-to-apply-page-setup-to-layout/m-p/13161106#M6077</guid>
      <dc:creator>paullimapa</dc:creator>
      <dc:date>2024-11-19T20:04:41Z</dc:date>
    </item>
    <item>
      <title>Re: Script (or other automation) to apply page setup to layout</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-or-other-automation-to-apply-page-setup-to-layout/m-p/13161198#M6078</link>
      <description>&lt;P&gt;Same error.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Nov 2024 20:49:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-or-other-automation-to-apply-page-setup-to-layout/m-p/13161198#M6078</guid>
      <dc:creator>lhaydenWCHJH</dc:creator>
      <dc:date>2024-11-19T20:49:55Z</dc:date>
    </item>
    <item>
      <title>Re: Script (or other automation) to apply page setup to layout</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-or-other-automation-to-apply-page-setup-to-layout/m-p/13161241#M6079</link>
      <description>&lt;P&gt;Please elaborate what is the error message you're getting.&lt;/P&gt;&lt;P&gt;I tested the code on the attached &lt;STRONG&gt;PSM&amp;nbsp; Demo Dwg.dwg&lt;/STRONG&gt; file.&lt;/P&gt;&lt;P&gt;Before running the function my current layouts with their page setups were:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="paullimapa_0-1732049877847.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1435944i6E6DDA8ACBFD2682/image-size/medium?v=v2&amp;amp;px=400" role="button" title="paullimapa_0-1732049877847.png" alt="paullimapa_0-1732049877847.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Then at the command line I enter the following to load the lisp function:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;(load"Ps2L")&lt;/LI-CODE&gt;&lt;P&gt;At the command line I then enter:&lt;/P&gt;&lt;P&gt;Command: &lt;STRONG&gt;Ps2L&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;The Text screen window appears listing the Pagesetups available for me to type in:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="paullimapa_1-1732049984806.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1435948i15BF4A5753F9615F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="paullimapa_1-1732049984806.png" alt="paullimapa_1-1732049984806.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;After entering:&amp;nbsp;&lt;STRONG&gt;PDF-ANSI C&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I enter command &lt;STRONG&gt;PAGESETUP&lt;/STRONG&gt; and I see all the layouts have been changed to that setup:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="paullimapa_2-1732050061889.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1435949iD1B206A21A64B93C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="paullimapa_2-1732050061889.png" alt="paullimapa_2-1732050061889.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Nov 2024 21:03:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-or-other-automation-to-apply-page-setup-to-layout/m-p/13161241#M6079</guid>
      <dc:creator>paullimapa</dc:creator>
      <dc:date>2024-11-19T21:03:34Z</dc:date>
    </item>
    <item>
      <title>Re: Script (or other automation) to apply page setup to layout</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-or-other-automation-to-apply-page-setup-to-layout/m-p/13161259#M6080</link>
      <description>&lt;P&gt;I run the PS2L lisp and the following window pops up:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="lhaydenWCHJH_0-1732050677094.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1435956i96FC229A1CC4A780/image-size/medium?v=v2&amp;amp;px=400" role="button" title="lhaydenWCHJH_0-1732050677094.png" alt="lhaydenWCHJH_0-1732050677094.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The only way to select UEU is with mouse clicks.&amp;nbsp; Typing UEU or down arrow both do nothing to change which page setup is selected.&amp;nbsp;&amp;nbsp;&amp;nbsp; (I need no mouse input so I can batch apply these across multiple drawings)&amp;nbsp; Perhaps I'm missing some step here, or I need a different function.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Nov 2024 21:23:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-or-other-automation-to-apply-page-setup-to-layout/m-p/13161259#M6080</guid>
      <dc:creator>lhaydenWCHJH</dc:creator>
      <dc:date>2024-11-19T21:23:30Z</dc:date>
    </item>
    <item>
      <title>Re: Script (or other automation) to apply page setup to layout</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-or-other-automation-to-apply-page-setup-to-layout/m-p/13161282#M6081</link>
      <description>&lt;P&gt;Looks like you have another lisp file that has the exact same name but runs a completely different function.&lt;/P&gt;&lt;P&gt;To avoid this problem I've created a different function called &lt;STRONG&gt;TestMe.lsp&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Save the attached &amp;amp; to load drag &amp;amp; drop it into your drawing area or execute the following at the command prompt:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;(load"TestMe")&lt;/LI-CODE&gt;&lt;P&gt;Then to execute this lisp function enter at the command prompt:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;TestMe&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;You should not be getting any popup windows for you to select from.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Nov 2024 21:22:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-or-other-automation-to-apply-page-setup-to-layout/m-p/13161282#M6081</guid>
      <dc:creator>paullimapa</dc:creator>
      <dc:date>2024-11-19T21:22:41Z</dc:date>
    </item>
    <item>
      <title>Re: Script (or other automation) to apply page setup to layout</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-or-other-automation-to-apply-page-setup-to-layout/m-p/13161293#M6082</link>
      <description>&lt;P&gt;Company policy won't allow me to download this .lsp.&amp;nbsp;&amp;nbsp; Can you paste the code to this conversation?&lt;/P&gt;</description>
      <pubDate>Tue, 19 Nov 2024 21:27:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-or-other-automation-to-apply-page-setup-to-layout/m-p/13161293#M6082</guid>
      <dc:creator>lhaydenWCHJH</dc:creator>
      <dc:date>2024-11-19T21:27:25Z</dc:date>
    </item>
    <item>
      <title>Re: Script (or other automation) to apply page setup to layout</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-or-other-automation-to-apply-page-setup-to-layout/m-p/13161301#M6083</link>
      <description>&lt;P&gt;sure...similar as before but just changed the function name to &lt;STRONG&gt;TestMe&lt;/STRONG&gt;:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;; TestMe.lsp type pagesetup name to assign to layouts (case sensitive)
; https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/apply-page-setup-to-multiple-layouts/m-p/4651451/highlight/true#M317264
(defun C:TestMe (/ page_setup config l)
  (vl-load-com)
  (or acDoc (setq acDoc (vla-get-activedocument (vlax-get-acad-object))))
  (princ "\n************************************\n")
  (if
    (and
      (&amp;gt; (vla-get-Count (setq page_setup (vla-get-plotconfigurations acDoc))) 0)
      (vlax-for a page_setup (princ (strcat "\n" (car (setq l (cons (vla-get-name a) l))))))
      (not (textscr))
      (member (setq config (getstring T "\nSelect page setup: ")) l)
      )
     (vlax-for layout (vla-get-layouts acDoc)
       (if (not (eq (strcase (vla-get-name layout)) "MODEL"))
         (vla-copyfrom layout (vla-item page_setup config))
         )
       )
    )
;;;  (vla-regen acDoc acAllViewPorts)
  (graphscr)
  (princ)
  )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Nov 2024 21:30:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-or-other-automation-to-apply-page-setup-to-layout/m-p/13161301#M6083</guid>
      <dc:creator>paullimapa</dc:creator>
      <dc:date>2024-11-19T21:30:39Z</dc:date>
    </item>
    <item>
      <title>Re: Script (or other automation) to apply page setup to layout</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-or-other-automation-to-apply-page-setup-to-layout/m-p/13161345#M6084</link>
      <description>&lt;P&gt;This test file worked so I closed my autocad to reset all lisps. After that, your PS2L lisp worked like a charm.&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks ever so much for your help!&lt;/P&gt;</description>
      <pubDate>Tue, 19 Nov 2024 21:46:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-or-other-automation-to-apply-page-setup-to-layout/m-p/13161345#M6084</guid>
      <dc:creator>lhaydenWCHJH</dc:creator>
      <dc:date>2024-11-19T21:46:20Z</dc:date>
    </item>
    <item>
      <title>Re: Script (or other automation) to apply page setup to layout</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-or-other-automation-to-apply-page-setup-to-layout/m-p/13161353#M6085</link>
      <description>&lt;P&gt;glad to have helped...cheers!!!&lt;/P&gt;</description>
      <pubDate>Tue, 19 Nov 2024 21:50:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-or-other-automation-to-apply-page-setup-to-layout/m-p/13161353#M6085</guid>
      <dc:creator>paullimapa</dc:creator>
      <dc:date>2024-11-19T21:50:10Z</dc:date>
    </item>
    <item>
      <title>Re: Script (or other automation) to apply page setup to layout</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-or-other-automation-to-apply-page-setup-to-layout/m-p/13162961#M6086</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1137264"&gt;@paullimapa&lt;/a&gt;Thanks for editing my lisp. Anyway, selecting the page setup by typing is not such a good idea, so I updated the lisp.&lt;/P&gt;&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/13118824"&gt;@lhaydenWCHJH&lt;/a&gt;If the lisp works after restarting, it might be in conflict with other lisp. I guess is the acDoc variable. I've seen it used as a function in some other lisp programs.&lt;/P&gt;&lt;P&gt;Attached is the updated version. It allows to apply the same settings to all the layouts, but now you have the option to select a Layout as the source or a predefined page setup. Page setup, even with it's advantages, might not be so commonly used.&lt;/P&gt;&lt;P&gt;When the lisp displays the available sources, select one by picking it from the list or type the number associated with it (the number displayed as prefix).&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="phanaem_0-1732108938698.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1436324i290ABE70BB8D201A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="phanaem_0-1732108938698.png" alt="phanaem_0-1732108938698.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If needed, I think it could be modified to select the destination layouts. For now, the setup is applied to ALL layouts.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="lisp"&gt;; Apply plot configuration to all layouts 
; Stefan M.
; 26.11.2013 https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/apply-page-setup-to-multiple-layouts/m-p/4651451/highlight/true#M317264
; updated 20.11.2024

(defun C:SetPlot (/ *error* acDoc srtm dyn msg plot_config config config_list layout_source)
  (vl-load-com)
  (setq acDoc (vla-get-activedocument (vlax-get-acad-object)))

  (if (= 8 (logand 8 (getvar 'undoctl))) (vla-endundomark acDoc))
  (vla-startundomark acDoc)
  
  (setq srtm (getvar 'shortcutmenu))
  (setq dyn (getvar 'dynmode))

  (setvar 'shortcutmenu 8)
  (setvar 'dynmode 3)

  (defun *error* (msg)
    (if msg
      (progn
        (if
          (not (wcmatch (strcase msg) "*EXIT*,*CANCEL*,*ABORT*"))
          (princ (strcat "\nERROR: " msg))
        )
      )
    )
    (setvar 'shortcutmenu srtm)
    (setvar 'dynmode dyn)
    (if (= 8 (logand 8 (getvar 'undoctl))) (vla-endundomark acDoc))
    (princ)
  )

  (or *source* (setq *source* "Layout"))

  (initget "Layout Pagesetup")

  (setq *source* (cond
                   ((getkword (strcat "\nSpecify plot setup source [Layout/Pagesetup] &amp;lt; " *source* "&amp;gt;: ")))
                   (*source*)
                 )
  )

  (cond
    ((eq *source* "Pagesetup")
     (if
       (and
         (setq msg "\nNo plotting configurations found.")
         (&amp;gt; (vla-get-Count (setq plot_config (vla-get-plotconfigurations acDoc))) 0)
         (progn
           (vlax-for a plot_config
             (if
               (eq (vla-get-modeltype a) :vlax-false)
               (setq config_list (cons (vla-get-name a) config_list))
             )
           )
           config_list
         )
         (setq msg "\nPlot configuration not selected.")
         (setq config (_select_from_list "Select page setup: " config_list))
         (setq config (vla-item page_setup config))
       )
       (progn
         (vlax-for layout (vla-get-layouts acDoc)
           (if
             (not (eq (strcase (vla-get-name layout)) "MODEL"))
             (vla-copyfrom layout config)
           )
         )
         (vla-regen acdoc acactiveviewport)
       )
       (if msg (princ msg))
     )
    )
    ((eq *source* "Layout")
     (if
       (and
         (setq msg "\nSource layout not selected.")
         (setq layout_source (_select_from_list "Select page setup: " (layoutlist)))
         (setq config (vla-item (vla-get-layouts acDoc) layout_source))
       )
       (progn
         (foreach layout (layoutlist)
           (if
             (not (eq layout layout_source))
             (vla-copyfrom (vla-item (vla-get-layouts acDoc) layout) config)
           )
         )
         (vla-regen acdoc acactiveviewport)
       )
       (if msg (princ msg))
     )
    )
  )

  (*error* nil)
  (princ)
)

;Select an item from a popup menu
(defun _select_from_list (msg lst / strcat_list k i ini_list opt_list)

  (defun strcat_list (lst sep)
    (apply 'strcat
      (mapcar 'strcat
        (cons "" (mapcar '(lambda (x) sep) (cdr lst)))
        lst
      )
    )
  )
  
  (repeat (setq i (length lst))
    (setq ini_list (cons (itoa (setq i (1- i))) ini_list))
  )

  (setq opt_list (mapcar
                   '(lambda (a b)
                      (strcat a " " b)
                    )
                   ini_list
                   lst
                 )
  )

  (initget (strcat_list ini_list " "))
  (setq k (getkword (strcat "\n" msg " [" (strcat_list opt_list "/") "]: ")))

  (if k
    (nth (vl-position k ini_list) lst)
  )
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Nov 2024 13:31:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-or-other-automation-to-apply-page-setup-to-layout/m-p/13162961#M6086</guid>
      <dc:creator>phanaem</dc:creator>
      <dc:date>2024-11-20T13:31:45Z</dc:date>
    </item>
  </channel>
</rss>

