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

Lisp routine during batch plotting AutoCAD 2014

21 REPLIES 21
Reply
Message 1 of 22
hillrunner
3457 Views, 21 Replies

Lisp routine during batch plotting AutoCAD 2014

I cannot get my lisp routine to run when I batch plot in AutoCAD 2014.  It's loaded into the startup suite and runs when I open the individual drawings but not during a batch plot.  How can I get this to run during a batch plot?  Any suggestions?

21 REPLIES 21
Message 2 of 22

Try loading the LISP in the Acaddoc.lsp file? it works more consistently then the startup suite.

Message 3 of 22
hillrunner
in reply to: hillrunner

We tried that already and it doesn't work during batch plotting.  It works great when you just open the drawing but not during a batch plot.

 

Message 4 of 22
BlackBox_
in reply to: hillrunner


@Anonymous wrote:

We tried that already and it doesn't work during batch plotting.  It works great when you just open the drawing but not during a batch plot.

 


User error.

 

 

 

Separately, what's with all of the duplicate threads lately... This isn't exactly a real pressing matter, IMO.



"How we think determines what we do, and what we do determines what we get."

Message 5 of 22
aqdam1978
in reply to: hillrunner

Hi,

 

set ACADLSPASDOC to "1" and try...

 

Abbas

Message 6 of 22
hillrunner
in reply to: aqdam1978

We tried that and it works when you just open the drawings (but it worked that way when it was in the startup suite) but it will not run when you batch plot multiple files.

 

Still need help.

Message 7 of 22
BlackBox_
in reply to: hillrunner

Firstly, you've not clarified what manor of 'batch plot' you're using, nor have you supplied your LISP code.

 

Second, ACADLSPASDOC determines when to load Acad.lsp (either once per session, or once per Document opened), and has nothing to do with AcadDoc.lsp, which is loaded once per Document opened by default.

 

Lastly, it's no coincidence that you still need help, as you've neglected to provide enough information for anyone to help you, short of stabs in the dark... Kindly, help us, help you.

 

Cheers



"How we think determines what we do, and what we do determines what we get."

Message 8 of 22
hillrunner
in reply to: BlackBox_

@ Blackbox

I'm happy to post the LISP code for you to try but I'm not interested in smarty pants replies. Just ask and keep it simple.  Thanks!

 

So here is the LISP routine we use that restores a specified layerstate when the drawing is opened.  We have a text file that determines which layerstate to load.  It works perfect wehn you just open a drawing but not when you use the AutoCAD 2014 batch plot (found under the output menu).

 

We have 2 LISP routines that run.  One is the startup.

 

;;; SH-Layer State.LSP ;;; Sitts And Hill Layer State Auto-Loading LISP (2008) ;;; ;;; Written by Steve McCarthy and Wes Jones ;;; Revised January 31, 2012 by Joel Hills ;;; ;;; LM is new command to reset sheet to correct layer state ;;; defined in xref and referenced in text file. Text file ;;; must be the same name as drawing sheet and located in ;;; a folder titled "Layer States" in the same directory ;;; as drawing sheet.

