<?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: How to use script with lisp ? in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-use-script-with-lisp/m-p/6385180#M131410</link>
    <description>&lt;P&gt;Run command APPLOAD then select your script. You're my post 2,000 by-the-way&amp;nbsp;&lt;img id="smileyvery-happy" class="emoticon emoticon-smileyvery-happy" src="https://forums.autodesk.com/i/smilies/16x16_smiley-very-happy.png" alt="Smiley Very Happy" title="Smiley Very Happy" /&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 15 Jun 2016 15:46:26 GMT</pubDate>
    <dc:creator>wispoxy</dc:creator>
    <dc:date>2016-06-15T15:46:26Z</dc:date>
    <item>
      <title>How to use script with lisp ?</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-use-script-with-lisp/m-p/6384926#M131409</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can someone tell me the way use lisp and scrips:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;my idea:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. open file via browse foler or file to select folder&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. Run script run lisp&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#00ccff"&gt;(vl-load-com)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#ff0000"&gt;&lt;STRONG&gt;(foreach layout (layoutlist)&lt;/STRONG&gt;&lt;FONT color="#999999"&gt;; conveniently&amp;nbsp;returns list of all&amp;nbsp;Paper-space Layouts&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#ff0000"&gt;&lt;STRONG&gt;&amp;nbsp; (setvar 'ctab layout)&lt;/STRONG&gt;&lt;FONT color="#999999"&gt;; get into the Layout&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#ff0000"&gt;&lt;STRONG&gt;&amp;nbsp; (command "_.pspace")&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT color="#999999"&gt;; [in case it might be in &lt;EM&gt;Model&lt;/EM&gt; space through a Viewport in that Layout]&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;FONT color="#00ccff"&gt;(if (setq ss (ssget "x" (list '(0 . "INSERT") '(2 . "TITLEBLOCKA") (cons 410 (getvar "ctab")))))&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#00ccff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; (progn&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#00ccff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (vla-getboundingbox&amp;nbsp;(vlax-ename-&amp;gt;vla-object (ssname ss 0)) 'minpt 'maxpt)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#00ccff"&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; (setq LL (vlax-safearray-&amp;gt;list minpt));&amp;nbsp;Lower Left corner of block's &lt;EM&gt;contents&lt;BR /&gt;&lt;/EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; (command&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#00ccff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; "_.layer" "_thaw" "*" "_on" "*" "_unlock" "*" "" ;&amp;nbsp;make everything&amp;nbsp;movable&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#00ccff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "_.move"&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#00ccff"&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;(ssget "x" (list (cons 410 (getvar "ctab")))) ""&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#00ccff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; LL '(0.0 0.0 0.0)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#00ccff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; "_.layerp" ; return previous Layer settings&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#00ccff"&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; ); end command&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#00ccff"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ); end progn&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#00ccff"&gt;&amp;nbsp; ); end if&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#ff0000"&gt;&lt;STRONG&gt;)&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT color="#999999"&gt;; foreach&lt;/FONT&gt;&lt;/P&gt;&lt;DIV class="UserSignature lia-message-signature"&gt;Kent Cooper&lt;/DIV&gt;&lt;DIV class="UserSignature lia-message-signature"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="UserSignature lia-message-signature"&gt;3. save and close.&lt;/DIV&gt;&lt;DIV class="UserSignature lia-message-signature"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="UserSignature lia-message-signature"&gt;Thanks for solution. ^_^&lt;/DIV&gt;</description>
      <pubDate>Wed, 15 Jun 2016 14:18:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-use-script-with-lisp/m-p/6384926#M131409</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-06-15T14:18:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to use script with lisp ?</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-use-script-with-lisp/m-p/6385180#M131410</link>
      <description>&lt;P&gt;Run command APPLOAD then select your script. You're my post 2,000 by-the-way&amp;nbsp;&lt;img id="smileyvery-happy" class="emoticon emoticon-smileyvery-happy" src="https://forums.autodesk.com/i/smilies/16x16_smiley-very-happy.png" alt="Smiley Very Happy" title="Smiley Very Happy" /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jun 2016 15:46:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-use-script-with-lisp/m-p/6385180#M131410</guid>
      <dc:creator>wispoxy</dc:creator>
      <dc:date>2016-06-15T15:46:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to use script with lisp ?</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-use-script-with-lisp/m-p/6385829#M131411</link>
      <description>&lt;P&gt;&amp;nbsp;Hi pony.chubby,&lt;BR /&gt;&lt;A href="https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/update-titleblock-insertion-point-or-move-border-frame-s-to-the/m-p/6384603#M342080" target="_blank"&gt;in your previous thread&lt;/A&gt; I did post a link to a post where you could get some ideas to start writing the code... &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One way...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Save Kent1Cooper's code in a 'Trusted Locations' folder, with the name you think best (e.x. "MyCode.lsp")&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;;; http://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/update-titleblock-insertion-point-or-move-border-frame-s-to-the/m-p/6383170#M342043
