Page 2 of 2 FirstFirst 12
Results 11 to 13 of 13

Thread: Script to execute lisp on multiple drawings

  1. #11
    Past Vice President / AUGI Volunteer peter's Avatar
    Join Date
    2000-09
    Location
    Honolulu HI
    Posts
    1,109
    Login to Give a bone
    0

    Default Re: Script to execute lisp on multiple drawings

    I would suggest creating a dbx routine to change multiple drawings without having to open them. If you are interested I can post some code to get your started.


    Peter Jamtgaard

  2. #12
    Member jrd.chapman's Avatar
    Join Date
    2000-11
    Location
    Ontario, Canada
    Posts
    49
    Login to Give a bone
    0

    Default Re: Script to execute lisp on multiple drawings

    I would suggest creating a dbx routine to change multiple drawings without having to open them. If you are interested I can post some code to get your started
    That would be great Peter! Always eager to try and learn new things.

  3. #13
    Login to Give a bone
    0

    Default Re: Script to execute lisp on multiple drawings

    I would like to add the following lines after ;; open/make a scriptfile to write to But i see at the command prompt the open command is still active which leads to filedia 0 again
    even though i make filedia to 1 before (close File#1)

    (setq UserCat (vl-filename-directory UserFile))
    (setq FileList (vl-directory-files UserCat "*.dwg" 1))
    (setq File#1 (open "c:/Lockup.scr" "w"))
    ;; open/make a scriptfile to write to
    (princ "setvar\n" File#1)
    (princ "filedia\n" File#1)
    (princ "0\n" File#1)

    (foreach DwgName FileList
    (setq FileName (strcat "\"" UserCat "\\" DwgName "\""))
    (princ "open\n" File#1)
    (princ (strcat FileName "\n") File#1)
    ;;Below are commands to run on each drawing...
    (princ "audit\n" File#1)
    (princ "Y\n" File#1)
    (princ "(load \"BatchLockRun.vlx\")\n" File#1)
    (princ "(C:BATCHLOCKRUN)\n" File#1)
    (princ "audit\n" File#1)
    (princ "Y\n" File#1)
    (princ "_.qsave\n" File#1)
    (princ "_.close\n" File#1)
    )
    (princ "setvar\n" File#1)
    (princ "filedia\n" File#1)
    (princ "1\n" File#1)

    (close File#1)
    (command "script" "C:\\Lockup.scr")






    Quote Originally Posted by jrd.chapman View Post
    Just thought I'd share the finished product. Modified Kennet's code (thank you so much again kennet...what I've learned about creating a script from within Lisp is invaluable and I will use it a lot in future applications...)

    It is working like a charm so far....Here is what I came up with:
    Code:
    (defun c:BatchLock
    	   (/ UserFile UserCat FileList File#1 DwgName FileName)
      (vl-load-com)
      (setq UserFile
      (getfiled "Select a drawing within the directory to process"
    	 "c:/"
    	 "dwg"
    	 16
      )
      )
      (setq UserCat (vl-filename-directory UserFile))
      (setq FileList (vl-directory-files UserCat "*.dwg" 1))
      (setq File#1 (open "c:/Lockup.scr" "w"))
      ;; open/make a scriptfile to write to
      (foreach DwgName FileList
    	(setq FileName (strcat "\"" UserCat "\\" DwgName "\""))
    	(princ "open\n" File#1)
    	(princ (strcat FileName "\n") File#1)
    	;;Below are commands to run on each drawing...	
    	(princ "audit\n" File#1)
    	(princ "Y\n" File#1)
    	(princ "(load \"BatchLockRun.vlx\")\n" File#1)
    	(princ "(C:BATCHLOCKRUN)\n" File#1)
    	(princ "audit\n" File#1)
    	(princ "Y\n" File#1)
    	(princ "_.qsave\n" File#1)
    	(princ "_.close\n" File#1)
      )
      (close File#1)
      (command "script" "C:\\Lockup.scr")
      (princ)
    )
    (princ "\nBatchLock loaded.")
    (princ)
    Thanks again to everyone for their help!!

Page 2 of 2 FirstFirst 12

Similar Threads

  1. 2015: AutoCAD LT Script that changes multiple attributes across multiple drawings
    By alecgburke704194 in forum AutoCAD LT - General
    Replies: 1
    Last Post: 2015-06-30, 12:21 PM
  2. Script for changing UCS in multiple drawings
    By marcusnewport in forum AutoCAD General
    Replies: 2
    Last Post: 2010-05-25, 01:56 PM
  3. How to run a LISP routine on multiple drawings?
    By jmoore284 in forum AutoLISP
    Replies: 3
    Last Post: 2008-05-06, 05:24 AM
  4. Updating multiple computers using a script or LISP file
    By Chris.Partin in forum AutoCAD Customization
    Replies: 9
    Last Post: 2007-08-22, 04:34 PM
  5. Execute AutoCAD through a VB Script file (.vbs)?
    By abdulhuck in forum VBA/COM Interop
    Replies: 5
    Last Post: 2007-02-22, 06:16 AM

Posting Permissions

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