+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Forum Newbie
    Using
    AutoCAD 2010
    Join Date
    Jun 2012
    Posts
    4

    Default Automate running lisp on folder of files

    Registered forum members do not see this ad.

    Hello,

    I'm an AutoLISP newbie and I need to iterate through a folder of .DWG files, running a lisp on each file one at a time with no prompts to the user. Can this be done in AutoLISP? Here is the lisp that will be run on each file:

    Code:
    ;delete_layers_except
    (vl-load-com)
    ;(defun c:demo  (/ aDoc name)
          (setvar 'Clayer "0")
          (repeat 4
                (vla-purgeall
                      (setq aDoc (vla-get-ActiveDocument
                                       (vlax-get-acad-object)))))
          (vlax-for
                 itm
                      (vla-get-layers aDoc)
                (if (and
                          (not (wcmatch
                                     (setq name (vla-get-name itm))
                                     "*|*"))
                          (not (eq name "0"))
                          (not (member name
                                       '("Fixture-Shapes"
                                         "CHECKLANE"
                                         ;"Arch-Wall-Interior (Construction)"
                                         ;"Arch-Wall-Interior"
                                         ;"Arch-Wall-Exterior"
                                         ))))
                      (progn
                            (vla-put-lock itm :vlax-false)
                            (vl-cmdf "_.-laydel" "_N" name "" "_Y"))
                      )
                )
          (repeat 4 (vla-purgeall aDoc))
          (princ)
     ;     )
          
    ;explode_all
    ;(defun c:explodeall ()
        (setvar "draworderctl" 0)
        (setvar "qaflags" 1)
        (command "._explode" (ssget "X" )"")
        (setvar "qaflags" 0)
    ;    )
    
    ;erase_hatch
    ;(defun c:nohatch ()
        ;(if (or (ssget '((0 . "HATCH"))) (ssget "_X" '((0 . "HATCH"))))
        (setq ss1 (ssget "X" '((0 . "HATCH"))))
        (command "_.erase" ss1 "")
    ;    )
    
    ;plot
    ;(defun c:pp ()
      (command "-plot" "no" "Layout1" "previous plot" "DWG to PDF" "" "" "")
      (princ) 
    ;  )
    Thank you!!

  2. #2
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    15,707

    Default

    Registered forum members do not see this ad.

    Use a Script to:
    • Open drawing.
    • Load LISP program.
    • Run LISP program.
    • Save drawing.
    • Close drawing.
    Lee Mac Programming

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

    Just another Swamper

Similar Threads

  1. lisp routine to automate coordinates
    By The Courage Dog in forum AutoLISP, Visual LISP & DCL
    Replies: 14
    Last Post: 23rd Jan 2010, 01:59 pm
  2. Print a List od Drawing files in a folder
    By Rhayes in forum AutoCAD Drawing Management & Output
    Replies: 4
    Last Post: 14th Mar 2008, 02:40 pm
  3. Files in folder respond slowly
    By EScholtz in forum AutoCAD Drawing Management & Output
    Replies: 3
    Last Post: 23rd Mar 2007, 02:24 pm
  4. How to view and open a Dwg Files in a Folder...???
    By vasqrainier in forum AutoLISP, Visual LISP & DCL
    Replies: 16
    Last Post: 29th Sep 2006, 12:24 am
  5. automate separating dwg parts to individual files
    By carvecream in forum AutoCAD General
    Replies: 15
    Last Post: 10th Oct 2005, 08:02 am

Tags for this Thread

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