See the top rated post in this thread. Click here

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

Thread: How to create a routine to batch process files or a directory

  1. #11
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    5,480
    Login to Give a bone
    0

    Default Re: How to create a routine to batch process files or a directory

    Put the lisp in a *.scr file and use ScriptPro to run it on any file/files you want. No programming necessary.
    Last edited by Ed Jobe; 2018-12-20 at 03:20 PM.
    C:> ED WORKING....

  2. #12
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    5,480
    Login to Give a bone
    0

    Default Re: How to create a routine to batch process files or a directory

    BTW, ScriptPro is open source now, on GitHub.
    https://github.com/ADN-DevTech/Scrip...art-of-content
    C:> ED WORKING....

  3. #13
    100 Club
    Join Date
    2002-08
    Posts
    177
    Login to Give a bone
    0

    Default Re: How to create a routine to batch process files or a directory

    Or an another way with lisp.
    In a new drawing copy-paste the code below directely in command line and execute the command MAKE_SCRIPT
    Select a drawing in directory (any of them) to determine the folder to apply the script.
    At the end, use command SCRIPT and select the "treat_folder.scr" generated by the lisp
    Code:
    (defun c:make_script ( / prefix file_scr)
      (setq
        prefix (strcat (vl-filename-directory (getfiled "Select a drawing file as WITNESS in a directory" "" "dwg" 16)) "\\")
        file_scr (open (strcat prefix "treat_folder.scr") "w")
      )
      (foreach dwg (vl-directory-files prefix "*.dwg" 1)
        (write-line "_.open" file_scr)
        (write-line (strcat "\"" prefix dwg "\"") file_scr)
    ;;
    ;;start of customizable party
    ;;
    (write-line "((lambda ( / )" file_scr)
    (write-line "(foreach lay '(\"G-ANNO-TEXT\" \"M-HVAC-DUCT-IDEN\" \"M-HVAC-CDFF-IDEN\" \"A-ANNO-NOTE\" \"A-DETL\" \"G-ANNO-REVC-IDEN\" \"A-ANNO-MATC\")" file_scr)
    (write-line "(if (tblobjname \"layer\" lay)" file_scr)
    (write-line "(command \"_.-laydel\" \"_N\" lay \"\" \"_Y\")" file_scr)
    (write-line ")" file_scr)
    (write-line ")" file_scr)
    (write-line "))" file_scr)
    ;;
    ;;end of customizable party
    ;;
        (write-line "_.qsave" file_scr)
        (write-line "_.close" file_scr)
      )
      (close file_scr)
      (princ (strcat "\You can start SCRIPT :" prefix "treat_folder.scr"))
      (prin1)
    )
    I don't test it, I hope that I not have error syntax

  4. #14
    Programming Moderator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,360
    Login to Give a bone
    0

    Default Re: How to create a routine to batch process files or a directory

    Running Scripts within AutoCAD will process the drawings in series (one at a time).

    Core Console allows for processing drawings both in series and parallel (multiple at once).

    Here's a quick example that uses DOSLib to select multiple drawings for Core Console to process in parallel, just be mindful of how many drawings you choose to process at once, based on your workstation's CPU & RAM limitations:

    Quote Originally Posted by BlackBox View Post
    First take at replacing BSU.

    Here's the core LISP routine, which uses DOSLib to prompt for multiple drawing + .SCR (script) selection:

    ** Be sure to replace the text in red as needed **

    Code:
    (vl-load-com)
    
    (defun c:SCRM() (c:ScriptMultiple))
    (defun c:ScriptMultiple (/ app flag dwgs dwgPath script cprofile)
    ;;;
    ;;;  AcCoreConsole.exe [/i <input dwg>] /s <script>[/product <product>] [/l <language>]
    ;;;  [/isolate <userid> <userDataFolder>] [/readonly] [/p[rofile] <profile>] 
    ;;;
      (if
        (and
          (setq app (findfile "accoreconsole.exe"))
          (setq flag (dos_version))
          (setq dwgs
                 (dos_getfilem
                   "Select drawing(s) to process:"
                   (if *Dwg_LastPath*
                     *Dwg_LastPath*
                     (getvar 'dwgprefix)
                   )
                   "Drawing files (*.dwg)|*.dwg||"
                 )
          )
          (setq *Dwg_LastPath* (car dwgs))
          (setq dwgPath *Dwg_LastPath*)
          (setq dwgs (cdr dwgs))
          (setq script
                 (dos_getfiled
                   "Select a Script to run:"
                   (if *Script_LastPath*
                     *Script_LastPath*
                     "C:\\ProgramData\\Autodesk\\C3D 2019\\BatchSaveTool\\Scripts"
                   )
                   "Script (*.scr)|*.scr||"
                 )
          )
          (setq *Script_LastPath* (vl-filename-directory script))
          (setq cprofile (getvar 'cprofile))
        )
         (progn
           (foreach dwg dwgs
             (startapp
               (strcat
                 "\""
                 app
                 "\" /i \""
                 dwgPath
                 dwg
                 "\" /s \""
                 script
                 "\" /product \"C3D\" /p \""
                 cprofile
                 "\""
               )
             )
           )
         )
         (cond
           (dwgs (prompt "\n** No script selected ** \n"))
           (flag (prompt "\n** No drawing(s) selected ** \n"))
           (app (prompt "\n** DOSLib required ** \n"))
           ((prompt
              "\n** Unable to find \"AcCoreConsole.exe\" in support paths ** \n"
            )
           )
         )
      )
      (princ)
    )
    Cheers
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3620, Core i7-7700K 4.2GHz, 32GB RAM, Samsung 970 Pro M.2, 8GB NVIDIA Quadro P4000

  5. #15
    I could stop if I wanted to aaronic_abacus's Avatar
    Join Date
    2006-04
    Posts
    380
    Login to Give a bone
    0

    Default Re: How to create a routine to batch process files or a directory

    Create-a-list-of-drawings-and-write-them-to-a-text-file

    http://forums.augi.com/showthread.ph...hlight=lookdbd
    Last edited by aaronic_abacus; 2019-01-07 at 11:27 PM.

    http://www.watsonlisp.com

    Artificial Intelligence for AutoCAD
    Find detail drawings by text and attribute content!
    6000 lines of code and and in development since 1997.

Page 2 of 2 FirstFirst 12

Similar Threads

  1. 2013: batch process for modifying multiple files
    By andres_t in forum AutoCAD General
    Replies: 2
    Last Post: 2012-12-21, 06:00 AM
  2. Replies: 2
    Last Post: 2012-08-08, 10:13 AM
  3. Batch Process files to a earlier version using Save AS
    By mserapiglia in forum CAD Management - General
    Replies: 5
    Last Post: 2009-01-24, 12:37 AM
  4. Batch routine to clean up Blocks within DWG files
    By george.arq in forum AutoLISP
    Replies: 3
    Last Post: 2007-01-25, 12:33 PM
  5. Replies: 3
    Last Post: 2006-08-04, 07:02 PM

Posting Permissions

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