Jump to content

HELP me improve this LISP


ttray33y

Recommended Posts

We were using this routine to update/redefine blocks inside a drawings in a directory (ei. 200 drawings) without user input upon invoking the "red" command"

The routine reads the dd_list.txt created from a batch file.

dir /b *.dwg > dd_list.txt

then R&W the list with Open, qSave, close command and loops thru the list until its done & creates the final script to execute.

AttDia
0
AttReq
0
-insert
"blockname=block path\drawing name.dwg"
0,0,0
1
1
0
(entdel(entlast))
AttReq
1
AttDia
1
;

 

please do suggest a better way or the fastest to achive the same routine. cheers

 

(defun c:red ( / ddlist red o_red d1 d2 dn)
(setq ddlist (findfile "dd_list.txt"))
(setq o_red (open "red.scr" "w"))
(setq red (findfile "red.scr"))
(setq d1 (open ddlist "r"))
(setq d2 (open red "a"))
(setq dn (read-line d1))

(while (/= dn nil)
  (princ "open" d2)
  (princ "\n" d2)
  (write-line dn d2)
  (princ "qsave" d2)
  (princ "\n" d2)
  (princ "close" d2)
  (princ "\n" d2)
  (setq dn (read-line d1))
)
(close d1)
(close d2)
(close o_red)
(command "script" "red")
)

Link to comment
Share on other sites

A bit simpler autoload the change part as a lisp then its just a simple script

 

open dwg1 (load "chges") close Y

open dwg2 (load "chges") close Y

 

; chges.lsp
(setvar "AttDia" 0)
(setvar "AttReq" 0)
(command "-insert" "blockname=block path\drawing name.dwg" 0,0,0 1 1 0)
(entdel(entlast))
(setvar "AttReq" 1)
(setvar "AttDia" 1)

Link to comment
Share on other sites

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