Jump to content

Recommended Posts

Posted

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:

 

;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!!

Posted

Use a Script to:

 

  • Open drawing.

 

  • Load LISP program.

 

  • Run LISP program.

 

  • Save drawing.

 

  • Close drawing.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...