<?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 to save a file in two locations? in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-to-save-a-file-in-two-locations/m-p/9209921#M80351</link>
    <description>&lt;P&gt;The code I posted is not a Script, but an AutoLisp definition of two command names.&amp;nbsp; Assuming you have full AutoCAD [with or without overlay software such as Civil3D or something], &lt;EM&gt;not LT&lt;/EM&gt;&amp;nbsp; that can't use AutoLisp, you should save the code to a file with a &lt;FONT color="#000000"&gt;&lt;STRONG&gt;.lsp&lt;/STRONG&gt;&lt;/FONT&gt; filetype ending.&amp;nbsp; You can use APPLOAD to load it, and then those two commands will be defined.&amp;nbsp; You can include the code in an &lt;FONT color="#000000"&gt;&lt;STRONG&gt;acaddoc.lsp&lt;/STRONG&gt;&lt;/FONT&gt; file [add to it if you have such a file already, or start such a file with it], and they will be defined in every drawing you open, automatically.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Once they're loaded, you can call either command in a Tool Palette button, or just type in the command names [that's what I do -- they're short left-hand-only names, so it's as easy as going to any menu item].&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;&lt;STRONG&gt;NOTE:&lt;/STRONG&gt;&lt;/FONT&gt;&amp;nbsp; In AutoLisp file-related functions, you must make file paths with either &lt;EM&gt;forward&lt;/EM&gt;&amp;nbsp; slashes [as in my code] or &lt;EM&gt;double&lt;/EM&gt;&amp;nbsp; backslashes, &lt;EM&gt;not&lt;/EM&gt;&amp;nbsp; single backslashes [which are triggers for special characters].&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you use LT and can't use AutoLisp, turning them into Script or command-macro format could be a problem since they use an AutoLisp &lt;FONT color="#000000"&gt;(strcat)&lt;/FONT&gt; function to put the file path and drawing name together.&amp;nbsp; There may be a way to do that in Diesel language, but I'm not well versed in that.&lt;/P&gt;</description>
    <pubDate>Wed, 18 Dec 2019 16:14:29 GMT</pubDate>
    <dc:creator>Kent1Cooper</dc:creator>
    <dc:date>2019-12-18T16:14:29Z</dc:date>
    <item>
      <title>Script to save a file in two locations?</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-to-save-a-file-in-two-locations/m-p/9209622#M80348</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to create a custom Save button that will save an open .dwg file to two different locations simultaneously.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The scenario would be that I'm making a change to an existing .dwg file that is located on our corporate server.&amp;nbsp; A project manager out at the job site accesses a copy of this file through a shared Dropbox account, or some similar cloud service.&amp;nbsp; When I make the updates and hit this new Save button, the file saves to it's native location and also saves (or creates a copy) to this cloud folder.&amp;nbsp; This way the project manager always has access to the most recently saved version of the file and I don't need to remember to manually send them a copy every time I hit Save.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm familiar with creating/modifying buttons and very basic commands in the CUI, but have no idea where to start with the coding to achieve this solution.&amp;nbsp; One part of the button command would be to save (overwrite) to the original file location (which varies).&amp;nbsp; The other part of the command would be to save the file (or overwrite existing) to the cloud based folder.&amp;nbsp; That folder would always be the same destination, and would be connected to my desktop through a connector app, so the file path should be able to remain consistent.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone help me with this?&amp;nbsp; I just need to know how that code would be written and how to apply it to a custom Save button that I've created.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Much appreciated!&lt;/P&gt;</description>
      <pubDate>Wed, 18 Dec 2019 14:38:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-to-save-a-file-in-two-locations/m-p/9209622#M80348</guid>
      <dc:creator>JOSHHALVERSON</dc:creator>
      <dc:date>2019-12-18T14:38:48Z</dc:date>
    </item>
    <item>
      <title>Re: Script to save a file in two locations?</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-to-save-a-file-in-two-locations/m-p/9209688#M80349</link>
      <description>&lt;P&gt;Here's what I use for a very similar purpose.&amp;nbsp; Both commands QSAVE the drawing [in its native location, which varies as in your description, typically on our Server] and also SAVE it to [in my case] &lt;EM&gt;my local computer&lt;/EM&gt;.&amp;nbsp; So in addition to being a secondary backup copy, in case anything goes wrong with the Server or my connection to it, I always have the latest version of any drawing I've worked on [assuming I have used these commands with it] &lt;EM&gt;on my computer&lt;/EM&gt;, so I can work in it until the Server connection is restored.&amp;nbsp; I hope you are able to &lt;FONT color="#00CCFF"&gt;substitute a path of some sort&lt;/FONT&gt; for your cloud folder.&lt;/P&gt;
&lt;PRE&gt;(defun C:&lt;FONT color="#000000"&gt;&lt;STRONG&gt;SS&lt;/STRONG&gt;&lt;/FONT&gt; (/ cmde); = &lt;STRONG&gt;S&lt;/STRONG&gt;ave &lt;STRONG&gt;twice&lt;/STRONG&gt; [and stay in drawing]
  (setq cmde (getvar 'cmdecho))
  (setvar 'cmdecho 0)
  (command "_.qsave" "_.save" (strcat "&lt;EM&gt;&lt;FONT color="#00CCFF"&gt;C:/My/Local/Backup/Filepath/&lt;/FONT&gt;&lt;/EM&gt;" (getvar "DWGNAME")) "Yes")
  (setvar 'cmdecho cmde)
  (prompt "\nDrawing Saved in original file and to local-computer backup.")
  (princ)
)

(defun C:&lt;FONT color="#000000"&gt;&lt;STRONG&gt;SSC&lt;/STRONG&gt;&lt;/FONT&gt; (); = &lt;STRONG&gt;S&lt;/STRONG&gt;ave &lt;STRONG&gt;twice&lt;/STRONG&gt; and &lt;STRONG&gt;C&lt;/STRONG&gt;lose, incl. set Layer to 0, Zoom to limits
  (command
    "_.layer" "_thaw" "0" "_set" "0" ""
    "_.zoom" (getvar 'limmin) (getvar 'limmax)
    "_.qsave" "_.save" (strcat &lt;EM&gt;&lt;FONT color="#00CCFF"&gt;"C:/My/Local/Backup/Filepath/"&lt;/FONT&gt;&lt;/EM&gt; (getvar "DWGNAME")) "Yes"
    "_.close"
  )
)
&lt;/PRE&gt;
&lt;P&gt;One thing to be aware of:&amp;nbsp; they have the "Yes" answer to the question of whether to replace the file built in.&amp;nbsp; On &lt;EM&gt;first use&lt;/EM&gt;&amp;nbsp; only in a particular drawing, that file won't be there yet, so it won't ask that question, which means "Yes" will go in at the command prompt, and an unknown-command message will go by.&amp;nbsp; It seemed not worth the complexity of trying to avoid that, and it doesn't bother the operation.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Dec 2019 14:54:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-to-save-a-file-in-two-locations/m-p/9209688#M80349</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2019-12-18T14:54:45Z</dc:date>
    </item>
    <item>
      <title>Re: Script to save a file in two locations?</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-to-save-a-file-in-two-locations/m-p/9209816#M80350</link>
      <description>&lt;P&gt;Your description sounds right along the lines of what I'm looking to accomplish.&amp;nbsp; I am able to get the file path of my desired backup folder, but I have a few questions if you'll bear with me.&amp;nbsp; Here's what I've done so far...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I copied your code text in full and pasted it into Notepad.&amp;nbsp; I changed both your instances of "C:/My/Local/Backup/Filepath/" to "C:\Users\jhalverson\Dropbox" which is the secondary location I want the file saved to.&amp;nbsp; I saved this as "save.scr" and placed it in a folder.&amp;nbsp; I went into Options and under the Files tab added the "save.scr" folder location to the Support File Search Path list.&amp;nbsp; Then in the CUI in AutoCAD I navigate to my custom save button.&amp;nbsp; In the Macro field I have the text "^C^C_script "save".&amp;nbsp; When I go back into the main screen and click on my button I get the following text in the command line...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Command:&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;Command:&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;Command: _script&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;Enter script file name &amp;lt;C:\Users\jhalverson\Desktop\Drawing3.scr&amp;gt;: "save"&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;Command: (defun C:SS (/ cmde); = Save twice [and stay in drawing]&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;(_&amp;gt; (setq cmde (getvar 'cmdecho))&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;(_&amp;gt; (setvar 'cmdecho 0)&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;(_&amp;gt; (command "_.qsave" "_.save" (strcat "C:\Users\jhalverson\Dropbox" (getvar "DWGNAME")) "Yes")&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;(_&amp;gt; (setvar 'cmdecho cmde)&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;(_&amp;gt; (prompt "\nDrawing Saved in original file and to local-computer backup.")&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;(_&amp;gt; (princ)&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;(_&amp;gt; )&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;C:SS&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;Command:&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;SCRIPT&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;Enter script file name &amp;lt;C:\Users\jhalverson\Desktop\Drawing3.scr&amp;gt;: (defun C:SSC (); = Save twice and Close, incl. set Layer to 0, Zoom to limits&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;(_&amp;gt; (command&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;((_&amp;gt; "_.layer" "_thaw" "0" "_set" "0" ""&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;((_&amp;gt; "_.zoom" (getvar 'limmin) (getvar 'limmax)&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;((_&amp;gt; "_.qsave" "_.save" (strcat "C:\Users\jhalverson\Dropbox" (getvar "DWGNAME")) "Yes"&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;((_&amp;gt; "_.close"&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;((_&amp;gt; )&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm obviously doing something wrong somewhere, but I'm VERY unfamiliar with how to implement this code.&amp;nbsp; Can you tell what I'm doing wrong?&lt;/P&gt;</description>
      <pubDate>Wed, 18 Dec 2019 15:38:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-to-save-a-file-in-two-locations/m-p/9209816#M80350</guid>
      <dc:creator>JOSHHALVERSON</dc:creator>
      <dc:date>2019-12-18T15:38:13Z</dc:date>
    </item>
    <item>
      <title>Re: Script to save a file in two locations?</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-to-save-a-file-in-two-locations/m-p/9209921#M80351</link>
      <description>&lt;P&gt;The code I posted is not a Script, but an AutoLisp definition of two command names.&amp;nbsp; Assuming you have full AutoCAD [with or without overlay software such as Civil3D or something], &lt;EM&gt;not LT&lt;/EM&gt;&amp;nbsp; that can't use AutoLisp, you should save the code to a file with a &lt;FONT color="#000000"&gt;&lt;STRONG&gt;.lsp&lt;/STRONG&gt;&lt;/FONT&gt; filetype ending.&amp;nbsp; You can use APPLOAD to load it, and then those two commands will be defined.&amp;nbsp; You can include the code in an &lt;FONT color="#000000"&gt;&lt;STRONG&gt;acaddoc.lsp&lt;/STRONG&gt;&lt;/FONT&gt; file [add to it if you have such a file already, or start such a file with it], and they will be defined in every drawing you open, automatically.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Once they're loaded, you can call either command in a Tool Palette button, or just type in the command names [that's what I do -- they're short left-hand-only names, so it's as easy as going to any menu item].&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;&lt;STRONG&gt;NOTE:&lt;/STRONG&gt;&lt;/FONT&gt;&amp;nbsp; In AutoLisp file-related functions, you must make file paths with either &lt;EM&gt;forward&lt;/EM&gt;&amp;nbsp; slashes [as in my code] or &lt;EM&gt;double&lt;/EM&gt;&amp;nbsp; backslashes, &lt;EM&gt;not&lt;/EM&gt;&amp;nbsp; single backslashes [which are triggers for special characters].&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you use LT and can't use AutoLisp, turning them into Script or command-macro format could be a problem since they use an AutoLisp &lt;FONT color="#000000"&gt;(strcat)&lt;/FONT&gt; function to put the file path and drawing name together.&amp;nbsp; There may be a way to do that in Diesel language, but I'm not well versed in that.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Dec 2019 16:14:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-to-save-a-file-in-two-locations/m-p/9209921#M80351</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2019-12-18T16:14:29Z</dc:date>
    </item>
    <item>
      <title>Re: Script to save a file in two locations?</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-to-save-a-file-in-two-locations/m-p/9209978#M80352</link>
      <description>&lt;P&gt;Oh my gosh, it works!&amp;nbsp; Thank you so much!&amp;nbsp; Go get yourself a beer, and tell the bartender to put it on Josh's tab.&amp;nbsp; Someone named Josh probably has one open.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":clinking_beer_mugs:"&gt;🍻&lt;/span&gt;&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":beer_mug:"&gt;🍺&lt;/span&gt;&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":clinking_beer_mugs:"&gt;🍻&lt;/span&gt;&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":beer_mug:"&gt;🍺&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Dec 2019 16:40:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-to-save-a-file-in-two-locations/m-p/9209978#M80352</guid>
      <dc:creator>JOSHHALVERSON</dc:creator>
      <dc:date>2019-12-18T16:40:36Z</dc:date>
    </item>
    <item>
      <title>Re: Script to save a file in two locations?</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-to-save-a-file-in-two-locations/m-p/13128042#M80353</link>
      <description>Hi, can you share the lisp file itself because I did copy and paste your code and save it as .lsp and load into the drawing but when I use QSAVE command, it just save the drawing and not make a duplicate file at the desktop (I changed the blue path in your coding to the desktop).&lt;BR /&gt;or am I doing it wrongly.</description>
      <pubDate>Mon, 04 Nov 2024 06:59:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-to-save-a-file-in-two-locations/m-p/13128042#M80353</guid>
      <dc:creator>asyrafQ3ZXS</dc:creator>
      <dc:date>2024-11-04T06:59:08Z</dc:date>
    </item>
    <item>
      <title>Re: Script to save a file in two locations?</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-to-save-a-file-in-two-locations/m-p/13128476#M80354</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/16078344"&gt;@asyrafQ3ZXS&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;.... when I use QSAVE command, it just save the drawing and not make a duplicate file ....&lt;BR /&gt;or am I doing it wrongly.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Yes, you're doing it wrongly.&amp;nbsp; It does not change the operation of the QSAVE command to make a double save.&amp;nbsp; It defines two custom commands to do it.&amp;nbsp; The command name is &lt;FONT size="4"&gt;&lt;STRONG&gt;SS&lt;/STRONG&gt;&lt;/FONT&gt;&amp;nbsp;if you only want to &lt;FONT size="4"&gt;&lt;STRONG&gt;S&lt;/STRONG&gt;&lt;/FONT&gt;ave in two places and continue working, or &lt;FONT size="4"&gt;&lt;STRONG&gt;SSC&lt;/STRONG&gt;&lt;/FONT&gt; if you want to &lt;FONT size="4"&gt;&lt;STRONG&gt;S&lt;/STRONG&gt;&lt;/FONT&gt;ave in two places and &lt;FONT size="4"&gt;&lt;STRONG&gt;C&lt;/STRONG&gt;&lt;/FONT&gt;lose the drawing.&amp;nbsp; [The command name is always the part immediately following&lt;FONT face="courier new,courier" size="4"&gt;&lt;STRONG&gt; (defun C: &lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT size="4"&gt;i&lt;/FONT&gt;n these kinds of files.]&lt;/P&gt;</description>
      <pubDate>Mon, 04 Nov 2024 11:23:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-to-save-a-file-in-two-locations/m-p/13128476#M80354</guid>
      <dc:creator>Kent1Cooper</dc:creator>
      <dc:date>2024-11-04T11:23:19Z</dc:date>
    </item>
    <item>
      <title>Re: Script to save a file in two locations?</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-to-save-a-file-in-two-locations/m-p/13130231#M80355</link>
      <description>ah thank you for the code! it works! and I will use it in the other lisp code as initial code so if anything happen to the file (like crash), it will save the drawing and I have the backup.</description>
      <pubDate>Tue, 05 Nov 2024 04:35:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-to-save-a-file-in-two-locations/m-p/13130231#M80355</guid>
      <dc:creator>asyrafQ3ZXS</dc:creator>
      <dc:date>2024-11-05T04:35:25Z</dc:date>
    </item>
    <item>
      <title>Re: Script to save a file in two locations?</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-to-save-a-file-in-two-locations/m-p/13130319#M80356</link>
      <description>&lt;P&gt;It is possible to capture the standard save &amp;amp; close commands using a reactor and do something different in this case save the file twice. I got help for this, not sure about Qsave. You must have the lisp autoloaded for it to work. The code attached is NOT working code just method.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;;Reactor callback function
(defun BeginSaveFunc (reactor lst / variables)
do your save here
)

(cond
((= (vlr-current-reaction-name) ':VLR-beginSave) (Princ "\nThis function has been triggered by a Document Save event."))
((= (vlr-current-reaction-name) ':VLR-beginClose)(princ "\nThis function has been triggered by a Document Close event."))
)
(princ)
)
(if (not _BeginCloseReactor) (setq _BeginCloseReactor (VLR-Dwg-Reactor nil '((:VLR-beginClose . BeginCloseFunc)))))
(if (not _BeginSaveReactor ) (setq _BeginSaveReactor  (VLR-Dwg-Reactor nil '((:VLR-beginSave  . BeginCloseFunc)))))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Nov 2024 05:53:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/script-to-save-a-file-in-two-locations/m-p/13130319#M80356</guid>
      <dc:creator>Sea-Haven</dc:creator>
      <dc:date>2024-11-05T05:53:58Z</dc:date>
    </item>
  </channel>
</rss>

