<?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: rename/copy/switch to next layout tab lisp help in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/rename-copy-switch-to-next-layout-tab-lisp-help/m-p/8092440#M103147</link>
    <description>&lt;P&gt;So walk me through this&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;(command
  "_.layout" "_rename" "" (lisped (getvar 'ctab))
  "_.layout" "_copy" "" (setq new (lisped (getvar 'ctab)))
)
(setvar 'ctab new)&lt;/PRE&gt;&lt;P&gt;this is taking and renaming the current layout with the variable 'ctab&amp;nbsp;&lt;BR /&gt;then doing a copy and naming the new sheet the variable new which is the same as ctab? or is that a second input?&amp;nbsp;&lt;BR /&gt;could i change it to (setq new ("newlayout")) to set a standard name for the new layout tab as "newlayout"&amp;nbsp;&lt;BR /&gt;then&amp;nbsp;command "CTAB" runs after to look like this?&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;(command
  "_.layout" "_rename" "" (lisped (getvar 'ctab))
  "_.layout" "_copy" "" (setq new ("NewLayout"))
  "ctab" new
)
(setvar 'ctab new)&lt;/PRE&gt;&lt;P&gt;this will allow you to rename the current tab, then moves you to a copy of this tab (named NewLayout)&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;right? maybe? nope?&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 26 Jun 2018 15:41:04 GMT</pubDate>
    <dc:creator>dwattersAMXH5</dc:creator>
    <dc:date>2018-06-26T15:41:04Z</dc:date>
    <item>
      <title>rename/copy/switch to next layout tab lisp help</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/rename-copy-switch-to-next-layout-tab-lisp-help/m-p/8092253#M103144</link>
      <description>&lt;P&gt;hello,&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I am currently working on a lisp to automate three tasks&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;1- rename current layout tab&amp;nbsp;&lt;BR /&gt;2- copy layout tab (to end)&lt;/P&gt;&lt;P&gt;3-switch to last layout tab&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;here is where i am at so far -&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;(DEFUN C:RRT2 ()

 (command "-layout" "rename" "" (getstring T "\nEnter new name for current layout")))
 (princ)

)&lt;/PRE&gt;&lt;P&gt;i know how to get the sheet to rename through the lisp, but the next part of&amp;nbsp;&lt;BR /&gt;1- adding in the next command :&lt;/P&gt;&lt;PRE&gt;(command "-layout" "copy" "" "") &lt;/PRE&gt;&lt;P&gt;2- the set command (i know it should look something like this):&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;(command "ctab" "(the last sheet)" ) &lt;/PRE&gt;&lt;P&gt;but i'm not positive on setting that "the last sheet" variable. this maybe?&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;(cadr (member (getvar 'CTAB) (layoutlist)))&lt;/PRE&gt;&lt;P&gt;So that leaves me here&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;(DEFUN C:RCS ()

 (command "-layout" "rename" "" (getstring T "\nEnter new name for current layout")))
 (princ)
 (command "-layout" "copy" "" "" "ctab" (cadr (member (getvar  'CTAB) (layoutlist))) 
)&lt;/PRE&gt;&lt;P&gt;the lisp runs the first part (renaming) but fails to run the rest,&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;new to writing lisps here, what am i doing wrong?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jun 2018 14:38:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/rename-copy-switch-to-next-layout-tab-lisp-help/m-p/8092253#M103144</guid>
      <dc:creator>dwattersAMXH5</dc:creator>
      <dc:date>2018-06-26T14:38:25Z</dc:date>
    </item>
    <item>
      <title>Re: rename/copy/switch to next layout tab lisp help</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/rename-copy-switch-to-next-layout-tab-lisp-help/m-p/8092354#M103145</link>
      <description>&lt;P&gt;I'd do it this way [minimally tested]:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(command
  "_.layout" "_rename" "" (lisped (getvar 'ctab))
  "_.layout" "_copy" "" (lisped (getvar 'ctab))
)
(setvar 'ctab &lt;STRIKE&gt;(last (layoutlist)))&lt;/STRIKE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The (lisped) function populates a text-edit box with the current name, so you can, for instance, just change a character or two, or add a little at the beginning or end, without having to re-type the rest of the Layout name, though you can also just replace it wholesale if you don't want to keep any of it.&amp;nbsp; It returns what you end up with for use by the Layout commands.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRIKE&gt;The new one becomes the last item in the list returned by (layoutlist), which makes that part pretty easy.&lt;/STRIKE&gt;&amp;nbsp; I did it with (setvar) above [because System Variable names can be used &lt;EM&gt;like&lt;/EM&gt;&amp;nbsp; command names, but they're not really], but you can do it in the (command) function if you prefer:&lt;/P&gt;
&lt;PRE&gt;(command
  "_.layout" "_rename" "" (lisped (getvar 'ctab))
  "_.layout" "_copy" "" (lisped (getvar 'ctab))
  "_.ctab" &lt;STRIKE&gt;(last (layoutlist))&lt;/STRIKE&gt;
)
&lt;/PRE&gt;
&lt;P&gt;[even though I find that a manual&amp;nbsp;&lt;EM&gt;command-line&lt;/EM&gt;&amp;nbsp; CTAB command won't accept (last (layoutlist)) as input!].&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#ff6600"&gt;&lt;STRONG&gt;EDIT:&lt;/STRONG&gt;&lt;/FONT&gt;&amp;nbsp; Whoops -- now I find the new one &lt;EM&gt;isn't&lt;/EM&gt;&amp;nbsp; necessarily always the last in (layoutlist) as it was in my first trials.&amp;nbsp; Let's try this instead:&lt;/P&gt;
&lt;PRE&gt;(command
  "_.layout" "_rename" "" (lisped (getvar 'ctab))
  "_.layout" "_copy" "" &lt;FONT color="#ff0000"&gt;(setq new&lt;/FONT&gt; (lisped (getvar 'ctab))&lt;FONT color="#ff0000"&gt;)&lt;/FONT&gt;
)
(setvar 'ctab &lt;FONT color="#ff0000"&gt;new&lt;/FONT&gt;)&lt;/PRE&gt;</description>
      <pubDate>Tue, 26 Jun 2018 15:17:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/rename-copy-switch-to-next-layout-tab-lisp-help/m-p/8092354#M103145</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2018-06-26T15:17:42Z</dc:date>
    </item>
    <item>
      <title>Re: rename/copy/switch to next layout tab lisp help</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/rename-copy-switch-to-next-layout-tab-lisp-help/m-p/8092437#M103146</link>
      <description>&lt;P&gt;Here is also a way to set the last tab current if you don't know what the name is.&lt;/P&gt;&lt;PRE&gt;;; Load ActiveX
(vl-load-com)
(vlax-for tab (vla-get-layouts (vla-get-activedocument (vlax-get-acad-object)))
  (if (= (length (layoutlist)) (vla-get-taborder tab))
    (setvar 'ctab (vla-get-name tab))
  )
)&lt;/PRE&gt;</description>
      <pubDate>Tue, 26 Jun 2018 15:36:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/rename-copy-switch-to-next-layout-tab-lisp-help/m-p/8092437#M103146</guid>
      <dc:creator>ronjonp</dc:creator>
      <dc:date>2018-06-26T15:36:54Z</dc:date>
    </item>
    <item>
      <title>Re: rename/copy/switch to next layout tab lisp help</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/rename-copy-switch-to-next-layout-tab-lisp-help/m-p/8092440#M103147</link>
      <description>&lt;P&gt;So walk me through this&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;(command
  "_.layout" "_rename" "" (lisped (getvar 'ctab))
  "_.layout" "_copy" "" (setq new (lisped (getvar 'ctab)))
)
(setvar 'ctab new)&lt;/PRE&gt;&lt;P&gt;this is taking and renaming the current layout with the variable 'ctab&amp;nbsp;&lt;BR /&gt;then doing a copy and naming the new sheet the variable new which is the same as ctab? or is that a second input?&amp;nbsp;&lt;BR /&gt;could i change it to (setq new ("newlayout")) to set a standard name for the new layout tab as "newlayout"&amp;nbsp;&lt;BR /&gt;then&amp;nbsp;command "CTAB" runs after to look like this?&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;(command
  "_.layout" "_rename" "" (lisped (getvar 'ctab))
  "_.layout" "_copy" "" (setq new ("NewLayout"))
  "ctab" new
)
(setvar 'ctab new)&lt;/PRE&gt;&lt;P&gt;this will allow you to rename the current tab, then moves you to a copy of this tab (named NewLayout)&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;right? maybe? nope?&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jun 2018 15:41:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/rename-copy-switch-to-next-layout-tab-lisp-help/m-p/8092440#M103147</guid>
      <dc:creator>dwattersAMXH5</dc:creator>
      <dc:date>2018-06-26T15:41:04Z</dc:date>
    </item>
    <item>
      <title>Re: rename/copy/switch to next layout tab lisp help</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/rename-copy-switch-to-next-layout-tab-lisp-help/m-p/8092475#M103148</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5054491"&gt;@dwattersAMXH5&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;So walk me through this&amp;nbsp;&lt;BR /&gt;....&lt;/P&gt;
&lt;P&gt;this is taking and renaming the current layout with the variable 'ctab&amp;nbsp;&lt;BR /&gt;then doing a copy and naming the new sheet the variable new which is the same as ctab? or is that a second input?&amp;nbsp;&lt;BR /&gt;could i change it to (setq new ("newlayout")) to set a standard name for the new layout tab as "newlayout"&amp;nbsp;&lt;BR /&gt;then&amp;nbsp;command "CTAB" runs after to look like this?&amp;nbsp;&lt;BR /&gt;....&lt;/P&gt;
&lt;P&gt;this will allow you to rename the current tab, then moves you to a copy of this tab (named NewLayout)&amp;nbsp;&lt;BR /&gt;right? maybe? nope?&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Not quite.&amp;nbsp; It's not renaming the current Layout, nor the new copy, with &lt;EM&gt;the variable 'ctab&lt;/EM&gt;, but rather with &lt;STRONG&gt;&lt;EM&gt;what is returned by the (lisped) function&lt;/EM&gt;&lt;/STRONG&gt; -- the 'ctab is just&amp;nbsp;pre-populating the text-editing box for you with the current name, in case what you want will be a minor modification of that.&amp;nbsp; If it would always be wholly different, you could go back to using (getstring).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your revision looks like it should work [I didn't try it] if you &lt;EM&gt;remove the parentheses&lt;/EM&gt;&amp;nbsp; around "NewLayout":&lt;/P&gt;
&lt;P&gt;(setq new "NewLayout")&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jun 2018 15:53:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/rename-copy-switch-to-next-layout-tab-lisp-help/m-p/8092475#M103148</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2018-06-26T15:53:43Z</dc:date>
    </item>
    <item>
      <title>Re: rename/copy/switch to next layout tab lisp help</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/rename-copy-switch-to-next-layout-tab-lisp-help/m-p/8092503#M103149</link>
      <description>&lt;P&gt;THANK YOU!&amp;nbsp;&lt;BR /&gt;works great!&lt;BR /&gt;&lt;BR /&gt;attached is a copy of the lisp for anyone in the future&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;RCS : Rename,Copy,Set layout&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jun 2018 16:00:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/rename-copy-switch-to-next-layout-tab-lisp-help/m-p/8092503#M103149</guid>
      <dc:creator>dwattersAMXH5</dc:creator>
      <dc:date>2018-06-26T16:00:51Z</dc:date>
    </item>
  </channel>
</rss>

