<?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: Batch Printing LSP in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/batch-printing-lsp/m-p/5683535#M140739</link>
    <description>&lt;P&gt;I recomend using a .cmd-file to run the script.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;@echo off
setlocal EnableDelayedExpansion
cls
echo.
echo. Starting batch plott....
Echo.
ping -n 3 127.0.0.1 &amp;gt;nul
echo.
rem ;check if the exe-file exist
if not exist "%programfiles%\Autodesk\AutoCAD 2012 - English\acad.exe" goto err1
rem ;check if lisp-file exist 
if not exist plott.lsp goto err2
rem ;defun y is to prevent an error if the drawing is not in read only mode
for %%z in (*.dwg) do echo Open "%%z" (defun c:y()(princ)) y (load "plott.lsp") pline 0,0 0,1 1,1 c close y&amp;gt;&amp;gt;tmp.scr
echo.
echo. Running script in AutoCAD...
echo.
"%programfiles%\Autodesk\AutoCAD 2012 - English\acad.exe" /B tmp.scr
ping -n 3 127.0.0.1 &amp;gt;nul
goto done


goto end
:err1
echo.
echo. Autocad exicutable is not found!
echo.
goto end
:errl2
echo.
echo. The lisp-file is not found!
echo. 
:Done
if exist tmp.scr del tmp.scr
echo.
ping -n 3 127.0.0.1 &amp;gt;nul
:end
echo.
echo.
echo. This window is closing in 10 sek....
ping -n 10 127.0.0.1 &amp;gt;nul&lt;/PRE&gt;&lt;P&gt;Change the version of autocad and name of lisp-file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Place the cmd and lsp-file in the folder you want to plot and run the cmd-file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/Micke&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 18 Jun 2015 18:30:17 GMT</pubDate>
    <dc:creator>Micke_ELE</dc:creator>
    <dc:date>2015-06-18T18:30:17Z</dc:date>
    <item>
      <title>Batch Printing LSP</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/batch-printing-lsp/m-p/5682350#M140736</link>
      <description>&lt;P&gt;I am trying to create a LSP routine that will run through the dwg files in a folder, open them up one by one and then print. I have adapted this lisp to do so but am having some problems.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As I understand it you cannot run a .lsp without an open drawing? So, I load up a drawing, any drawing, and then try to run this lisp. CAD will then open up each of the drawings in the selected directory but will only do so in the background of the existing drawing. When it goes to run the predetermined plot routine it will just keep printing the first drawing I had open over and over again. Now obviously I don't want this to happen&amp;nbsp;&lt;img id="smileylol" class="emoticon emoticon-smileylol" src="https://forums.autodesk.com/i/smilies/16x16_smiley-lol.png" alt="Smiley LOL" title="Smiley LOL" /&gt; So what am I missing to make it open a drawing, plot, open the next drawing, plot etc&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also is there a better way for me to go about doing this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;(defun c:batch (/ dir files total ct docs doc)
(defun listAllFiles (path ext /)

(apply 'append
(cons
(mapcar
(function (lambda(x) (strcat path "\\" x)))
(vl-directory-files path ext 1)
)
(mapcar
(function (lambda(x) (listAllFiles (strcat path "\\" x) ext)))
(cddr (vl-directory-files path nil -1)) ; to exclude "." and ".."
)
)
)
)
(if (and
(setq dir (getfiled "Select a directory to process..." "Start here" "" 33))
(setq dir (vl-filename-directory dir))
)
(if (setq files (listAllFiles dir "*.dwg"))
(progn
(vl-load-com)
(setq total (itoa (length files))
ct 0
docs (vla-get-documents (vlax-get-acad-object))
)
(foreach file files
(setq doc (vla-open docs file)
ct (1+ ct)
)

(command "tilemode" "0")
(command "-plot" "y" "Layout1" "\\\\CTASERVER\\Brother MFC-J6520DW Printer" "A3 (297 x 420 mm)" "M"
"L" "N" "e" "F" "" "Y" "" "Y" "y" "N" "N" "n" "N" "y" )  
(setvar"DynMode" 0)

(prompt (strcat "\r" (itoa ct) " of " total " drawings processed."))


(vla-close doc :vlax-false)
)
(vlax-release-object doc)
(vlax-release-object docs)
)
(prompt (strcat "\nNo files of that type found in " dir " !"))
)
(prompt "\nNo path specified!")
)
(princ)
)&lt;/PRE&gt;</description>
      <pubDate>Thu, 18 Jun 2015 08:30:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/batch-printing-lsp/m-p/5682350#M140736</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-06-18T08:30:06Z</dc:date>
    </item>
    <item>
      <title>Re: Batch Printing LSP</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/batch-printing-lsp/m-p/5683366#M140737</link>
      <description>&lt;P&gt;Hi HaleOED,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="alt-edited"&gt;Autolisp&amp;nbsp; is a single document application.&amp;nbsp; Activating another document to run the "plot" command will&amp;nbsp;stops and autolsip program...&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="alt-edited"&gt;I&amp;nbsp;would suggest&lt;/SPAN&gt; to use a .scr file to open each dwg file and&amp;nbsp;call your_plot.lsp file.&lt;/P&gt;