(defun C:LMS (/ path dwg ans1 ans2 txt)  (setq path (getvar "dwgprefix")        dwg (getvar "dwgname")        ans1 (findfile (strcat path "Layer States/" dwg ".txt"))        ans2 (strcat path "Layer States\\" dwg ".txt")  )  (if (= ans1 ans2)   (progn    (setq txt (open (strcat path "Layer States/" dwg ".txt") "r"))    (setq line1 (read-line txt)          line2 (read-line txt)          line3 (read-line txt)          line4 (read-line txt)          line5 (read-line txt)          line6 (read-line txt)    )    (if (= (null line1) T)     (princ "\nERROR! Text File Is Empty")     (if (= (null line2) T)      (progn       (command "-layer" "a" "r" line1 "" "")       (princ (strcat "\nLoaded Layer State: " line1))      )      (if (= (null line3) T)       (progn        (command "-layer" "a" "r" line1 "r" line2 "" "")        (princ (strcat "\nLoaded Layer State: " line1))        (princ (strcat "\nLoaded Layer State: " line2))       )       (if (= (null line4) T)        (progn         (command "-layer" "a" "r" line1 "r" line2 "r" line3 "" "")         (princ (strcat "\nLoaded Layer State: " line1))         (princ (strcat "\nLoaded Layer State: " line2))         (princ (strcat "\nLoaded Layer State: " line3))        )        (if (= (null line5) T)         (progn          (command "-layer" "a" "r" line1 "r" line2 "r" line3 "r" line4 "" "")          (princ (strcat "\nLoaded Layer State: " line1))          (princ (strcat "\nLoaded Layer State: " line2))          (princ (strcat "\nLoaded Layer State: " line3))          (princ (strcat "\nLoaded Layer State: " line4))         )         (if (= (null line6) T)          (progn           (command "-layer" "a" "r" line1 "r" line2 "r" line3 "r" line4 "r" line5 "" "")           (princ (strcat "\nLoaded Layer State: " line1))           (princ (strcat "\nLoaded Layer State: " line2))           (princ (strcat "\nLoaded Layer State: " line3))           (princ (strcat "\nLoaded Layer State: " line4))           (princ (strcat "\nLoaded Layer State: " line5))          )          (progn           (command "-layer" "a" "r" line1 "r" line2 "r" line3 "r" line4 "r" line5 "r" line6 "" "")           (princ (strcat "\nLoaded Layer State: " line1))           (princ (strcat "\nLoaded Layer State: " line2))           (princ (strcat "\nLoaded Layer State: " line3))           (princ (strcat "\nLoaded Layer State: " line4))           (princ (strcat "\nLoaded Layer State: " line5))           (princ (strcat "\nLoaded Layer State: " line6))          )         )        )       )      )     )    )    (close txt)    (princ)   )   (progn   (princ "\nLayer State text file not found!")   )  )  (princ "\nVersion 1/31/13")  (princ) )

(defun C:LM() (command  "-xref" "r" "**") (c:LMS) )

 

Startup routine:

;;; Revised January 31, 2012 by Joel Hills
(defun S::startup ()
(C:LMS)
)

 

 

Thank you in advance for the help.

 

 

Message 9 of 22
BlackBox_
in reply to: hillrunner


@Anonymous wrote:

@ Blackbox

I'm happy to post the LISP code for you to try but I'm not interested in smarty pants replies. Just ask and keep it simple.  Thanks! 

 


Allow me to state this as simple, and plainly as I know how..... 

 

It is incumbent upon you (the question asker) to provide enough detail for another (the question answerer) to offer an informed, perhaps even good, response.

 

 

 

