+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Forum Newbie
    Using
    AutoCAD 2018
    Join Date
    Nov 2017
    Posts
    2

    Question Adapting LISP to work with 2018

    Registered forum members do not see this ad.

    I have a routine that is used to batch run a scr on a directory of dwgs, via a toolbar button/macro. After clicking the button the user selects the first file in the target directory, clicks "OPEN", the dialog box re-opens and then the user clicks "CANCEL". At this point the specified script named in the macro is run on all of the dwgs in the directory not including the sub folders. The problem I'm having is that the lsp was functional with 2012 and 2014 but will not open and process any dwgs with 2018.

    Any help would be greatly appreciated.

    Macro text
    Code:
    ^C^C(LOAD"GSCRIPT") GSCRIPT MS-BUTTON N '_SCRIPT "C:/XXXXXX/XXXXX/AppData/Roaming/Autodesk/AutoCAD 2018/R22.0/enu/Support/MS-BUTTON.scr"
    Code:
    ;script file generator for multiple automated editing of drawings
    ;by Clint Moore
    ;;
    ;;
    ;;Revision:2.0
    ;;
    
    (defun c:gscript()
     (setq templ (getstring "\nName of Template script file :"))
     (initget 1 "Yes No")
     (setq ans (getkword "\nSave Changes made to drawings Yes/No: "))
     (if (= ans "Yes")
        (setq ans "No")
        (setq ans "Yes")
     )
     (setq str nil)
     (if (setq addscr (findfile (strcat templ ".scr")))
      (progn
       (setq dwglist nil)
       (while (setq dwg (getfiled "Select a Drawing File" "" "dwg" 0))
         (progn
             (setq cnt (strlen dwg)
                   str nil
             )
             (while (and (> cnt 0) (/= str "\\"))
               (setq str (substr dwg cnt 1))
               (setq cnt (1- cnt))
             )
             (if (= str "\\")
               (setq su 2)
               (setq su 1)
             )
             (setq s3 (substr dwg (+ su cnt)))
             (setq dpth (substr dwg 1 (- (strlen dwg) (strlen s3))))
             (setq s3 (substr s3 1 (- (strlen s3) 4)))
             (setq dwglist (append  dwglist (list (list s3 dpth))))
             (command "shell" (strcat "dir /b " dpth "*.dwg >" s3 ".lst" ""))
          )
       )
       (setq wlst "dwgprp.lst"
             wname "begin.scr"
             fnwl  (open wlst "r")
             fnw (open wname "w")
       )
       (foreach dwgnm dwglist
         (setq rname (strcat (nth 0 dwgnm) ".lst"))
         (setq fnr (open rname "r"))
         (while (setq dwg (read-line fnr))
           (write-line "Open" fnw)
           (write-line (strcat (nth 1 dwgnm) dwg) fnw)
           (setq tscr (open addscr "r"))
           (while (setq outline (read-line tscr))
              (write-line outline fnw)
           )
           (close tscr)
         )
         (close fnr)
       )
       (if (= ans "Yes")
          (write-line "exit  " fnw)
          (write-line "QSAVE" fnw)
       )
       (close fnw)
    
      )
      (prompt "Template script file not found")
     )
    ; (command "script" "begin")
    ) 
    	 
       
    

  2. #2
    Luminous Being
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    9,819

    Default

    It may be the "trusted paths" is not set for the deep deep path for the SCR

    2nd why not have a directory like c:\Myprogs which has all your lisps and scripts etc. so much easier to find.
    A man who never made mistakes never made anything

  3. #3
    Forum Newbie
    Using
    AutoCAD 2018
    Join Date
    Nov 2017
    Posts
    2

    Default

    Registered forum members do not see this ad.

    Quote Originally Posted by BIGAL View Post
    It may be the "trusted paths" is not set for the deep deep path for the SCR

    2nd why not have a directory like c:\Myprogs which has all your lisps and scripts etc. so much easier to find.
    GSCRIPT and MS-BUTTON.SCR reside in the same place.I have always used the support folder to house all of my SCRs and LSPs in the past, but I can try moving the template script file.

    The macro code used to look like the line below, but for some reason it doesn't work.
    Code:
    ^C^C(LOAD"GSCRIPT") GSCRIPT MS-BUTTON N SCRIPT BEGIN
    Which returns this.


    Command: (LOAD"GSCRIPT") C:GSCRIPT
    Command: GSCRIPT
    Name of Template script file :MS-BUTTON
    Save Changes made to drawings Yes/No: N shell
    OS Command: dir /b X:\Working\Drawings\11-6-2017\*.dwg >A-M-EP-0021-SH-1.lst
    Command: nil

    Command: SCRIPT
    Enter script file name <X:\Working\Drawings\11-6-2017\Drawing1.scr>: BEGIN



    To be honest I don't fully understand how this lisp functions and the original author isn't around anymore for me to seek his help.

Similar Threads

  1. AutoCAD 2018.1 and AutoCAD LT 2018.1 Update Now Available
    By Between the Lines in forum AutoCAD RSS Feeds
    Replies: 0
    Last Post: 28th Jul 2017, 01:10 am
  2. My Lisp does not work
    By jevrem1 in forum AutoLISP, Visual LISP & DCL
    Replies: 8
    Last Post: 30th May 2017, 01:01 pm
  3. A way to work around without lisp?
    By bubba74 in forum AutoLISP, Visual LISP & DCL
    Replies: 6
    Last Post: 8th Feb 2010, 09:55 pm
  4. trying to get this lisp to work
    By andrew361 in forum AutoLISP, Visual LISP & DCL
    Replies: 16
    Last Post: 26th Jun 2009, 11:00 pm
  5. Adapting lisp menu from ABS 2006 to AutoCAD 2006
    By rab in forum AutoLISP, Visual LISP & DCL
    Replies: 2
    Last Post: 31st Jan 2007, 03:01 pm

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts