Jump to content

question about batch, lisp, script files


Recommended Posts

Posted

todouble22 & Lee Mac,

I just saw this thread, very interesting. I too have been running a .bat, .scp and .lsp routine to clean up multiple drawings at one time. Very annoying the whole [(command ".quit"); Quit AutoCAD] deal at the end of the .lsp routine that closes AutoCAD. I too tried to substitute a close command in place of the quit, no luck. I messed around with it for EVER with no success. So I gave up. Then I saw Lee Mac’s solution for you. WOW!!! That whole “Script Maker” thing is awesome. I got it to work pretty fast and it works nice. I put the “Script Maker” and the “Purger” .lsp in my “acad.lsp” start up so my “Script line” is a little different; [open *file* purger save y close]. I had to add 2 spaces after the save and a Y because it keep coming up with “file already exist do you want to replace”.

The problem I’m having now is trying to get my old clean up .lsp to work in the place of the purger .lsp Lee Mac provided. For some reason it opens the first drawing performs the clean up then stops. Do you guys know what I’m doing wrong?

 

I attached my clean up.lsp I use.

DCU-Drawing Clean Up.lsp

  • Replies 68
  • Created
  • Last Reply

Top Posters In This Topic

  • todouble22

    25

  • Lee Mac

    19

  • dbroada

    10

  • BIGAL

    4

Posted
todouble22 & Lee Mac,

 

I just saw this thread, very interesting. I too have been running a .bat, .scp and .lsp routine to clean up multiple drawings at one time. Very annoying the whole [(command ".quit"); Quit AutoCAD] deal at the end of the .lsp routine that closes AutoCAD. I too tried to substitute a close command in place of the quit, no luck. I messed around with it for EVER with no success. So I gave up. Then I saw Lee Mac’s solution for you. WOW!!! That whole “Script Maker” thing is awesome. I got it to work pretty fast and it works nice. I put the “Script Maker” and the “Purger” .lsp in my “acad.lsp” start up so my “Script line” is a little different; [open *file* purger save y close]. I had to add 2 spaces after the save and a Y because it keep coming up with “file already exist do you want to replace”.

 

The problem I’m having now is trying to get my old clean up .lsp to work in the place of the purger .lsp Lee Mac provided. For some reason it opens the first drawing performs the clean up then stops. Do you guys know what I’m doing wrong?

 

I attached my clean up.lsp I use.

 

 

Hi BlownBigBlock,

 

I'm glad you like the program - I shall take a look at your LISP and see what I can do :)

Posted

Give this a shot mate:

 