;; by Kent1Cooper
(vl-load-com)
(foreach layout (layoutlist); conveniently returns list of all Paper-space Layouts
  (setvar 'ctab layout); get into the Layout
  (command "_.pspace"); [in case it might be in Model space through a Viewport in that Layout]
  (if (setq ss (ssget "x" (list '(0 . "INSERT") '(2 . "TITLEBLOCKA") (cons 410 (getvar "ctab")))))
    (progn
      (vla-getboundingbox (vlax-ename-&amp;gt;vla-object (ssname ss 0)) 'minpt 'maxpt)
      (setq LL (vlax-safearray-&amp;gt;list minpt)); Lower Left corner of block's contents
      (command
        "_.layer" "_thaw" "*" "_on" "*" "_unlock" "*" "" ; make everything movable
        "_.move"
        (ssget "x" (list (cons 410 (getvar "ctab")))) ""
        LL '(0.0 0.0 0.0)
        "_.layerp" ; return previous Layer settings
      ); end command
    ); end progn
  ); end if
); foreach&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Change the command name to the name you think best, and change "MyCode.lsp" to the correct one.&lt;BR /&gt;Save the file in a 'Trusted Locations' folder.&lt;BR /&gt;Open a new dwg, load the code and type the new command name...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;;; Load Supporting Functions
;; Old Version of 'BrowseForFolder' by: Tony Tanzillo 
(defun BrowseForFolder (Message / sh folder parentfolder folderobject result)
   (vl-load-com)
   (setq sh (vla-getInterfaceObject (vlax-get-acad-object) "Shell.Application"))
   (setq folder (vlax-invoke-method sh 'BrowseForFolder 0 Message 0))
   (vlax-release-object sh)
   (if folder
      (progn
         (setq parentfolder (vlax-get-property folder 'ParentFolder))
         (setq FolderObject (vlax-invoke-method ParentFolder 'ParseName (vlax-get-property Folder 'Title)))
         (setq result (vlax-get-property FolderObject 'Path))
         (mapcar 'vlax-release-object
                 (list folder parentfolder folderobject)
         )
         (if (/= (substr result (strlen result)) "\\")
            (setq result (strcat result "\\"))
            result
         )
      )
   )
)


(defun c:demo (/ DirPath DwgFile DwgList my_lisp_file Ofile) ; &amp;lt;&amp;lt;&amp;lt; change the command name!!!
   (if (setq DirPath (BrowseForFolder "Select directory to scan drawings."))
      (progn
         (setq my_lisp_file "MyCode.lsp") ; &amp;lt;&amp;lt;&amp;lt; Place the correct lisp name here!!!
         (setq Scrfile (strcat DirPath "test.scr"))
         (setq ofile (open Scrfile "w"))
         (setq DwgList (vl-directory-files DirPath "*.dwg" 1))
         (foreach Dwg DwgList
            (setq DwgFile (strcat DirPath Dwg))
            (write-line (strcat "_.open\r" (chr 34) DwgFile (chr 34) "\r") Ofile)
            (write-line (strcat "(load " (chr 34) my_lisp_file (chr 34) ")") Ofile)
            (write-line "_.qsave" Ofile)
            (write-line "_.close" Ofile)
         )
         (close Ofile)
         (command "_.script" Scrfile)
         (vla-sendcommand (vla-get-activedocument (vlax-get-acad-object)) "(vl-file-delete Scrfile)\r")
      )
   )
   (princ)
)&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps, &lt;BR /&gt;Henrique&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jun 2016 19:57:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-use-script-with-lisp/m-p/6385829#M131411</guid>
      <dc:creator>hmsilva</dc:creator>
      <dc:date>2016-06-15T19:57:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to use script with lisp ?</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-use-script-with-lisp/m-p/6386282#M131412</link>
      <description>&lt;P&gt;right, exactly&amp;nbsp;&lt;SPAN&gt;Henrique&amp;nbsp;&lt;img id="heart" class="emoticon emoticon-heart" src="https://forums.autodesk.com/i/smilies/16x16_heart.png" alt="Heart" title="Heart" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and question:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can select TITLEBLOCK by ssget and name of TITLEBLOCK then run lisp Kent1Cooper ? Because TITLEBLOCK maybe is TITLEBLOCK 1, TITLEBLOCK, .....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your help.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jun 2016 23:57:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-use-script-with-lisp/m-p/6386282#M131412</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-06-15T23:57:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to use script with lisp ?</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-use-script-with-lisp/m-p/6386290#M131413</link>
      <description>&lt;P&gt;You're welcome!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Change the&lt;/P&gt;
&lt;P&gt;(2 . "TITLEBLOCKA")&lt;/P&gt;
&lt;P&gt;to your titleblock names&lt;/P&gt;
&lt;P&gt;(2 . "TITLEBLOCKA,TITLEBLOCKB,TITLEBLOCKX")&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Henrique&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jun 2016 00:04:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-use-script-with-lisp/m-p/6386290#M131413</guid>
      <dc:creator>hmsilva</dc:creator>
      <dc:date>2016-06-16T00:04:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to use script with lisp ?</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-use-script-with-lisp/m-p/6386303#M131414</link>
      <description>&lt;P&gt;No, i mean:&lt;/P&gt;&lt;P&gt;(setq insert (entsel&amp;nbsp;"\nSelect TITLEBLOCK in drawing"))&lt;/P&gt;&lt;P&gt;(setq name (cdr (assoc 2 (entget insert))))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;how can assign to : (ssget "X" .......... name) in ssget.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jun 2016 00:14:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-use-script-with-lisp/m-p/6386303#M131414</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-06-16T00:14:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to use script with lisp ?</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-use-script-with-lisp/m-p/6386500#M131415</link>
      <description>&lt;P&gt;i am trying:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(setq ename (entget (car (entsel "\nSelect TitleBlock: "))))&lt;BR /&gt;(setq name_title (assoc 2 ename))&lt;/P&gt;&lt;P&gt;(if (setq ss (ssget "x" (list '(0 . "INSERT") name_title (cons 410 (getvar "ctab")))))&lt;BR /&gt;(progn&lt;/P&gt;&lt;P&gt;......&lt;/P&gt;&lt;P&gt;&amp;nbsp;That is clear for me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can u see it Henrique !&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your solution&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jun 2016 04:40:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-use-script-with-lisp/m-p/6386500#M131415</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-06-16T04:40:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to use script with lisp ?</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-use-script-with-lisp/m-p/6386696#M131416</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i tried in my pc is ok&lt;/P&gt;&lt;P&gt;but path file in server error:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;; error: bad argument type: streamp nil&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;how can fix it.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jun 2016 07:47:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-use-script-with-lisp/m-p/6386696#M131416</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-06-16T07:47:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to use script with lisp ?</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-use-script-with-lisp/m-p/6386752#M131417</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous wrote:&lt;BR /&gt;
&lt;P&gt;i am trying:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(setq ename (entget (car (entsel "\nSelect TitleBlock: "))))&lt;BR /&gt;(setq name_title (assoc 2 ename))&lt;/P&gt;
&lt;P&gt;(if (setq ss (ssget "x" (list '(0 . "INSERT") name_title (cons 410 (getvar "ctab")))))&lt;BR /&gt;(progn&lt;/P&gt;
&lt;P&gt;......&lt;/P&gt;
&lt;P&gt;&amp;nbsp;That is clear for me.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can u see it Henrique !&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for your solution&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;To run the script in a folder, we can't have one of the dwg's in that folder opened... &lt;U&gt;we need to have all dwg's in that folder closed&lt;/U&gt;...otherwise the code will error...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have a dwg in another folder with the same TitleBlock, you can modify Kent1Cooper's code, as a function with one argumente&lt;/P&gt;
&lt;P&gt;i.e.&lt;/P&gt;
&lt;PRE&gt;(defun MyCode (name_title / ll minpt ss)
   ;; http://forums.autodesk.com/t5/visual-lisp-autolisp?-and-general/update-titleblock-insertion-point-or-?move-border-frame-s-to-the/m-p/6383170#M342043
   ;; by Kent1Cooper
   (vl-load-com)
   (foreach layout (layoutlist) ; conveniently returns list of all Paper-space Layouts
      (setvar 'ctab layout) ; get into the Layout
      (command "_.pspace") ; [in case it might be in Model space through a Viewport in that Layout]
      (if (setq ss (ssget "x" (list '(0 . "INSERT") (cons 2 name_title) (cons 410 (getvar "ctab")))))
         (progn
            (vla-getboundingbox (vlax-ename-&amp;gt;vla-object (ssname ss 0)) 'minpt 'maxpt)
            (setq LL (vlax-safearray-&amp;gt;list minpt)) ; Lower Left corner of block's contents
            (command "_.layer" "_thaw" "*" "_on" "*" "_unlock" "*" "" ; make everything movable
               "_.move" (ssget "x" (list (cons 410 (getvar "ctab")))) "" LL '(0.0 0.0 0.0)
               "_.layerp" ; return previous Layer settings
            ) ; end command
         ) ; end progn
      ) ; end if
   ) ; foreach
)&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and in the code to write and run the script&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;;; Load Supporting Functions
;; Old Version of 'BrowseForFolder' by: Tony Tanzillo 
(defun BrowseForFolder (Message / sh folder parentfolder folderobject result)
   (vl-load-com)
   (setq sh (vla-getInterfaceObject (vlax-get-acad-object) "Shell.Application"))
   (setq folder (vlax-invoke-method sh 'BrowseForFolder 0 Message 0))
   (vlax-release-object sh)
   (if folder
      (progn
         (setq parentfolder (vlax-get-property folder 'ParentFolder))
         (setq FolderObject (vlax-invoke-method ParentFolder 'ParseName (vlax-get-property Folder 'Title)))
         (setq result (vlax-get-property FolderObject 'Path))
         (mapcar 'vlax-release-object
                 (list folder parentfolder folderobject)
         )
         (if (/= (substr result (strlen result)) "\\")
            (setq result (strcat result "\\"))
            result
         )
      )
   )
)


(defun c:demo (/ dirpath dwgfile dwglist ent my_lisp_file name_title ofile sel) ; &amp;lt;&amp;lt;&amp;lt; change the command name!!!
   (if (and (setq DirPath (BrowseForFolder "Select directory to scan drawings."))
            (setq sel (car (entsel "\nSelect TitleBlock: ")))
            (= (cdr (assoc 0 (setq ent (entget sel)))) "INSERT")
            (setq name_title (cdr (assoc 2 (entget sel))))
       )
      (progn
         (setq my_lisp_file "MyCode.lsp") ; &amp;lt;&amp;lt;&amp;lt; Place the correct lisp name here!!!
         (setq Scrfile (strcat DirPath "test.scr"))
         (setq ofile (open Scrfile "w"))
         (setq DwgList (vl-directory-files DirPath "*.dwg" 1))
         (foreach Dwg DwgList
            (setq DwgFile (strcat DirPath Dwg))
            (write-line (strcat "_.open\r" (chr 34) DwgFile (chr 34) "\r") Ofile)
            (write-line (strcat "(load " (chr 34) my_lisp_file (chr 34) ")") Ofile)
            (write-line "(my_lisp_file name_title)" Ofile)
            (write-line "_.qsave" Ofile)
            (write-line "_.close" Ofile)
         )
         (close Ofile)
         (command "_.script" Scrfile)
         (vla-sendcommand (vla-get-activedocument (vlax-get-acad-object)) "(vl-file-delete Scrfile)\r")
      )
   )
   (princ)
)&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But remember, &lt;STRONG&gt;none of the dwg's to process can be open!&lt;/STRONG&gt;&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, 16 Jun 2016 08:27:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-use-script-with-lisp/m-p/6386752#M131417</guid>
      <dc:creator>hmsilva</dc:creator>
      <dc:date>2016-06-16T08:27:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to use script with lisp ?</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-use-script-with-lisp/m-p/6387869#M131418</link>
      <description>&lt;P&gt;Right ,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks Henrique again.&lt;img id="heart" class="emoticon emoticon-heart" src="https://forums.autodesk.com/i/smilies/16x16_heart.png" alt="Heart" title="Heart" /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jun 2016 16:44:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-use-script-with-lisp/m-p/6387869#M131418</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-06-16T16:44:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to use script with lisp ?</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-use-script-with-lisp/m-p/6387872#M131419</link>
      <description>&lt;P&gt;You're welcome!&lt;BR /&gt;Glad I could help &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;Henrique&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jun 2016 16:46:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-use-script-with-lisp/m-p/6387872#M131419</guid>
      <dc:creator>hmsilva</dc:creator>
      <dc:date>2016-06-16T16:46:34Z</dc:date>
    </item>
  </channel>
</rss>

