letissier85 Posted February 21 Share Posted February 21 Hello everyone, i am new to scripts and i would like to resolve a big problem with your help. I have 400 dwg files, and i need to batch-print them in monochrome on different pdfs. Unfortunately, with the ctb plot style table active, the batch process outcomes with coloured lines. So, following a post here on CADTutor, i launched lee mac wscript and pointed to the dwg folder with the command: _open *file* (if (= (getvar PSTYLEMODE) 1) (setvar "Pstylesmode" 0)) _qsave _close to convert to stb plot style table. Opening randomly one of the dwg and giving pstylemode it still return out 1. i also tried : _open *file* (if (= (getvar PSTYLEMODE) 1) (_convertpstyles)) _qsave _close same results (it opens autocad help windows, and no windows to select stb files opens). What can i do? Quote Link to comment Share on other sites More sharing options...
CyberAngel Posted February 21 Share Posted February 21 The easy solution, it seems to me, would be to apply a monochrome color table when you plot. That way you don't have to change all those drawing files, and you take less time. It may take a little work to get all the prompts correct, but you should be able to write a script (here's a page on how to do that, and some tips from CADTutor) to run the PLOT command. If you have to use CONVERTPSTYLES, you can include that in the script. Quote Link to comment Share on other sites More sharing options...
letissier85 Posted February 21 Author Share Posted February 21 monochrome color table (CTB) returns out colors , and it seems to be some issue with truecolor layers, that's why i need to convert all drawings to STB plot style table. i tried those commands but the script doesn't save the pstylemode to 0. i don't know if there's something faster to convert layers to the nearest aci color and save it. Thanks for your help Quote Link to comment Share on other sites More sharing options...
SLW210 Posted February 21 Share Posted February 21 Black and white (monochrome/grayscale) color-dependent plot style (CTB) plots color in AutoCAD AFAIK, STB could also plot True Colors, it has been a while since I used STB. It's not an issue, but the way they work. To change from CTB to STB you first run CONVERTCTB, then run CONVERTPSTYLES. Black and white (monochrome/grayscale) named plot style (STB) plots color in AutoCAD Easy solution is to see if the PDF plotter driver can be set to B&W, I think Acrobat might could do that, maybe Bluebeam. Other than that, look for a LISP that can set True Colors/Color Book to Index colors. How to access the truecolor property via AutoLISP? - AutoCAD DevBlog Quote Link to comment Share on other sites More sharing options...
BIGAL Posted February 22 Share Posted February 22 (edited) Some more, use a lisp in your script to do the plot bit. open dwg1 (load "plotmydwg") Close N open dwg2 (load "plotmydwg") Close N open dwg3 (load "plotmydwg") Close N The plot lisp would be something like this, (load "CONVERTCTB")(c:CONVERTCTB) (setvar "textfill" 1) (setvar "fillmode" 1) (setq pdfname (strcat "C:\\mypdfs\\" (getvar 'dwgname))) (COMMAND "-PLOT" "Y" "" "Plot To PDF" "Iso full bleed A3 (420.00 x 297.00 MM)" "m" "LANDSCAPE" "N" "W" "-6,-6" "807,560" "1=2" "C" "y" "Mono.ctb" "Y" "n" "n" "n" pdfName "N" "y" ) Edited February 22 by BIGAL Quote Link to comment Share on other sites More sharing options...
letissier85 Posted February 22 Author Share Posted February 22 i really appreciate your tips and the time you spend to help people, but as i said i am absolutely newbie to script, so i actually don't understand what you wrote, BIGAL! it seems to me that the code you gave to me has to be launched for every dwg, but i have 400! Lee Mac wscript let me choose a folder of file to which execute a script, but i cannot make the script work. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted February 24 Share Posted February 24 You need to build say a lisp that has multiple functions. The first is convert the colors to index colors, then do the plot code. So post a sample dwg. Ok 1st step is a function to convert RGB to ACI ; RGB -> ACI - Lee Mac ;; Args: r,g,b - [int] Red, Green, Blue values (defun LM:RGB->ACI ( r g b / c o ) (if (setq o (vla-getinterfaceobject (LM:acapp) (strcat "autocad.accmcolor." (substr (getvar 'acadver) 1 2)))) (progn (setq c (vl-catch-all-apply '(lambda ( ) (vla-setrgb o r g b) (vla-get-colorindex o)))) (vlax-release-object o) (if (vl-catch-all-error-p c) (prompt (strcat "\nError: " (vl-catch-all-error-message c))) c ) ) ) ) Another method is to use Accoreconsole which is very fast and can be ran as a batch process on a directory of dwg's. Quote Link to comment Share on other sites More sharing options...
letissier85 Posted February 28 Author Share Posted February 28 i cannot find accoreconsole.exe on my pc (using Autocad2024). i actually don't need the plot code, i will do it later with batch plot. i understood that the problem with monochrome plot is due to truecolors i have in some layer. so, i thought would be easier to write a script that assign to any element of drawing the nearest (rgb or aci) color, and save it. all this, applied to all the drawings of a folder. as i don't know anything of scripting, i used chatgpt but i cannot obtain anything work. can anyone help me? please, i would appreciate a step by step guide Quote Link to comment Share on other sites More sharing options...
CyberAngel Posted February 28 Share Posted February 28 3 hours ago, letissier85 said: can anyone help me? please, i would appreciate a step by step guide BigAl, in his Feb. 21 post, gave you two pieces of code. You will have to set things up for your particular system, which is why we can't just give you a file to run. First of all there's some mechanism (not shown) that generates the master script, i.e. the first piece of code. If you can cut & paste a list of the files, you're halfway there. If you can find & replace in that list and make it look like BigAl's script, you can save it as a SCR file. Every time the script opens a drawing, it loads and runs a function, then it closes the drawing and opens the next one. That's all the master script does. The other piece of code should go in a file named plotmydwg.lsp. Save it in a folder where AutoCAD can find LISP code. That's the function called by the script. Since you won't be printing with this function, you'll have to change it. As BigAl suggests, you could include a call to the RGB->ACI function, or whatever needs doing to prepare your files. Tip: open one of your drawings and type the AutoLISP commands (in order) to make sure they have the desired effects. Once you get them right, type them into the .LSP file. In other words, find out how to accomplish your task on one file and automate it to do the rest. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted February 28 Share Posted February 28 Type commands in order use Logfileon it will record what occurs on the command line then Logfileoff to stop, the log file is in your temporary directory, look at Options Files Temp directory if you do not know where it is. This lisp will tell you where it is also (setq *files* (vla-get-files (vla-get-preferences (vlax-get-Acad-object)))) (setq pre (vla-get-TempFilePath *files*)) (alert (strcat "Your temp directory is " pre)) I started in the DOS days so used to make file lists using DOS then put them into word and use search and replace to make my scripts. Have a look at Lee-mac Script writer. Script Writer | Lee Mac Programming (lee-mac.com) Quote Link to comment Share on other sites More sharing options...
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.