<?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: Saveas lisp, subfolder in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/saveas-lisp-subfolder/m-p/6724725#M126041</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3794662"&gt;@andreas7ZYXQ&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;....&lt;BR /&gt;I would like to start my routine with save as in a subfolder where the curent drawings is saved.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;after this routine i want to add various things so it has to be "opened" as i[t] normally does when pressing save as in the file tab...&lt;BR /&gt;....&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I assume you mean a subfolder &lt;EM&gt;under&lt;/EM&gt; the one in which the current drawing is located, not the &lt;EM&gt;same&lt;/EM&gt; subfolder in which it is, as &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/450014"&gt;@Shneuph&lt;/a&gt;&amp;nbsp;appears to have assumed. &amp;nbsp;There's no need to have to spell out a subfolder name, nor check whether it exists [whether because it hasn't been made yet or you mis-typed it].&amp;nbsp; You can do this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(defun C:DOSTUFF (/ some local variables)
  (... do some initial stuff ...)
  &lt;FONT color="#0000ff"&gt;&lt;STRONG&gt;(initdia)&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT color="#33cccc"&gt;; &lt;FONT color="#0000ff"&gt;INIT&lt;/FONT&gt;iate the &lt;FONT color="#0000ff"&gt;DIA&lt;/FONT&gt;log box for the following command&lt;/FONT&gt;
  &lt;STRONG&gt;&lt;FONT color="#0000ff"&gt;(command "_.saveas")&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT color="#33cccc"&gt;; do &lt;FONT color="#ff6600"&gt;all you need to do&lt;/FONT&gt; in the dialog box&lt;/FONT&gt;
  (... do more stuff ...)
  (... do more other stuff ...)
  (princ)
); defun&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The (initdia) is needed because without it, commands called in a (command) function use the command-line version.&amp;nbsp; The &lt;FONT color="#ff6600"&gt;all you need to do&lt;/FONT&gt; part &lt;EM&gt;includes&lt;/EM&gt; the options of picking on an existing subfolder if there is one [no risk of typing its name incorrectly], just entering a new drawing name if you want it in the &lt;EM&gt;same&lt;/EM&gt; folder the starting drawing is in, right-clicking in the list of drawings and picking New&amp;nbsp;&amp;gt; Folder if you need to make one that doesn't exist yet, navigating to somewhere entirely unrelated if that's what you need, etc., etc.&amp;nbsp; Since it's operating through the dialog box, there's no need to do the wait-for-input-until-the-command-is-done thing that you typically do with a command in which you don't know the amount of inputs the User will need to provide, in command-line mode.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I &lt;EM&gt;wasn't&lt;/EM&gt; sure this approach would work, because I had always heard that an AutoLisp routine can't start in one drawing and continue in another, but I tried it, and in this case it &lt;EM&gt;does&lt;/EM&gt;, presumably because SAVEAS &lt;EM&gt;moves you into&lt;/EM&gt; the new drawing, and the starting one doesn't remain active. &amp;nbsp;[I think an example of what &lt;EM&gt;wouldn't&lt;/EM&gt; work would be with an OPEN command, in which case the drawing you start the routine in &lt;EM&gt;is&lt;/EM&gt; still active, but I haven't tested the theory].&amp;nbsp; I did the following&amp;nbsp;as a completely arbitrary test:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(defun C:TEST ()
  (initdia)
  (command "_.saveas")
  (command "_.circle" (getvar 'viewctr) 10)
  (command "_.move" "_last" "" "0,5" "")
)&lt;/PRE&gt;
&lt;P&gt;and sure enough, when I ran the TEST command, I got to save a new drawing, was taken into it, and it &lt;EM&gt;did&lt;/EM&gt; draw a 10-radius Circle in the middle of the screen, and Moved&amp;nbsp;it up 5 units.&amp;nbsp; So it &lt;EM&gt;will&lt;/EM&gt; take you into the new drawing and continue with your "add various things" part.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 02 Dec 2016 18:33:12 GMT</pubDate>
    <dc:creator>Kent1Cooper</dc:creator>
    <dc:date>2016-12-02T18:33:12Z</dc:date>
    <item>
      <title>Saveas lisp, subfolder</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/saveas-lisp-subfolder/m-p/6724339#M126039</link>
      <description>&lt;P&gt;Im looking for a Saveas lisp to run.&amp;nbsp;&lt;BR /&gt;i have searched throught various posts but i cant find anything to work.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I would like to start my routine with save as in a subfolder where the curent drawings is saved.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;after this routine i want to add various things so it has to be "opened" as i normally does when pressing save as in the file tab...&lt;BR /&gt;&lt;BR /&gt;Anyone out there that knows a good trick for this?&amp;nbsp;&lt;BR /&gt;If it not too much to ask it would be great to have some comments through the code so i can begin to understand what happends. I would like to understand more of this and maybe even build some own code from scratch&lt;/P&gt;</description>
      <pubDate>Fri, 02 Dec 2016 15:58:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/saveas-lisp-subfolder/m-p/6724339#M126039</guid>
      <dc:creator>andreas7ZYXQ</dc:creator>
      <dc:date>2016-12-02T15:58:46Z</dc:date>
    </item>
    <item>
      <title>Re: Saveas lisp, subfolder</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/saveas-lisp-subfolder/m-p/6724421#M126040</link>
      <description>&lt;P&gt;Here is a basic example of how you can do this (with notes). &amp;nbsp;If I understood what you wanted clearly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;(Defun C:Saveas_Sub_Folder ( / subfolder cpath newpath); Define "COMMAND" &amp;amp; localize variables (delete when lisp is done running)
  (setq subfolder (getstring "Enter Subfolder Name: ")); get subfolder name from user (no checking for allowed windows characters)
  (setq cpath (getvar "dwgprefix")) ; get current drawing path
  (Setq newpath (strcat cpath subfolder)) ; add the new sub-folder to the end of the current path
  (if (not (findfile newpath)) ; check if the subfolder already exists
    (vl-mkdir newpath) ; if not make it
    );if
  (command "saveas" "" (strcat newpath "\\" (getvar "dwgname"))); saveas with new path and existing dwg name
  );defun&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Dec 2016 16:28:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/saveas-lisp-subfolder/m-p/6724421#M126040</guid>
      <dc:creator>Shneuph</dc:creator>
      <dc:date>2016-12-02T16:28:09Z</dc:date>
    </item>
    <item>
      <title>Re: Saveas lisp, subfolder</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/saveas-lisp-subfolder/m-p/6724725#M126041</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3794662"&gt;@andreas7ZYXQ&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;....&lt;BR /&gt;I would like to start my routine with save as in a subfolder where the curent drawings is saved.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;after this routine i want to add various things so it has to be "opened" as i[t] normally does when pressing save as in the file tab...&lt;BR /&gt;....&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I assume you mean a subfolder &lt;EM&gt;under&lt;/EM&gt; the one in which the current drawing is located, not the &lt;EM&gt;same&lt;/EM&gt; subfolder in which it is, as &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/450014"&gt;@Shneuph&lt;/a&gt;&amp;nbsp;appears to have assumed. &amp;nbsp;There's no need to have to spell out a subfolder name, nor check whether it exists [whether because it hasn't been made yet or you mis-typed it].&amp;nbsp; You can do this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(defun C:DOSTUFF (/ some local variables)
  (... do some initial stuff ...)
  &lt;FONT color="#0000ff"&gt;&lt;STRONG&gt;(initdia)&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT color="#33cccc"&gt;; &lt;FONT color="#0000ff"&gt;INIT&lt;/FONT&gt;iate the &lt;FONT color="#0000ff"&gt;DIA&lt;/FONT&gt;log box for the following command&lt;/FONT&gt;
  &lt;STRONG&gt;&lt;FONT color="#0000ff"&gt;(command "_.saveas")&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT color="#33cccc"&gt;; do &lt;FONT color="#ff6600"&gt;all you need to do&lt;/FONT&gt; in the dialog box&lt;/FONT&gt;
  (... do more stuff ...)
  (... do more other stuff ...)
  (princ)
); defun&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The (initdia) is needed because without it, commands called in a (command) function use the command-line version.&amp;nbsp; The &lt;FONT color="#ff6600"&gt;all you need to do&lt;/FONT&gt; part &lt;EM&gt;includes&lt;/EM&gt; the options of picking on an existing subfolder if there is one [no risk of typing its name incorrectly], just entering a new drawing name if you want it in the &lt;EM&gt;same&lt;/EM&gt; folder the starting drawing is in, right-clicking in the list of drawings and picking New&amp;nbsp;&amp;gt; Folder if you need to make one that doesn't exist yet, navigating to somewhere entirely unrelated if that's what you need, etc., etc.&amp;nbsp; Since it's operating through the dialog box, there's no need to do the wait-for-input-until-the-command-is-done thing that you typically do with a command in which you don't know the amount of inputs the User will need to provide, in command-line mode.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I &lt;EM&gt;wasn't&lt;/EM&gt; sure this approach would work, because I had always heard that an AutoLisp routine can't start in one drawing and continue in another, but I tried it, and in this case it &lt;EM&gt;does&lt;/EM&gt;, presumably because SAVEAS &lt;EM&gt;moves you into&lt;/EM&gt; the new drawing, and the starting one doesn't remain active. &amp;nbsp;[I think an example of what &lt;EM&gt;wouldn't&lt;/EM&gt; work would be with an OPEN command, in which case the drawing you start the routine in &lt;EM&gt;is&lt;/EM&gt; still active, but I haven't tested the theory].&amp;nbsp; I did the following&amp;nbsp;as a completely arbitrary test:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(defun C:TEST ()
  (initdia)
  (command "_.saveas")
  (command "_.circle" (getvar 'viewctr) 10)
  (command "_.move" "_last" "" "0,5" "")
)&lt;/PRE&gt;
&lt;P&gt;and sure enough, when I ran the TEST command, I got to save a new drawing, was taken into it, and it &lt;EM&gt;did&lt;/EM&gt; draw a 10-radius Circle in the middle of the screen, and Moved&amp;nbsp;it up 5 units.&amp;nbsp; So it &lt;EM&gt;will&lt;/EM&gt; take you into the new drawing and continue with your "add various things" part.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Dec 2016 18:33:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/saveas-lisp-subfolder/m-p/6724725#M126041</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2016-12-02T18:33:12Z</dc:date>
    </item>
    <item>
      <title>Re: Saveas lisp, subfolder</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/saveas-lisp-subfolder/m-p/6725275#M126042</link>
      <description>&lt;P&gt;I read it as the drawing was already saved in a folder e.g., "C:\FolderA\This Drawing.dwg" and the user wanted to saveas to a subfolder of the "Folder A" (new or existing) like, "C:\Folder A\New or E Subfolder\&lt;SPAN&gt;This &lt;/SPAN&gt;Drawing.dwg"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I could have misinterpreted what the user wanted.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Dec 2016 23:24:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/saveas-lisp-subfolder/m-p/6725275#M126042</guid>
      <dc:creator>Shneuph</dc:creator>
      <dc:date>2016-12-02T23:24:17Z</dc:date>
    </item>
    <item>
      <title>Re: Saveas lisp, subfolder</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/saveas-lisp-subfolder/m-p/6725572#M126043</link>
      <description>&lt;P&gt;Sheneuph you just made my day alot better &lt;span class="lia-unicode-emoji" title=":face_with_tongue:"&gt;😛&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;Actually i find both of your codes useful so i will use them both but in this case Sheneuphs code seems to fulfil my wishes &lt;span class="lia-unicode-emoji" title=":grinning_face_with_big_eyes:"&gt;😃&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;saves my file and continue to draw a circle there. &lt;span class="lia-unicode-emoji" title=":face_with_tongue:"&gt;😛&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks alot guys, and for the great comments so i can understand the code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;(Defun C:ss ( / subfolder cpath newpath); Define "COMMAND" &amp;amp; localize variables (delete when lisp is done running)
  (setq subfolder "3D"); get subfolder name from user (no checking for allowed windows characters)
  (setq cpath (getvar "dwgprefix")); get current drawing path
  (Setq newpath (strcat cpath subfolder)); add the new sub-folder to the end of the current path
  (if (not (findfile newpath)); check if the subfolder already exists
    (vl-mkdir newpath); if not make it
    );if
  (command "saveas" "" (strcat newpath "\\" (getvar "dwgname"))); saveas with new path and existing dwg name
  (command "_.circle" (getvar 'viewctr) 10)
  (command "_.move" "_last" "" "0,5" "")
  (command "_-view" "_swiso" )
  (command "zoom" "e" )
)&lt;/PRE&gt;</description>
      <pubDate>Sat, 03 Dec 2016 08:13:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/saveas-lisp-subfolder/m-p/6725572#M126043</guid>
      <dc:creator>andreas7ZYXQ</dc:creator>
      <dc:date>2016-12-03T08:13:46Z</dc:date>
    </item>
  </channel>
</rss>

