Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
*James Maeding
Message 21 of 31 (211 Views)

Re: Batch LISP?

08-18-2009 05:19 PM 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
Distinguished Contributor
drago2dmax
Posts: 207
Registered: ‎10-16-2008
Message 22 of 31 (211 Views)

Re: Batch LISP?

08-18-2009 07:43 PM in reply to: avltcad
Thanks James
Its good to know.
Active Contributor
mayhap
Posts: 38
Registered: ‎07-31-2008
Message 23 of 31 (211 Views)

Re: Batch LISP?

08-20-2009 11:34 AM 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
Valued Contributor
gilsoto13
Posts: 79
Registered: ‎03-06-2009
Message 24 of 31 (211 Views)

Re: Batch LISP?

08-22-2009 08:24 PM 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
Distinguished Contributor
sdanis
Posts: 203
Registered: ‎12-09-2003
Message 25 of 31 (211 Views)

Re: Batch LISP?

08-26-2009 12:29 PM in reply to: avltcad
Google 'Changing Hundredes of Autocad Drawings in a Hurry.
I ues this process all the time. It works great!
Contributor
avltcad
Posts: 21
Registered: ‎07-07-2009
Message 26 of 31 (211 Views)

Re: Batch LISP?

08-28-2009 06:01 AM 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?
Distinguished Contributor
sdanis
Posts: 203
Registered: ‎12-09-2003
Message 27 of 31 (211 Views)

Re: Batch LISP?

08-28-2009 06:04 PM 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
Contributor
avltcad
Posts: 21
Registered: ‎07-07-2009
Message 28 of 31 (211 Views)

Re: Batch LISP?

08-31-2009 09:57 AM 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.
Distinguished Contributor
sdanis
Posts: 203
Registered: ‎12-09-2003
Message 29 of 31 (211 Views)

Re: Batch LISP?

08-31-2009 10:08 AM 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
Contributor
avltcad
Posts: 21
Registered: ‎07-07-2009
Message 30 of 31 (211 Views)

Re: Batch LISP?

08-31-2009 10:35 AM in reply to: avltcad
Awesome!

Thanks sdanis!
Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.