While I thank you for finally providing the LISP (which could greatly benefit from the use of Layer-State-* functions in lieu of Command calls, for efficiency if nothing else [so long as you're working in 2009+ version?]), you've still not answered the question of your 'batch plot' method, let alone provided a working sample of the dependent files in your scenario for us to properly test (i.e., .dwg, .txt, etc.) would-be solution(s).

 

Your fellow members are all volunteers (aside from Autodesk staff), and are more likely to take time to help someone who's actually put in the effort to make it easy for them to offer help, than one who has not... So kindly provide enough accurate information, and I'm willing to bet you'll see better responses.

 

Cheers



"How we think determines what we do, and what we do determines what we get."

Message 10 of 22
smaher12
in reply to: hillrunner

hillrunner - just takeing at quick look at your code, with the code in your startup file do you execute the code at the command prompt or is automatic everytime you open a drawing?

 

Message 11 of 22
hillrunner
in reply to: smaher12

It runs automatically upon opening the drawings.

Message 12 of 22
smaher12
in reply to: hillrunner

Maybe run code when you exit the drawings, then set up your batch plot???

Message 13 of 22
hillrunner
in reply to: smaher12

The way we use this routine is so we can make a layerstate change in the base file that is xreffed into hundreds of other drawing files.  When you open the drawings where this base file is xreffed it automatically loads the correct layerstate (specified by a text file).  It used to work when you published the drawings without having to open each drawing in AutoCAD 2008.  Therefore running the routine upon exit does not help when you need it to run when it's opened so it will plot correctly.

 

We use PUBLISH for batch plotting.

Message 14 of 22

ahh see this type of info is that we needed from the beginning. Not having used 2014 i can only speculate, but its seems like its something in 2014 itself (maybe something to do with the Trusted Securith path thing?). although the lisp may need updating.

Message 15 of 22

We've added it to the trusted locations and it still won't run.  we are speculating that something has changed in the publishing that disables LISP routines to speed up plotting.  It does work great when you open the drawings just not when you publish a set of drawings.

 

Message 16 of 22


@conormccartney3897 wrote:

ahh see this type of info is that we needed from the beginning. 


This.

 


@conormccartney3897 wrote:

... although the lisp may need updating.


This, too.



"How we think determines what we do, and what we do determines what we get."

Message 17 of 22
BlackBox_
in reply to: hillrunner


@Anonymous wrote:

We've added it to the trusted locations and it still won't run. 

 


This can be inferred from your earlier statement that the LISP loads/runs correctly when you open the drawing... But we're still lacking complete detail (i.e., more information, complete data set to test, etc.).

 

 


@Anonymous wrote:

... we are speculating that something has changed in the publishing that disables LISP routines to speed up plotting.  

 


You have to remember that nobody else (other than your coworkers) has your setup... Without something provided by you for others to test (i.e., .dwg, .txt, etc.), we're unable to replicate, and identify the 'bug' so-to-speak.



"How we think determines what we do, and what we do determines what we get."

Message 18 of 22
hillrunner
in reply to: BlackBox_

Yes, we are in the process of updating the LISP routine as we speak.

Message 19 of 22
jonesw
in reply to: hillrunner

Here is the revised LSP routine as well as a sample drawing. The routine looks for a .txt file located within a folder titled "Layer States" saved in the same directory as the drawing with the same name as the drawing (i.e. drawing.dwg.txt). Within the .txt file, the exact name of the layer state associated with each xref is saved. The LSP routine recalls the layer states for the drawing by reading the .txt file upon drawing open. If the text does not exactly match the drawing an error is reported on the command line. This command can also be invoked while in a drawing if you want to restore it to it's correct state, using the defined "LM" command.

 

In the attached example there are three xrefs all with their own layer states. The sample drawing has them all referenced into it. Each xref is saved with the layers white and the sample drawing brings them in white. However, when the LSP command is run, the sample drawing recalls the correct layer state for each file and makes them appear as they were intended. Simple, but it gets the point accross.

 

The routine works upon drawing open, however the routine does not appear to load during a standard publish routine where multiple drawings are automatically loaded and printed. This appears to have changed sometime between 2008 and 2014 (we just upgraded). Previously the routine would invoke (in 2008) during a publish routine and set the drawings correctly prior to printing. Now it doesn't and we are suspecting that there is a system variable for disabling LSP during batch plotting to speed up the process. If so, we'd like to turn it back on. If not, well then that is what we are trying to find a fix for.

 

Thanks for the help!

 

 

 

 

 

;;; SH-Layer State.LSP ;;; Sitts And Hill Layer State Auto-Loading LISP (2008) ;;; ;;; Written by Steve McCarthy and Wes Jones ;;; Revised June 19, 2013 by Wes Jones ;;; ;;; LM is new command to reset sheet to correct layer state ;;; defined in xref and referenced in text file. Text file ;;; must be the same name as drawing sheet and located in ;;; a folder titled "Layer States" in the same directory ;;; as drawing sheet. ;;; ;;; (C) Copyright 2013. All rights reserved.

(defun C:LMS (/ path dwg ans1 ans2 txt)  (setq path (getvar "dwgprefix")        dwg (getvar "dwgname")        ans1 (findfile (strcat path "Layer States/" dwg ".txt"))        ans2 (strcat path "Layer States\\" dwg ".txt")  )  (cond ((= ans1 ans2)         (setq txt (open (strcat path "Layer States/" dwg ".txt") "r"))         (setq line1 (read-line txt)               line2 (read-line txt)               line3 (read-line txt)               line4 (read-line txt)               line5 (read-line txt)               line6 (read-line txt)         )         (cond ((= nil line1)                (princ "\nERROR! Text File Is Empty.")               )               ((= nil line2)                (cond ((= (layerstate-has line1))                       (layerstate-restore line1)                       (command "regenall")                       (princ (strcat "\nLoaded Layer State: " line1))                      )                      (t                       (princ "\nWARNING! Text file contents do not match drawing!")                      )                )               )               ((= nil line3)                (cond ((and (= (layerstate-has line1) (layerstate-has line2)))                       (layerstate-restore line1)                       (layerstate-restore line2)                       (command "regenall")                       (princ (strcat "\nLoaded Layer State: " line1))                       (princ (strcat "\nLoaded Layer State: " line2))                      )                      (t                       (princ "\nWARNING! Text file contents do not match drawing!")                      )                )               )               ((= nil line4)                (cond ((and (= (layerstate-has line1) (layerstate-has line2) (layerstate-has line3)))                       (layerstate-restore line1)                       (layerstate-restore line2)                       (layerstate-restore line3)                       (command "regenall")                       (princ (strcat "\nLoaded Layer State: " line1))                       (princ (strcat "\nLoaded Layer State: " line2))                       (princ (strcat "\nLoaded Layer State: " line3))                      )                      (t                       (princ "\nWARNING! Text file contents do not match drawing!")                      )                )               )               ((= nil line5)                (cond ((and (= (layerstate-has line1) (layerstate-has line2) (layerstate-has line3) (layerstate-has line4)))                       (layerstate-restore line1)                       (layerstate-restore line2)                       (layerstate-restore line3)                       (layerstate-restore line4)                       (command "regenall")                       (princ (strcat "\nLoaded Layer State: " line1))                       (princ (strcat "\nLoaded Layer State: " line2))                       (princ (strcat "\nLoaded Layer State: " line3))                       (princ (strcat "\nLoaded Layer State: " line4))                      )                      (t                       (princ "\nWARNING! Text file contents do not match drawing!")                      )                )               )               ((= nil line6)                (cond ((and (= (layerstate-has line1) (layerstate-has line2) (layerstate-has line3) (layerstate-has line4) (layerstate-has line5)))                       (layerstate-restore line1)                       (layerstate-restore line2)                       (layerstate-restore line3)                       (layerstate-restore line4)                       (layerstate-restore line5)                       (command "regenall")                       (princ (strcat "\nLoaded Layer State: " line1))                       (princ (strcat "\nLoaded Layer State: " line2))                       (princ (strcat "\nLoaded Layer State: " line3))                       (princ (strcat "\nLoaded Layer State: " line4))                       (princ (strcat "\nLoaded Layer State: " line5))                      )                      (t                       (princ "\nWARNING! Text file contents do not match drawing!")                      )                )               )               ((not (= nil line6))                (cond ((and (= (layerstate-has line1) (layerstate-has line2) (layerstate-has line3) (layerstate-has line4) (layerstate-has line5) (layerstate-has line6)))                       (layerstate-restore line1)                       (layerstate-restore line2)                       (layerstate-restore line3)                       (layerstate-restore line4)                       (layerstate-restore line5)                       (layerstate-restore line6)                       (command "regenall")                       (princ (strcat "\nLoaded Layer State: " line1))                       (princ (strcat "\nLoaded Layer State: " line2))                       (princ (strcat "\nLoaded Layer State: " line3))                       (princ (strcat "\nLoaded Layer State: " line4))                       (princ (strcat "\nLoaded Layer State: " line5))                       (princ (strcat "\nLoaded Layer State: " line6))                      )                      (t                       (princ "\nWARNING! Text file contents do not match drawing!")                      )                )               )         )        )        (t         (princ "\nLayer State text file not found!")        )  )  (princ "\nVersion 1/31/13")  (princ) )

(defun C:LM() (command  "-xref" "r" "**") (c:LMS) )

(defun S::startup () (C:LMS) )

Message 20 of 22
hillrunner
in reply to: smaher12

It's loaded automatically each time we open a drawing.

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

Post to forums  

Autodesk Design & Make Report

”Boost