Results 1 to 4 of 4

Thread: Redefine blocks in all drawings within a directory

  1. #1
    Woo! Hoo! my 1st post
    Join Date
    2015-07
    Posts
    1
    Login to Give a bone
    0

    Default Redefine blocks in all drawings within a directory

    Hi there,

    DOes anyone know of a lisp that will redefine a particular block in all drawings within a directory?

  2. #2
    Certifiable AUGI Addict tedg's Avatar
    Join Date
    2005-06
    Location
    in the upper right corner
    Posts
    3,507
    Login to Give a bone
    0

    Default Re: Redefine blocks in all drawings within a directory

    Quote Originally Posted by jeremy.mooring705792 View Post
    Hi there,

    DOes anyone know of a lisp that will redefine a particular block in all drawings within a directory?
    Well I'm not an "expert" in this matter but that type of thing can be done with a script.
    Basically redefining the block with the -insert command.
    Code:
    -insert
    "OLDBLOCK=C:\NEWBLOCK.dwg"
    0,0,0
    
    
    
    erase
    last
    
    qsave
    (you would use your block names and paths etc)
    I you have something like ScriptPro, you can make it happen to tons of drawings.

  3. #3
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: Redefine blocks in all drawings within a directory

    Quote Originally Posted by BlackBox View Post
    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
    Meaningless text so I can make this post.
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  4. #4
    Certifiable AUGI Addict tedg's Avatar
    Join Date
    2005-06
    Location
    in the upper right corner
    Posts
    3,507
    Login to Give a bone
    0

    Default Re: Redefine blocks in all drawings within a directory

    Quote Originally Posted by BlackBox View Post
    Meaningless text so I can make this post.
    LOL
    Not meaningless.. you are the MAN!
    Thanks for posting this here, another great option for batch running scripts.

Similar Threads

  1. Open all drawings in a directory, save, close.
    By JSimons in forum AutoLISP
    Replies: 18
    Last Post: 2020-05-08, 10:08 PM
  2. 2014: Wblock all drawings in a Directory
    By guardsman3 in forum AutoCAD General
    Replies: 5
    Last Post: 2013-04-25, 01:11 PM
  3. Redefine Blocks from Directory?
    By stusic in forum AutoLISP
    Replies: 3
    Last Post: 2012-10-24, 07:50 PM
  4. Search text within drawings, without actually opening drawings
    By Animesh Kundu in forum AutoCAD General
    Replies: 3
    Last Post: 2008-02-29, 05:34 PM
  5. I need to redefine a Block in over 100 drawings
    By Mamma Jamma in forum AutoCAD Customization
    Replies: 4
    Last Post: 2006-04-07, 09:17 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
  •