The title of today’s routine pretty much explains what this LISP routine does. You must have the layout tab active with the correct page setup current on that tab as well.
Here’s how:
CPS <enter> To start and run
~enjoy
;; Copy current layout page setup to all layout tabs
(vl-load-com)
(defun c:CPS (/ Adoc Layts clyt)
(setq aDoc (vla-get-activedocument (vlax-get-acad-object))
Layts (vla-get-layouts aDoc)
clyt (vla-get-activelayout aDoc)
)
(foreach
itm
(vl-remove (vla-get-name clyt) (layoutlist))
(vla-copyfrom (vla-item Layts itm) clyt)
)
(princ)
)
Am I missing something?? everything is done according to your …”here s how!”… and nothing happens!
make sure the file name is “cps.lsp” – it will work for page layouts with the same page size.
Are you copying the code and loading it correctly?
Hi, is there an article on how to load lisp files?
Cheers
Hi Gillian,
There is a couple of links in the “About” section of this blog https://autocadtips.wordpress.com/about/
Also Lee Mac has a couple of posts about how to load a lisp routine http://www.lee-mac.com/runlisp.html and also how to load them automatically (upon opening a drawing) http://www.lee-mac.com/autoloading.html
~Greg
cheers Greg!
Hi, I have (unfortunately) the necessity to modify into some files (which are used as models) the print style preset.
These files, which are necessary for the realization of electrical diagrams, have inside hundreds of layout.
Each layout set default printing parameters, so as “Laser b/n.pc3,” as the paper size “A4” scale “Scale to Fit”, and plot style “Schemi.ctb”, etc. ..
Is there a way to create a macro (a field unknown to me) or something similar, to automatically change in all the default layout, for example, the printer “Colori.pc3” and the print style in “Schemi_colori.ctb “? And maybe can I choose the fields to modify??
The easiest way to accomplish what you want to do is to create a template drawing that contains a page setup with the .ctb file and printer already set… Then when you open a drawing that does not have this page setup, you simply right click on a layout tab and choose “from template…” then navigate to the template file that you previously created and select what page setup will be applied to the current drawing. Once that page setup has been brought into the drawing – and with that layout tab being the current layout tab you can then use this lisp routine to apply that page setup to all of the layout tabs in the drawing.
Thanks, but I can’t use this lisp because each layout have different plot-windows.
This lisp reset all plot-windows to the default. :-(
I also noticed a command PSETUPIN if you put a minus sign in the front of the command it will force autocad to use the command line only version of the command. Therefore you can create a script using this command
http://www.sonic.net/~odin/lounge/autocad%20tips/page_setups_in_autocad.htm
Brilliant! Thanks for sharing this lisp routine. Particularly helpful today when I was searching for a solution to realising that the plot transparency had to be applied to a page setup across a doc that had dozens of layouts. I’ll be saving your link to my favourites!
That’s great to hear. I am glad it helped
~Greg
It might not seem to do anything (by command prompt), but it seems to work for me :).
YOU are my new BFF!!!! THANK YOU so much for this!!!! You are my hero today. Thanks!
If I may trouble you, I need help with your autolisp routine.
I have one dwg file, under the Plot command in Paper Space, I have configured the Printer/plotter name, paper size, the plot area, Plot scale and Plot style table.
Now I would like to apply all these plot configuration to the rest of the dwgs (all in Paper Space) in the same folder. I loaded up CPS and ran it, nothing happen. I know I am missing a few crucial steps, much appreciated if you could guide me, as I am not much of a programmer.
Dix
Sorry for the late response. Did you ever find a solution?
The routine in the blog post only applies the page setup to all layout tabs in the current drawing.
The ideal solution is to purge out the old page setups and then apply a new page setup.
The below routine is from the ADN (Autodesk Developer’s network and does what I thin you are after.
You will need to have a drawing that has the desired page setup in it. The routine will then need to be customized to point to this file and also call upon the name of the desired page setup.
;; Delete page setups and Import a named page setup
;; http://adndevblog.typepad.com/autocad/2013/01/visual-lisp-importing-page-setups-from-another-drawing.html
(vl-load-com)
(setq *doc* (vla-get-activedocument (vlax-get-acad-object)))
(defun ImpPgSetups (psname / psfile doc2 colPgSetups1 colPgSetups2 objPgSetup objPgSetup2 sName)
; if page setup source file is found,
(if (setq psfile (findfile "Batch Plot Page Setups.dwg"));;<~~~~~~Adjust file name (dWG) that contains the setup
(progn
;; delete all existing page setups.
(DelPgSetups)
;; import page setups
(setq doc2 (vla-open
(vla-get-documents (vlax-get-acad-object)) psfile)
colPgSetups1 (vla-get-PlotConfigurations *doc*)
colPgSetups2 (vla-get-PlotConfigurations doc2)
) ;setq
;;get each page setup in the ACAD_PLOTSETTINGS dictionary
(vlax-for objPgSetup colPgSetups2
(setq sName (vlax-get-property objPgSetup 'Name))
(if (= sName psname)
(progn
;;add the page setup to the current doc
;:vlax-true = Model tab only
(setq objPgSetup2
(vla-add colPgSetups1 sName :vlax-false))
(vla-CopyFrom objPgSetup2 objPgSetup)
)
) ;if
;release the page setup
(vlax-release-object objPgSetup)
) ;vlax-for
(vlax-release-object colPgSetups1)
(vlax-release-object colPgSetups2)
(vla-close doc2)
(vlax-release-object doc2)
) ;progn
) ;if
)
(defun DelPgSetups (/ colPgSetups objPgSetup)
(vl-load-com)
;;get the ACAD_PLOTSETTINGS dictionary
(setq colPgSetups (vla-get-PlotConfigurations *doc*))
;;get each page setup in the ACAD_PLOTSETTINGS dictionary
(vlax-for objPgSetup colPgSetups
;delete the page setup from the dictionary
(vla-delete objPgSetup)
;release the page setup
(vlax-release-object objPgSetup)
) ;vlax-for
(vlax-release-object colPgSetups)
(princ)
)
(defun C:Import_Page_Setups()
(ImpPgSetups "11x17 Page");; <~~~~~~~Adjust to specify the name of the page setup to import
)
this lisp does not work for me. can anyone help me.
My question is 1st layout tab insert sheet a3 more 25 layout tab copy in 1st layout sheet .please draw a program autolisp commad .
THANKS FOR THIS LISP
Thank you so much. I have struggled with this for so long, don’t understand why something like isn’t built into Civil 3D.
It’s absolutely fantastic what makes this LISP routine !!!
I had a drawing with 53 layouts and managed in less than 10 seconds I set page all at once. Very simple and fast. I tested CPS command in AutoCAD 2014 and AutoCAD 2007, and works perfectly. Many thanks from me, Sorin
That is great!
I am glad that it helped
why cps lisp does not work in autocad 2017. how to work, pls help me
Brilliant … exactly what was needed in my moment of despair!!
Nice one Greg!
Glad it helped
~Greg
HI GREG
I ASKED SO MANY TIMES UNTILL DID NOT ANSWER MY PROBLEM. NOTHING HAPPEN IN AUTOCAD. HOW TO SOLVE IT. KINDLY HELP ME
Hello Greg ! This LISP is AWESOME and you are the greatest, the smartest man EVER!!!!!!!!! I’m simply thrilled!
I am very happy that it helped you
~Greg
You helped big time! I know it sounds like I’m exaggerating a bit, but I was searching something like this for quite a long time… And there was nothing like this to find. Your blog is extra useful, I will keep following you, have a nice day! :-)
This works brilliant thanks. It was so quick I wasn’t sure it worked at first but it did on 100+ sheets!
The lisp changed ALL the layouts, Even the ones set for 11×17.
Very helpful
When i apply lsp, it pop up ” object was open for read”
t try to paste link folder contain Lsp to the first tab in Options
but it didn’t work
please help
Thank for ur help and sorry about my English grammar