(DEFUN C:DCU (/ *error* ACAD DICTOBJ DOC OV SS VL)
 (vl-load-com)
 ;; Lee Mac  ~  14.01.10

 (defun *error* (msg)
   (and ov (mapcar (function setvar) vl ov))
   (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
       (princ (strcat "\n** Error: " msg " **")))
   (princ))

 (setq doc (vla-get-ActiveDocument
             (setq acad (vlax-get-acad-object))))

 (setq vl '("QAFLAGS" "CMDECHO")
       ov  (mapcar (function getvar) vl))
 
 (mapcar (function setvar) vl '(1 0))

 (foreach x '(1 0)
   (setvar "TILEMODE" x)
   (vla-ZoomExtents acad)
   
   (if (setq ss (ssget "_X" '((0 . "MTEXT"))))
     (vl-cmdf "_.explode" ss "")))

 (repeat 3 (vla-purgeall doc))

 (vl-catch-all-apply
   (function vla-remove)
     (list (vla-getExtensionDictionary
             (vla-get-Layers doc)) "AcLyDictionary"))

 (if (vl-catch-all-error-p
       (setq DictObj (vl-catch-all-apply
                       (function vla-item)
                         (list (vla-get-Dictionaries doc) "AcStStandard"))))
   (princ "\n<< No Attached DWS Files >>")
   (progn
     (vla-delete DictObj)
     (princ (strcat "\n<< Deleted " (itoa (vla-get-Count DictObj)) " DWS File Associations >>"))))

 (command "_.mview" "_L" "ON" "All" "")

 (vla-auditinfo doc :vlax-true)

 (mapcar (function setvar)
         '("CLAYER" "CECOLOR" "CELTYPE" "CELWEIGHT" "SETBYLAYERMODE")
         '("0" "ByLayer" "ByLayer" -1 103))

 (foreach x '(0 1)
   (setvar 'TILEMODE x)
   (vl-cmdf "_.setbylayer" "_all" "" "_N" "_N"))

 (setenv "DefaultFormatForSave" "12")
 (vla-save doc)
             
 (mapcar (function setvar) vl ov)
 (princ))

 

Code for Script-Line:

 

_open *file* (c:DCU) _close

 

Lee

Posted
todouble22 & Lee Mac,

 

I just saw this thread, very interesting. I too have been running a .bat, .scp and .lsp routine to clean up multiple drawings at one time. Very annoying the whole [(command ".quit"); Quit AutoCAD] deal at the end of the .lsp routine that closes AutoCAD. I too tried to substitute a close command in place of the quit, no luck. I messed around with it for EVER with no success. So I gave up. Then I saw Lee Mac’s solution for you. WOW!!! That whole “Script Maker” thing is awesome. I got it to work pretty fast and it works nice. I put the “Script Maker” and the “Purger” .lsp in my “acad.lsp” start up so my “Script line” is a little different; [open *file* purger save y close]. I had to add 2 spaces after the save and a Y because it keep coming up with “file already exist do you want to replace”.

 

The problem I’m having now is trying to get my old clean up .lsp to work in the place of the purger .lsp Lee Mac provided. For some reason it opens the first drawing performs the clean up then stops. Do you guys know what I’m doing wrong?

 

I attached my clean up.lsp I use.

I think it may be that you have qsave and quit in your lisp routine?

Posted
Give this a shot mate:

 

(DEFUN C:DCU (/ *error* ACAD DICTOBJ DOC OV SS VL)
 (vl-load-com)
 ;; Lee Mac  ~  14.01.10

 (defun *error* (msg)
   (and ov (mapcar (function setvar) vl ov))
   (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
       (princ (strcat "\n** Error: " msg " **")))
   (princ))

 (setq doc (vla-get-ActiveDocument
             (setq acad (vlax-get-acad-object))))

 (setq vl '("QAFLAGS" "CMDECHO")
       ov  (mapcar (function getvar) vl))

 (mapcar (function setvar) vl '(1 0))

 (foreach x '(1 0)
   (setvar "TILEMODE" x)
   (vla-ZoomExtents acad)

   (if (setq ss (ssget "_X" '((0 . "MTEXT"))))
     (vl-cmdf "_.explode" ss "")))

 (repeat 3 (vla-purgeall doc))

 (vl-catch-all-apply
   (function vla-remove)
     (list (vla-getExtensionDictionary
             (vla-get-Layers doc)) "AcLyDictionary"))

 (if (vl-catch-all-error-p
       (setq DictObj (vl-catch-all-apply
                       (function vla-item)
                         (list (vla-get-Dictionaries doc) "AcStStandard"))))
   (princ "\n<< No Attached DWS Files >>")
   (progn
     (vla-delete DictObj)
     (princ (strcat "\n<< Deleted " (itoa (vla-get-Count DictObj)) " DWS File Associations >>"))))

 (command "_.mview" "_L" "ON" "All" "")

 (vla-auditinfo doc :vlax-true)

 (mapcar (function setvar)
         '("CLAYER" "CECOLOR" "CELTYPE" "CELWEIGHT" "SETBYLAYERMODE")
         '("0" "ByLayer" "ByLayer" -1 103))

 (foreach x '(0 1)
   (setvar 'TILEMODE x)
   (vl-cmdf "_.setbylayer" "_all" "" "_N" "_N"))

 (setenv "DefaultFormatForSave" "12")
 (vla-save doc)

 (mapcar (function setvar) vl ov)
 (princ))

 

Code for Script-Line:

 

_open *file* (c:DCU) _close

 

Lee

damn you're good bro.

Posted

Another way to do it. We have a call in our acad.lsp routines to call a lisp call batch.lsp. On a typical day this batch.lsp just has this line:

 

(defun BATCH (/)

(princ "Batch Process Loaded")

(princ)

)

 

But on the server we have .bat file that over write that batch.lsp with a modified version that does everything from batch plotting to titleblock cleanup etc..

 

The only problem is that is you don't reset the batch.lsp (with a .bat file from the pulldown) then anytime you open a drawing it will run through the batch.lsp file that is currently loaded.

 

It is antiquated but it does work well as long as you don't forget to reset it.

Posted

Anyone knows if there is a limit for script length in acad?

Posted
Anyone knows if there is a limit for script length in acad?
not sure but some of my scripts are more than 5000 lines long. If there is a limit it is probably more a windows file size limit than an AutoCAD one.

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...