Steven P Posted June 2, 2016 Share Posted June 2, 2016 Hello, I wonder if anyone can help me out? Bit of background - I have a client who requires drawings to be returned to them with the page setup in specific ways, such as not having a plotter specified, and so on. When we are plotting check prints and so on we use the settings that work for our plotters. Sometimes our settings get saved and not theirs So what I am a looking at doing is making a simple LISP routine which will set the page setup as per their requirements. Before the files are sent out I can go to each drawing, type in a simple command to set up the page and close the drawing (rather than going through the page setup box and a risk of forgetting something) Hope that makes sense. So maybe the Lisp routine would be something like: (c:defun client1pagesetup() .... set plotter to none .... set paper size to A1 .... set plot area to Extents .... set units to mm and so on. I can use the '_plot' method, and simply use 'no' for proceed with plot, however that falls down if no plotter is selected - I would have to add a plotter, set up the page, then remove the plotter and set up anything that changes because of that again. I can get most of the page setup things to work, change the plotter and so on, I am struggling with page orientation at the moment Does anyone know how to set the page orientation via a LISP command in page setup to either Landscape or Portrait? I am hoping it would be a 1 or 2 line piece of code I would prefer to change each setting one at a time (might not be the best way, but good for m to learn with) and to not copy a page setup from another drawing (avoid copying errors) Thanks in advance Quote Link to comment Share on other sites More sharing options...
RobDraw Posted June 2, 2016 Share Posted June 2, 2016 I would prefer to change each setting one at a time (might not be the best way, but good for m to learn with) and to not copy a page setup from another drawing (avoid copying errors) That should be the other way around. It would prevent errors by importing one page set-up. I've imported hundreds of page set-ups and have never had an error. Do yourself a favor and do this in a batch process. Doing them in a batch ensures consistency and thoroughness. There are a number of routines for importing a page set-up into multiple files. I'm pretty sure I've got one, if you are interested. Quote Link to comment Share on other sites More sharing options...
CAD USER Posted June 2, 2016 Share Posted June 2, 2016 I'm pretty sure I've got one, if you are interested. Please post it, if you can... Quote Link to comment Share on other sites More sharing options...
Steven P Posted June 2, 2016 Author Share Posted June 2, 2016 Thanks Rob, Doing them in a batch should work OK, however that still needs checking for consistency that nobody else in the team hasn't altered the page setup of the 'master' page setup. So yes, it is a good solution - and you are right there are lots of examples out there - but not quite what I am looking for here Quote Link to comment Share on other sites More sharing options...
RobDraw Posted June 2, 2016 Share Posted June 2, 2016 Okay, no copyright or author information. I can post. this is quite old and I have not used it in years. Use at your own risk. ;; Copies plot configurations from the current drawing ;; to all drawings within a selected folder. (defun c:copyplotconfigs (/ _getfolder _getplotconfigs adoc dir doc file l n odbx plt v) (vl-load-com) (defun _getfolder (message / sh folder result) (setq sh (vla-getinterfaceobject (vlax-get-acad-object) "Shell.Application")) (setq folder (vlax-invoke-method sh 'browseforfolder 0 message 0)) (vlax-release-object sh) (if folder (progn (setq result (vlax-get-property (vlax-get-property folder 'self) 'path)) (if (wcmatch result "*\\") result (strcat result "\\") ) ) ) ) (defun _getplotconfigs (doc / out) (vlax-for x (vla-get-plotconfigurations doc) (setq out (cons (cons (strcase (vla-get-name x)) x) out)) ) ) (setq adoc (vla-get-activedocument (setq doc (vlax-get-acad-object)))) (cond ((not (setq l (_getplotconfigs adoc))) (princ "\nNo plot configurations in current drawing!") ) ((not (setq odbx (if (< (setq v (substr (getvar 'acadver) 1 2)) "16") (vla-getinterfaceobject doc "ObjectDBX.AxDbDocument") (vla-getinterfaceobject doc (strcat "ObjectDBX.AxDbDocument." v)) ) ) ) (princ "\nObject DBX interface not created!") ) ((if (setq dir (_getfolder "Select directory to apply current drawing pagesetups to: ")) (foreach f (vl-directory-files dir "*.dwg" 0) (setq file (strcat dir f)) (if (vl-catch-all-error-p (vl-catch-all-apply 'vla-open (list odbx file))) (princ (strcase (strcat "\nError opening: " file))) (progn (princ (strcat "\nOpening: " file)) (setq plt (vla-get-plotconfigurations odbx)) (if (not (zerop (setq n (vla-get-count plt)))) (progn (princ (strcat "\n\t" (itoa n) " - plot configurations removed")) (vlax-map-collection plt 'vla-delete) ) ) (and (vlax-invoke adoc 'copyobjects (mapcar 'cdr l) plt nil) (princ (strcat "\n\t" (itoa (length l)) " - plot configurations copied from current drawing" ) ) ) (vla-saveas odbx (vla-get-name odbx)) ) ) ) (princ "\nBuh bye...") ) ) ) (princ) ) (c:copyplotconfigs) Quote Link to comment Share on other sites More sharing options...
Tripledot Posted June 3, 2016 Share Posted June 3, 2016 It appears to be not working When the lisp is running, it appears to be working & the file date of all drawings within that folder is changed but the plot config still remain as per the original drawings. Okay, no copyright or author information. I can post. this is quite old and I have not used it in years. Use at your own risk. ;; Copies plot configurations from the current drawing ;; to all drawings within a selected folder. (defun c:copyplotconfigs (/ _getfolder _getplotconfigs adoc dir doc file l n odbx plt v) (vl-load-com) (defun _getfolder (message / sh folder result) (setq sh (vla-getinterfaceobject (vlax-get-acad-object) "Shell.Application")) (setq folder (vlax-invoke-method sh 'browseforfolder 0 message 0)) (vlax-release-object sh) (if folder (progn (setq result (vlax-get-property (vlax-get-property folder 'self) 'path)) (if (wcmatch result "*\\") result (strcat result "\\") ) ) ) ) (defun _getplotconfigs (doc / out) (vlax-for x (vla-get-plotconfigurations doc) (setq out (cons (cons (strcase (vla-get-name x)) x) out)) ) ) (setq adoc (vla-get-activedocument (setq doc (vlax-get-acad-object)))) (cond ((not (setq l (_getplotconfigs adoc))) (princ "\nNo plot configurations in current drawing!") ) ((not (setq odbx (if (< (setq v (substr (getvar 'acadver) 1 2)) "16") (vla-getinterfaceobject doc "ObjectDBX.AxDbDocument") (vla-getinterfaceobject doc (strcat "ObjectDBX.AxDbDocument." v)) ) ) ) (princ "\nObject DBX interface not created!") ) ((if (setq dir (_getfolder "Select directory to apply current drawing pagesetups to: ")) (foreach f (vl-directory-files dir "*.dwg" 0) (setq file (strcat dir f)) (if (vl-catch-all-error-p (vl-catch-all-apply 'vla-open (list odbx file))) (princ (strcase (strcat "\nError opening: " file))) (progn (princ (strcat "\nOpening: " file)) (setq plt (vla-get-plotconfigurations odbx)) (if (not (zerop (setq n (vla-get-count plt)))) (progn (princ (strcat "\n\t" (itoa n) " - plot configurations removed")) (vlax-map-collection plt 'vla-delete) ) ) (and (vlax-invoke adoc 'copyobjects (mapcar 'cdr l) plt nil) (princ (strcat "\n\t" (itoa (length l)) " - plot configurations copied from current drawing" ) ) ) (vla-saveas odbx (vla-get-name odbx)) ) ) ) (princ "\nBuh bye...") ) ) ) (princ) ) (c:copyplotconfigs) Quote Link to comment Share on other sites More sharing options...
RobDraw Posted June 3, 2016 Share Posted June 3, 2016 Sorry, it worked for me in the past. Did you create a named page set-up? If so, does it also reside in the other files? The LISP may not overwrite one that already exists. I don't really have time to do any testing ATM. Maybe over the weekend. Let me know if you get it working or find another solution. Quote Link to comment Share on other sites More sharing options...
Tripledot Posted June 3, 2016 Share Posted June 3, 2016 Sorry, it worked for me in the past. Did you create a named page set-up? If so, does it also reside in the other files? The LISP may not overwrite one that already exists. I don't really have time to do any testing ATM. Maybe over the weekend. Let me know if you get it working or find another solution. The earlier test the dwg has the same multiple page setups. I just tested with a new drawing. So basically what it does is transfer ALL multiple page setups over to the drawings within that folder. It did not set the page setup. It that it? I though the lisp will help to set the page setup base on another dwg 'setted' page setup? edit I just notice this Copies plot configurations from the current drawing Quote Link to comment Share on other sites More sharing options...
RobDraw Posted June 3, 2016 Share Posted June 3, 2016 That does sound familiar. You might need another LISP to make the page set-up current. IMHO, a client asking for a page-set-up on files that you have edited is asking too much unless you promised it in the contract. When you receive the files, is their page set-up named? If not, name it and save a file so that you can import it. That way there can be no mistakes on your end. Thinking out loud here: It should be fairly easy to code an import and set current a named page set-up. This could possibly be combined with a save command. The batch processing part, I'm not so sure about. Quote Link to comment Share on other sites More sharing options...
Steven P Posted June 3, 2016 Author Share Posted June 3, 2016 I get the idea, and understand what you are saying. Get one page setup right, good and correct, copy that setup to the others and they should all be good and correct. It is possible to do this with a LISP routine, change a few details in it for each client and project, like the source file for the good page setup and off you go for each project. Plenty of examples online to do this. Of course, and we all know that what the clients send out are not always the correct format that they want returned. They won't complain about what they send out but will for what they get back, spending 30 seconds per drawing here can save a week of arguments with their document controllers. It is never worth assuming their files are good. Anyway, thanks so far, I understand your preference and in an ideal world where no one changes the master drawings page setup it will work beautifully, thanks for pointing me in that direction. Just as a matter of interest for me now, is it possible to have a line or 2 in a LISP routine that will set just the page setup to landscape or portrait without having to copy another drawings page setup or to use the _plot method to setup up a page Cheers Quote Link to comment Share on other sites More sharing options...
Tripledot Posted June 4, 2016 Share Posted June 4, 2016 Just as a matter of interest for me now, is it possible to have a line or 2 in a LISP routine that will set just the page setup to landscape or portrait without having to copy another drawings page setup or to use the _plot method to setup up a page Cheers maybe include all the setup eg. papersize, plotter.....etc. but without any setup name that will be so neat Quote Link to comment Share on other sites More sharing options...
BlackBox Posted June 4, 2016 Share Posted June 4, 2016 This may be of use - It's a custom LispFunction Method that sets a named Page Setup active, and works with ODBX: http://forums.augi.com/showthread.php?80461-Page-Setup-Manager&p=1219546&viewfull=1#post1219546 Example: (foreach layoutname (layoutlist) ([color="blue"]vla-SetActivePageSetup[/color] layoutname “[color="red"]YourPageSetupName[/color]”) ) Cheers Quote Link to comment Share on other sites More sharing options...
Steven P Posted June 4, 2016 Author Share Posted June 4, 2016 Thats the plan Tripledot, I have got so far with that but some parts of what I have done are not the best. I am struggling with the page orientation part at the moment, pretty sure somewhere there will be someone who can work out how to just change page orientation as a line in a LISP. Blackbox, weekend at the moment so I can check on Monday, but doesn't that just copy the whole layout rather than just altering the page orientation? Quote Link to comment Share on other sites More sharing options...
BlackBox Posted June 5, 2016 Share Posted June 5, 2016 ... doesn't that just copy the whole layout rather than just altering the page orientation? No - what gave you that impression? The vla-SetActivePageSetup LispFunction does nothing but precisely that; set a (named) Page Setup as active, for a given Layout. Cheers Quote Link to comment Share on other sites More sharing options...
Steven P Posted June 10, 2016 Author Share Posted June 10, 2016 found this which appears to be close to what I want to do: (defun c:setlayoutname() (setq layoutname (vla-get-name (vla-get-ActiveLayout (vla-get-activedocument (vlax-get-acad-object ))))) (setq AD (vla-get-activedocument (vlax-get-acad-object ))) ;;AD Active Document (setq AL (vla-get-ActiveLayout AD)) ;;AL Active Layout ) (defun c:getplotrotation() (c:setlayoutname) (vla-get-PlotRotation AL) ;;; alt. (ac0degrees ac90degrees ac180degrees ac270degrees) (vla-put-PlotRotation AL ac0degrees) (princ (VLA-get-PlotRotation AL)) ) from the autodesk forums: http://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/using-activex-lisp-to-get-set-plot-configuration/td-p/883677 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.