Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Batch processing .lsp routine to multiple drawings

  1. #1
    Member
    Join Date
    2009-05
    Posts
    22
    Login to Give a bone
    0

    Default Batch processing .lsp routine to multiple drawings

    Hi all,

    Hope I am not asking the obvious here, but a quick search didn't turn up results...

    How do I batch run a .lsp file over a number of drawings? I used to have a .vlx program called runbatch which did the job nicely however it no longer works with AutoCAD 2011. I have only a very basic knowledge of LISP.

    cheers
    Simon

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

    Default Re: Batch processing .lsp routine to multiple drawings

    You could create a script (.SCR) file.

    Provided your .LSP is loaded with ACADDOC.lsp, place a command call (for your .LSP) after each drawing is opened, run your command, then save and move onto the next drawing... etc.
    "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

  3. #3
    Certifiable AUGI Addict
    Join Date
    2015-11
    Location
    Jo'burg SA
    Posts
    4,512
    Login to Give a bone
    0

    Default Re: Batch processing .lsp routine to multiple drawings

    There are various ways. The 3 "easiest" is to install one of the following proggies:
    The 1st is the easiest to run your LSPs on several drawings ... not the least error prone though. For the other 2 you need to write a SCR file which loads and runs your LSP. The one which works best with erroring DWGs is ADesks ScriptPro, but it only works on 32bit systems. The AutoScript works a lot similar to ScrPro, but runs directly inside ACad, I have found it to sometimes hang if the drawing's bad.

  4. #4
    Active Member
    Join Date
    2002-12
    Posts
    77
    Login to Give a bone
    0

    Default Re: Batch processing .lsp routine to multiple drawings

    The absolute easiest way is to rename your Acad.lsp (acad.lsp.old) then name your new lisp acad.lsp.

    Then just open the drawing that you want to process. (make sure that you comment our the defuns (they won't be necessary).

    When you are finished just do the opposite.

  5. #5
    Member
    Join Date
    2009-05
    Posts
    22
    Login to Give a bone
    0

    Default Re: Batch processing .lsp routine to multiple drawings

    Thanks all,

    I will try AutoScript as I am running a 64-bit system. I was aware of the option to run lisp on drawing open, but wanted to open run save and close on whole directories of files.

    cheers
    Simon

  6. #6
    Certifiable AUGI Addict
    Join Date
    2015-11
    Location
    Jo'burg SA
    Posts
    4,512
    Login to Give a bone
    0

    Default Re: Batch processing .lsp routine to multiple drawings

    Quote Originally Posted by TimSpangler View Post
    The absolute easiest way is to rename your Acad.lsp (acad.lsp.old) then name your new lisp acad.lsp.

    Then just open the drawing that you want to process. (make sure that you comment our the defuns (they won't be necessary).

    When you are finished just do the opposite.
    Only if you change the AcadLspAsDoc to 1 (which is not default, and IMO is not the best idea). In which case change the ACAD.LSP in Tim's post to ACADDOC.LSP - then you don't need to set any variables.

    Of course you still need to open the DWGs manually for the "automatic" lisp to run on them. Which you can script, but then you start loosing the ease of just selecting files and / or folders to run the lisp / script on. So yes, this would be "easiest" if there's a small amount of DWGs - opening them all in one go. But if you've got hundreds, it's not as simple - then the file/folder selection tools make more sense.

    There is a nice way of implementing Tim's suggestion though: You can place (say) a button on a toolbar which would rename-swap the ACADDOC.LSP files. Effectively turning the scripting on/off. But I'd only use this for a handful of DWGs at a time.

    If I want to perform the same tasks on multiple DWGs, I want to set it and forget it, so I can continue with something else: another reason AutoScript is "better" than ScriptPro ... SC will open a new session of ACad for each DWG in turn, so you constantly get this ACad window popping up (effectively bugging you each time), since AS runs inside one single ACad session this doesn't happen - you can work inside another ACad session without interruption.

  7. #7
    Member
    Join Date
    2009-05
    Posts
    22
    Login to Give a bone
    0

    Default Re: Batch processing .lsp routine to multiple drawings

    Ok, I have now run into another issue. AutoScript is now working as per expected, however I am not sure that it can solve my issue.

    The problem I have is with a 3rd party software addon that we use. After an update in version I now get a window pop-up giving me an error each time I open a drawing created with the old version.

    The plan was to clear the error (which I can do), but this doesn't seem to be possible as I can't seem to clear the dialogue box which pops up with scripts.....is this possible?

    All I need the script to do is an 'enter' - or ok on the dialogue box - and then I can run the commands to clear the problem. Are scripts capable of doing this? I have tried to put a delay and a few blank lines for 'enter' but no luck.

    cheers
    Simon

  8. #8
    Certifiable AUGI Addict
    Join Date
    2015-11
    Location
    Jo'burg SA
    Posts
    4,512
    Login to Give a bone
    0

    Default Re: Batch processing .lsp routine to multiple drawings

    Not normal scripts no - they have no way of interacting with dialogs. If you need to send keystrokes to a dialog then you'll need some ActiveX together with VBScripting:
    Code:
    (vl-load-com)
    ;;; Send keystrokes to the current window / dialog
    (defun SendKeys (keys / ws)
      (if (setq ws (vlax-get-or-create-object "WScript.Shell"))
        (progn
          (vl-catch-all-apply (vlax-Invoke ws 'SendKeys keys))
          (vlax-release-object ws)
        )
      )
    )
    You'll call it in the SCR file like (SendKeys "keystrokes"), e.g. to send an Enter:
    Code:
    (SendKeys "~")
    For more info on the SendKeys method: http://msdn.microsoft.com/en-us/libr...8VS.85%29.aspx

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

    Default Re: Batch processing .lsp routine to multiple drawings

    :: SIDEBAR ::

    Irneb,

    I'm finding "Wscript.Shell" (WS) to be potentially more useful, the more development I do.

    For example, I automated my employer's Project Archival process using the expected findfile, vl-mkdir, vl-directory-files, and vl-file-copy, etc.

    Now that I know about WS, I'm curious (before I go re-writing my code), do you think that WS is faster than ActiveX (obviously depending on the inherent task being performed)?
    "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

  10. #10
    Certifiable AUGI Addict
    Join Date
    2015-11
    Location
    Jo'burg SA
    Posts
    4,512
    Login to Give a bone
    0

    Default Re: Batch processing .lsp routine to multiple drawings

    I couldn't honestly tell you. I've never done a test like that. I'd think they wouldn't be much different speedwise if you don't create the object every time (i.e. try to re-use it). However, be careful when using COM objects outside of ACad - they're not released from RAM through the normal garbage collection (you have to release them manually).

Page 1 of 2 12 LastLast

Similar Threads

  1. Batch processing utility
    By Wish List System in forum AutoCAD Wish List
    Replies: 0
    Last Post: 2012-07-22, 12:22 AM
  2. How to run a LISP routine on multiple drawings?
    By jmoore284 in forum AutoLISP
    Replies: 3
    Last Post: 2008-05-06, 05:24 AM
  3. Reuse CAD Standards Check Options for Batch Processing
    By autocad.wishlist1734 in forum AutoCAD Wish List
    Replies: 0
    Last Post: 2007-01-29, 01:42 PM
  4. Replies: 27
    Last Post: 2007-01-08, 01:59 PM
  5. Replies: 7
    Last Post: 2006-08-18, 08:15 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
  •