Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Batch LISP?

30 REPLIES 30
Reply
Message 1 of 31
avltcad
1704 Views, 30 Replies

Batch LISP?

Is there a way to apply a LISP file to a batch of files without opening each one and running the file on it?
30 REPLIES 30
Message 21 of 31
Anonymous
in reply to: avltcad

you cannot plot a dbx doc.
I believe this is because a dbx doc does not cause acad to generate a display list, or read the data to fill in any
settings a normal acad session would.
Its the raw database info, and you can only select with filter methods, not anything graphical.
You cannot do a regen on a dbx doc, and plotting essentially regens the drawing and spits out crunched info from display
list.

drago2dmax <>
|>Hi Tim.

|>Is it possible for the drawing to load xrefs when using ODBX method to open drawings. I like to plot using ODBX to but only if it see the Xrefs.

|>

|>Thanks
James Maeding
Civil Engineer and Programmer
jmaeding - at - hunsaker - dotcom
Message 22 of 31
drago2dmax
in reply to: avltcad

Thanks James
Its good to know.
Message 23 of 31
mayhap
in reply to: avltcad

If you are still having problems, i have a batchlisp file, thta you just change the name of lisp you want to run in every file, or it can be tweaked to just run simple commands without having to attach another lisp to it.

if you still need help emial me directly Edited by: mayhap on Aug 20, 2009 12:18 PM
Message 24 of 31
gilsoto13
in reply to: avltcad

Mayhap: Could I have your lisp for batching any lisp in multiple drawings?... If so... How could I email you? there are no private messages in this forum
Message 25 of 31
sdanis
in reply to: avltcad

Google 'Changing Hundredes of Autocad Drawings in a Hurry.
I ues this process all the time. It works great!
Message 26 of 31
avltcad
in reply to: avltcad

This works awesome, but there is one hitch; it does not seem to give my LISP enough time to run fully before saving the drawing, quitting and going on to the next drawing.

Is there a way to bypass this?
Message 27 of 31
sdanis
in reply to: avltcad

I only use the script file to load and run the lisp file.
Be sure to issue the save and quit commands at the end of lisp file.;
If you are still having problems I'll be happy to take a look and the lisp and script.

Your script and lisp should look something like this

Lisp:

(defun c:test()
(do something)
(command "qsave")
(command "quit")
);;defun

Script:
(load "directory/lisp file name")
test ;;;dont forget to include 1 enter Edited by: sdanis on Aug 29, 2009 1:05 AM
Message 28 of 31
avltcad
in reply to: avltcad

Attached is the script, lsp and bat file.

I had errors when i tried to issue the save and quit commands at the end of lisp file.

I don't know!

So these files that are attached are what I had originally.
Message 29 of 31
sdanis
in reply to: avltcad

What I would do first is make the lisp so that it is a command by adding a c: after the defun.

(defun c:LAYERFIX (/ BLKDATA NEWCOLOR NEWCOLOR NEWLAYER LAYER XREFFLAG XDEPFLAG BLKENTNAME
COUNT ENTDATA ENTNAME ENTTYPE OLDCOLOR OLDLAYER SSCOUNT SS)

(command ".undo" "group")
(setq BLKDATA (tblnext "BLOCK" t))
(setq NEWCOLOR (cons 62 256)) ;this will set 62 (color) to bylayer
; (setq NEWLAYER (cons 8 "0")) ;this will set 8 (layer) to 0
; (setq NEWLW (cons 370 256)) ;this will set 370 (lineweight) to bylayer
; While there is an entry in the block table to process, continue
(while BLKDATA
(prompt "\nRedefining colors for block: ")
(princ (cdr (assoc 2 BLKDATA)))
; Check to see if block is an XREF or is XREF dependent
(setq XREFFLAG (assoc 1 BLKDATA))
(setq XDEPFLAG (cdr (assoc 70 BLKDATA)))
; If block is not XREF or XREF dependent, i.e., regular block, then proceed.
(if (and (not XREFFLAG) (/= (logand XDEPFLAG 32) 32))
(progn
(setq BLKENTNAME (cdr (assoc -2 BLKDATA)))
(setq COUNT 1)
(terpri)
; As long as we haven't reached the end of the block's defintion, get the data
; for each entity and change its color assignment to BYLAYER.
(while BLKENTNAME
(princ COUNT)
(princ "\r")
(setq ENTDATA (entget BLKENTNAME)); get entities data
(setq OLDCOLOR (assoc 62 ENTDATA)) ;get entities old color value
(if OLDCOLOR ; if value exist (null = bylayer)
(entmod (subst newcolor oldcolor ENTDATA)) ; substitute old color to byblock
(entmod (cons newcolor ENTDATA)) ; modify ent data w/ byblock values
)
(setq OLDLW (assoc 370 ENTDATA)) ;get entities old lweight value
(if OLDLW ; if value exist (null = bylayer)
(entmod (subst newlw oldlw ENTDATA)) ; substitute old lweight to bylayer
(entmod (cons newlw ENTDATA)) ; modify ent data w/ bylayer values
)

(setq BLKENTNAME (entnext BLKENTNAME)) ;if attributes exist, then edit next one
(setq COUNT (+ COUNT 1));
) ;end while for attribute trap
) ;progn
(progn
(princ " XREF...skipping!")
) ;progn
);end if not an Xref
(setq BLKDATA (tblnext "BLOCK")) ;next block please
) ;end while loop of blk data available to edit
(command ".undo" "end")
(command ".regen")
(PROMPT "\nDone... ")
(princ)

;;here I would add
(command "qsave")
(command "quit")

);;defun


My script would look like this:
(load "c:\\datafiles\\avlt-cad\\setup.lsp")
layerfix
"only 1 enter"



The Bat file looks fine.

Edited by: sdanis on Aug 31, 2009 5:08 PM Edited by: sdanis on Aug 31, 2009 5:12 PM
Message 30 of 31
avltcad
in reply to: avltcad

Awesome!

Thanks sdanis!
Message 31 of 31
sdanis
in reply to: avltcad

Glad I could help

Scott

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost