<?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 Create new file, with more text in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/create-new-file-with-more-text/m-p/8304115#M98873</link>
    <description>&lt;P&gt;I want to make a lisp that crates a new file, based on the current file i am working with.&lt;BR /&gt;I want to add "_FINAL" to the filename.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i have this at the moment, but i dont get the "_FINAL" added&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(defun c:Finalcreate()&lt;BR /&gt;setq fPath (getvar 'dwgprefix)&lt;BR /&gt;setq fName (getvar 'dwgname)&lt;BR /&gt;(command "saveas" "2010" (strcat fPath fName "_FINAL"))&lt;BR /&gt;(command "qsave")&lt;BR /&gt;(princ)&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best would be if it automatic owerwrate the file, if it exists.&lt;/P&gt;&lt;P&gt;AND if the file, currently in use has "__" 2 x underscore , all after the "__" should be erased before adding _FINAL to the filename.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am currently doing this manually, and it is taking SO much time &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 01 Oct 2018 11:33:19 GMT</pubDate>
    <dc:creator>lmnDCJSJ</dc:creator>
    <dc:date>2018-10-01T11:33:19Z</dc:date>
    <item>
      <title>Create new file, with more text</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/create-new-file-with-more-text/m-p/8304115#M98873</link>
      <description>&lt;P&gt;I want to make a lisp that crates a new file, based on the current file i am working with.&lt;BR /&gt;I want to add "_FINAL" to the filename.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i have this at the moment, but i dont get the "_FINAL" added&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(defun c:Finalcreate()&lt;BR /&gt;setq fPath (getvar 'dwgprefix)&lt;BR /&gt;setq fName (getvar 'dwgname)&lt;BR /&gt;(command "saveas" "2010" (strcat fPath fName "_FINAL"))&lt;BR /&gt;(command "qsave")&lt;BR /&gt;(princ)&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best would be if it automatic owerwrate the file, if it exists.&lt;/P&gt;&lt;P&gt;AND if the file, currently in use has "__" 2 x underscore , all after the "__" should be erased before adding _FINAL to the filename.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am currently doing this manually, and it is taking SO much time &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Oct 2018 11:33:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/create-new-file-with-more-text/m-p/8304115#M98873</guid>
      <dc:creator>lmnDCJSJ</dc:creator>
      <dc:date>2018-10-01T11:33:19Z</dc:date>
    </item>
    <item>
      <title>Re: Create new file, with more text</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/create-new-file-with-more-text/m-p/8304178#M98874</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5013764"&gt;@lmnDCJSJ&lt;/a&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;for the first part of your question:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the result of saving with SAVEAS command would make that file current and than you QSAVE the file again which is &lt;SPAN&gt;redundant. so i suggest to change it to use SAVE command (instead of SAVEAS) but this won't let you to specify the dwg format so do it in OPTIONS.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;the expert=5 sysvar is to tell autocad to skip alerting of existing file.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;if the file in question is already open? that's another 'story' to VisualLISP\ActiveX to be solve.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;moshe&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;(defun c:Finalcreate()
 (setq fPath (getvar 'dwgprefix))
 (setq fName (getvar 'dwgname))

 (setvar 'expert 5)
 (command "save" (strcat fPath fName "_FINAL"))
 (command "qsave")
 (setvar 'expert 0)
 (princ)
)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Oct 2018 11:59:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/create-new-file-with-more-text/m-p/8304178#M98874</guid>
      <dc:creator>Moshe-A</dc:creator>
      <dc:date>2018-10-01T11:59:49Z</dc:date>
    </item>
    <item>
      <title>Re: Create new file, with more text</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/create-new-file-with-more-text/m-p/8304206#M98875</link>
      <description>&lt;P&gt;this code will replace also&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(defun c:Finalcreate()&lt;BR /&gt;(setq fPath (getvar 'dwgprefix))&lt;BR /&gt;(setq fName (getvar 'dwgname))&lt;BR /&gt;(setq fsl (strlen fName))&lt;BR /&gt;(setq fsl (- fsl 4))&lt;BR /&gt;(setq file (strcat fPath fName "_FINAL.dwg"))&lt;BR /&gt;(if (findfile file)&lt;BR /&gt;(vl-file-delete file)&lt;BR /&gt;)&lt;BR /&gt;(command "saveas" "2010" (strcat fPath fName "_FINAL"))&lt;BR /&gt;(princ)&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Oct 2018 12:09:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/create-new-file-with-more-text/m-p/8304206#M98875</guid>
      <dc:creator>dbhunia</dc:creator>
      <dc:date>2018-10-01T12:09:05Z</dc:date>
    </item>
    <item>
      <title>Re: Create new file, with more text</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/create-new-file-with-more-text/m-p/8304207#M98876</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/52747"&gt;@Moshe-A&lt;/a&gt;&lt;/P&gt;&lt;P&gt;Thanks it works, but the filename has the .dwg embedded in the new filename.&lt;/P&gt;&lt;P&gt;eg: file1.dwg becomes file1.dwg_FINAL.dwg&lt;/P&gt;&lt;P&gt;Can i somehow use substr to remove the LAST 4 (.dwg)?&lt;/P&gt;</description>
      <pubDate>Mon, 01 Oct 2018 12:09:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/create-new-file-with-more-text/m-p/8304207#M98876</guid>
      <dc:creator>lmnDCJSJ</dc:creator>
      <dc:date>2018-10-01T12:09:21Z</dc:date>
    </item>
    <item>
      <title>Re: Create new file, with more text</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/create-new-file-with-more-text/m-p/8304254#M98877</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5013764"&gt;@lmnDCJSJ&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;I want to make a lisp that crates a new file, based on the current file i am working with.&lt;BR /&gt;I want to add "_FINAL" to the filename.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i have this at the moment, but i dont get the "_FINAL" added&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(defun c:Finalcreate()&lt;BR /&gt;setq fPath (getvar 'dwgprefix)&lt;BR /&gt;setq fName (getvar 'dwgname)&lt;BR /&gt;(command "saveas" "2010" (strcat fPath fName "_FINAL"))&lt;BR /&gt;(command "qsave")&lt;BR /&gt;(princ)&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best would be if it automatic &lt;FONT color="#3366FF"&gt;owerwrate&lt;/FONT&gt; the file, if it exists.&lt;/P&gt;&lt;P&gt;AND if the file, currently in use has &lt;FONT color="#3366FF"&gt;"__" 2 x underscore , all after the "__" should be erased before adding _FINAL to the filename.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am currently doing this manually, and it is taking SO much time &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Try this ...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(defun c:Finalcreate()&lt;BR /&gt;(setq fPath (getvar 'dwgprefix))&lt;BR /&gt;(setq fName (getvar 'dwgname))&lt;BR /&gt;(while&lt;BR /&gt;(wcmatch fName "*_*")&lt;BR /&gt;(setq fName (vl-string-subst "" "_" fName))&lt;BR /&gt;)&lt;BR /&gt;(setq fsl (strlen fName))&lt;BR /&gt;(setq fsl (- fsl 4))&lt;BR /&gt;(setq Fname (substr fName 1 fsl))&lt;BR /&gt;(setq file (strcat fPath fName "_FINAL.dwg"))&lt;BR /&gt;(if (findfile file)&lt;BR /&gt;(vl-file-delete file)&lt;BR /&gt;)&lt;BR /&gt;(command "saveas" "2010" (strcat fPath fName "_FINAL"))&lt;BR /&gt;(princ)&lt;BR /&gt;)&lt;/P&gt;</description>
      <pubDate>Mon, 01 Oct 2018 12:26:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/create-new-file-with-more-text/m-p/8304254#M98877</guid>
      <dc:creator>dbhunia</dc:creator>
      <dc:date>2018-10-01T12:26:21Z</dc:date>
    </item>
    <item>
      <title>Re: Create new file, with more text</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/create-new-file-with-more-text/m-p/8304339#M98878</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5869979"&gt;@dbhunia&lt;/a&gt;&lt;/P&gt;&lt;P&gt;Works like i wanted &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; thanks.&lt;/P&gt;</description>
      <pubDate>Mon, 01 Oct 2018 12:55:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/create-new-file-with-more-text/m-p/8304339#M98878</guid>
      <dc:creator>lmnDCJSJ</dc:creator>
      <dc:date>2018-10-01T12:55:58Z</dc:date>
    </item>
  </channel>
</rss>