&lt;P&gt;You can use Auto/Visual LISP to &lt;SPAN class="hps"&gt;write&lt;/SPAN&gt; the &lt;SPAN class="hps"&gt;temporary&lt;/SPAN&gt; .scr file, and start the script.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps, &lt;BR /&gt;Henrique&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jun 2015 17:01:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/batch-printing-lsp/m-p/5683366#M140737</guid>
      <dc:creator>hmsilva</dc:creator>
      <dc:date>2015-06-18T17:01:44Z</dc:date>
    </item>
    <item>
      <title>Re: Batch Printing LSP</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/batch-printing-lsp/m-p/5683486#M140738</link>
      <description>&lt;P&gt;AutoCAD CoreConsole can be used...&lt;/P&gt;
&lt;P&gt;Here is an exmple with hardcoded folder name -&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Batch_Plot.bat file -&lt;/P&gt;
&lt;P&gt;echo off&lt;BR /&gt;echo Starting AcCoreConsole&lt;BR /&gt;c:&lt;BR /&gt;cd C:\Program Files\Autodesk\AutoCAD 2013&lt;BR /&gt;echo ================================================================================&lt;BR /&gt;FOR %%f in ("C:\TEST\*.dwg") DO "C:\Program Files\Autodesk\AutoCAD 2013\AcCoreConsole.exe" /i "%%f" /s "C:\Test\Batch_Plot.scr" /l en-US&lt;BR /&gt;echo Pause when done. Hit [Enter] to continue...&lt;BR /&gt;pause&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Batch_Plot.scr file -&lt;/P&gt;
&lt;P&gt;(command "tilemode" "0")&lt;BR /&gt;(command "-plot" "y" "Layout1" "\\\\CTASERVER\\Brother MFC-J6520DW Printer" "A3 (297 x 420 mm)" "M" "L" "N" "e" "F" "" "Y" "" "Y" "y" "N" "N" "n" "N" "y" ) &lt;BR /&gt;(setvar"DynMode" 0)&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jun 2015 18:10:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/batch-printing-lsp/m-p/5683486#M140738</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-06-18T18:10:09Z</dc:date>
    </item>
    <item>
      <title>Re: Batch Printing LSP</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/batch-printing-lsp/m-p/5683535#M140739</link>
      <description>&lt;P&gt;I recomend using a .cmd-file to run the script.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;@echo off
setlocal EnableDelayedExpansion
cls
echo.
echo. Starting batch plott....
Echo.
ping -n 3 127.0.0.1 &amp;gt;nul
echo.
rem ;check if the exe-file exist
if not exist "%programfiles%\Autodesk\AutoCAD 2012 - English\acad.exe" goto err1
rem ;check if lisp-file exist 
if not exist plott.lsp goto err2
rem ;defun y is to prevent an error if the drawing is not in read only mode
for %%z in (*.dwg) do echo Open "%%z" (defun c:y()(princ)) y (load "plott.lsp") pline 0,0 0,1 1,1 c close y&amp;gt;&amp;gt;tmp.scr
echo.
echo. Running script in AutoCAD...
echo.
"%programfiles%\Autodesk\AutoCAD 2012 - English\acad.exe" /B tmp.scr
ping -n 3 127.0.0.1 &amp;gt;nul
goto done


goto end
:err1
echo.
echo. Autocad exicutable is not found!
echo.
goto end
:errl2
echo.
echo. The lisp-file is not found!
echo. 
:Done
if exist tmp.scr del tmp.scr
echo.
ping -n 3 127.0.0.1 &amp;gt;nul
:end
echo.
echo.
echo. This window is closing in 10 sek....
ping -n 10 127.0.0.1 &amp;gt;nul&lt;/PRE&gt;&lt;P&gt;Change the version of autocad and name of lisp-file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Place the cmd and lsp-file in the folder you want to plot and run the cmd-file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/Micke&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jun 2015 18:30:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/batch-printing-lsp/m-p/5683535#M140739</guid>
      <dc:creator>Micke_ELE</dc:creator>
      <dc:date>2015-06-18T18:30:17Z</dc:date>
    </item>
    <item>
      <title>Re: Batch Printing LSP</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/batch-printing-lsp/m-p/5683556#M140740</link>
      <description>&lt;P&gt;I have done something similar before with a lisp function and no bat file.&amp;nbsp; You will need to write a couple of lines fo code to a file named acad.lsp, or acaddco.lsp.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;you will need to write a s::startup function to be ran when the drawing file opens.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(defun S::STARTUP () (custom-plot args))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Matthew&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jun 2015 18:32:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/batch-printing-lsp/m-p/5683556#M140740</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-06-18T18:32:41Z</dc:date>
    </item>
    <item>
      <title>Re: Batch Printing LSP</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/batch-printing-lsp/m-p/5685090#M140741</link>
      <description>&lt;P&gt;Thanks very much guys. I am very much a beginner when it comes to this sort of thing but I shall try to pick from what you guys have said, shoudl help me learn &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jun 2015 12:53:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/batch-printing-lsp/m-p/5685090#M140741</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-06-19T12:53:22Z</dc:date>
    </item>
  </channel>
</rss>

