leonucadomi Posted August 9, 2021 Posted August 9, 2021 hello friends: I use this text string to quickly print a file, I would like to know if there is any way to apply it to all open drawings (command "'_.zoom" "_e" "" "_-plot" "y" nombre "print1" "carta" "m" "P" "N" "E" "F" "C" "Y" "PLUM.ctb" "Y" "N" "N" "N" "N" "N" "Y""_QSAVE" "_CLOSE") It would be great to click and have everything printed without using the publish command Quote
zwonko Posted August 9, 2021 Posted August 9, 2021 (edited) Why you dont want to use publish? IT is great. Otherwise use Lee mac scriptwriter. Or maybe simplier scriptwriter that i use to set lts 1 and freeze a layer. (defun C:LTSALLDWG ( / filename doc scriptname) (setq scriptname (open "d:\\#temp\\tmp\\batch.scr" "w")) (vlax-for doc (vla-get-documents (vlax-get-acad-object)) (progn (setq filename (vla-get-FullName doc)) (write-line (strcat "_open \"" filename "\"") scriptname) (write-line (strcat "(vl-cmdf \"" "setvar\"" " " "\"" "ltscale\"" " " "\"1\"" " " "\"" "\"" ")") scriptname) (write-line (strcat "(vl-cmdf \"" "_.layer\"" " " "\"" "_freeze\"" " " "\"*podpis*,*podpisy*,*RS podpis*\"" " " "\"" "\"" ")") scriptname) (write-line "_qsave" scriptname) ) ) (close scriptname) (command "filedia" "0") (command "new" " ") (command "closeall") (command "script" "d:\\#temp\\tmp\\batch.scr") (command "filedia" "1") (princ) ) Maybe IT is also possibile to do something similar to: https://www.cadtutor.net/forum/topic/73181-ltscale-10-to-allopeneddwgs/ Edited August 9, 2021 by zwonko 1 Quote
leonucadomi Posted August 9, 2021 Author Posted August 9, 2021 I have not been able to make a script to apply it to multiple files. I do not know how Quote
Steven P Posted August 9, 2021 Posted August 9, 2021 2 hours ago, zwonko said: Why you dont want to use publish? IT is great. Otherwise use Lee mac scriptwriter. I can't remember, does Lee Macs scriptwriter work on an open drawing, or just the saved version of the drawing? This is somethng I have been trying to do for a while, not just with plotting but as a general batch operation runinng commands and LISPS on all opened files - closed files and there are a lot of options like Scriptwriter, the core console, and so on. For opened files I haven't found anything good yet (I don't look all the time though), I'll give your version a try in the morning. Quote
zwonko Posted August 9, 2021 Posted August 9, 2021 1 hour ago, Steven P said: I can't remember, does Lee Macs scriptwriter work on an open drawing, or just the saved version of the drawing? actually it does work not on open drawings, but working on the drawing in folder (and sub-folder) is ok. Try this code (defun C:plotall ( / filename doc scriptname) (setq scriptname (open (strcat (getenv "temp") "\\batch.scr") "w")) (vlax-for doc (vla-get-documents (vlax-get-acad-object)) (progn (setq filename (vla-get-FullName doc)) (write-line (strcat "_open \"" filename "\"") scriptname) (write-line (strcat "_.zoom e" ) scriptname) (write-line (strcat "_-plot y layout1 " "dwg to pdf.pc5" "\n" "A4" "\n" "m p n e " "f" "\n" "c" "\n" "y" "\n" "monochrome.ctb" "\n" "Y" "\n" "N" "\n" "N" "\n" "N" "\n" filename ".pdf" "\n" "N" "\n" "Y") scriptname) (write-line "_qsave" scriptname) (write-line "_close" scriptname) ) ) (close scriptname) (command "filedia" "0") (command "new" " ") (command "closeall") (command "script" (strcat (getenv "temp") "\\batch.scr")) (command "filedia" "1") (princ) ) Note that it is printing only "layout1". script file is lokated in %temp% folder. Quote
leonucadomi Posted August 9, 2021 Author Posted August 9, 2021 unfortunately nothing has worked Quote
zwonko Posted August 9, 2021 Posted August 9, 2021 try this one. For me it is working. Note that it will plot only layout called layout1. (defun C:plotall ( / filename doc scriptname) (setq scriptname (open (strcat (getenv "temp") "\\batch.scr") "w")) (vlax-for doc (vla-get-documents (vlax-get-acad-object)) (progn (setq filename (vla-get-FullName doc)) (write-line (strcat "_open \"" filename "\"") scriptname) (write-line (strcat "_.zoom e" ) scriptname) (write-line (strcat "_-plot y layout1 " "dwg to pdf.pc5" "\n" "A4" "\n" "m p n e " "f" "\n" "c" "\n" "y" "\n" "monochrome.ctb" "\n" "Y" "\n" "N" "\n" "N" "\n" "N" "\n" filename ".pdf" "\n" "N" "\n" "Y") scriptname) (write-line "_qsave" scriptname) (write-line "_close" scriptname) ) ) (close scriptname) (command "filedia" "0") (command "new" " ") (command "closeall") (command "script" (strcat (getenv "temp") "\\batch.scr")) (command "filedia" "1") (princ) ) Quote
BIGAL Posted August 9, 2021 Posted August 9, 2021 You can get a list of all open dwgs using VL and change between the dwgs I am not sure about doing plotting as well, would have to check. Run this with multi dwgs open try replacing the alert with your plot line. With out the save and close will have to look at how the item number accepts that a dwg has been closed. Or may need to redo the acdocs each time. May need to leave the last dwg open. (setq acDocs (vla-get-documents (vlax-get-acad-object))) (setq howmany (vla-get-count acdocs)) (vlax-for dwg acdocs (vla-activate (vla-item acdocs (setq howmany (1- howmany)))) (alert (getvar 'dwgname)) ) Quote
Steven P Posted August 10, 2021 Posted August 10, 2021 Hi Big Al, I have had a look at your option this morning, I don't know why it works for 'alert'.. . What I have found this morning is what I found before, change the alert line to a (command "...) or a (c:....) to run a command or a LISP. When AutoCAD moves on from the original drawing it stops processing the original command until it comes back again - and it won't run the command on subsequent drawings because of this. Zwonko, your codes work by closing all the drawings? the OP said about doing this on all opened drawings, otherwise I would go with Lee Macs or similar scriptwriter to process closed drawings. If you change your code about, instead of closing the file and then opening it again, use BigAls suggestion '(vla-activate' in the script, will that work? Quote
zwonko Posted August 10, 2021 Posted August 10, 2021 @Steven P this lisp is generating script to autocad. So it is making *.scr file with lines that menas commands to do in script. Firstly it generate list of drawing and commands. After it is closing all, becouse it cannot work otherwise, cause files willbe reopened as read only. After opening each file it does the commands. THe last command it close file. If you delete line: (write-line "_close" scriptname) the drawings will be reopened, so it is like "they wasn't closed" (P.S. sorry for my english) In BIGAL's option propably it may work if instead of command the "vla-cmdf" or "vla-sendcommand" will be use. I tried one to do something in code simmilar to BIGAL's here: but the thing was that code works on Bricscad, and didn't on ZWCAD and AUTOCAD. Quote
Recommended Posts
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.