Delecting a names block accross many file script.scr

Delecting a names block accross many file script.scr

bbrummon
Contributor Contributor
350 Views
3 Replies
Message 1 of 4

Delecting a names block accross many file script.scr

bbrummon
Contributor
Contributor

Hi all,

 

I am using AutoCad Electrical 2015.  I need to delete a named block accorss 900 drawings.  From the project tab the is a utilities that will let me run a script file ( .scr not .lsp ) accross all the files.  I have tried the following in my scr file:

 

; Erase the ANSI-D_22x34 block

(command "erase" (SSGET "X" '((0 . "INSERT") (2 . "ANSI-D_22x34" ))) "")

QSAVE

CLOSE

 

;Blank line above to end the command

 

This seems to work on the 1st open file but then just stops running.  If I try to run it from the manage tab, Run Script. I get a error dialog that pops up and says "Filename of the drawing".scr not found

 

Thanks,

 

Bob

0 Likes
351 Views
3 Replies
Replies (3)
Message 2 of 4

Shneuph
Collaborator
Collaborator

When I have had to batch process drawings in this manner in the past I have created a temporary acaddoc.lsp file with code similar to what you have written.  Then open drawings 10 at a time.  It should run, save, and close them.  You could possibly do more than 10 at a time as well.

 

Just be careful to save original acaddoc.lsp and not to have it run on drawings you don't intent it to run on.

 

It's not the most elegant solution but it has worked for me to batch process files in the past.

---sig---------------------------------------
'(83 104 110 101 117 112 104 64 71 109 97 105 108 46 99 111 109)
0 Likes
Message 3 of 4

bbrummon
Contributor
Contributor

Just got it working.  It would seem that .scr file don't like white space.  In my file I now have just the following 2 lines:

 

(command "erase" (SSGET "X" '((0 . "INSERT") (2 . "ANSI-D_22x34" ))) "")
; Blank line above to end LAYER command

 

It works just fine now.  If I add any blank lines or more comments it fails.

 

Bob

0 Likes
Message 4 of 4

m_badran
Advocate
Advocate

Put your syntax in file as lisp and make loaded each time you start AutoCAD.

(defun c:eraseblock()
  (command "erase"
	   (SSGET "X" '((0 . "INSERT") (2 . "ANSI-D_22x34")))
	   ""
  )
(princ)
)

Prepare your script

open
"yourdrawingpath\mydrawing1.dwg"
eraseblock
CLOSE 
open
"yourdrawingpath\mydrawing2.dwg"
eraseblock
CLOSE 

 

0 Likes