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

page setup in lisp

21 REPLIES 21
Reply
Message 1 of 22
robert06
4985 Views, 21 Replies

page setup in lisp

I use a "-plot" lisp to print drawings on paper.

.....

(setq cnum (getreal "\nNumber of copies:\n"))

(command "-plot" "Yes" "" plname pasize "M" orient "No" "E" "1=1" "Center" "No" "." "Yes" "No" "No" "No" "No" "Yes" "No")
(vla-put-NumberOfCopies (setq plot (vla-get-plot (vla-get-activedocument
(vlax-get-acad-object)))) cnum)
(vlax-invoke-method plot 'PlotToDevice plname)

....

 

I'd like to maintain page setup which is set to print pdf after running the "-plot" lisp, but to enable the number of copies option, "save page setup" has to be set "Yes".

 

How to reset page setup after "-plot"?

 

I don't speak VLA, it has to be probably something like this:

http://autocadtips1.com/2012/05/18/autolisp-apply-current-page-setup-to-all-layout-tabs/

 

Current page setup is stored before running "-plot" and restored after.

 

thanks!

 

Robert

 

21 REPLIES 21
Message 2 of 22
BlackBox_
in reply to: robert06


@robert06 wrote:

 

How to reset page setup after "-plot"?

 


Hi Robert,

 

Following your -PLOT procedure, you can easily apply any named Page Setup using this; here's a quick example:

 

http://forums.augi.com/showthread.php?80461-Page-Setup-Manager&p=1219546&viewfull=1#post1219546

 

(foreach layoutname (layoutlist)
  (vla-SetActivePageSetup layoutname “YourPageSetupName”)
)

 

 

Cheers



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

Message 3 of 22
robert06
in reply to: BlackBox_

Hi, thanks! But could it be done without named Page Setup, my plotting lisp would be more universal then (previous page setup would be restored either a named page setup is there or not).

 

In the Autocadtips example I posted seems to have something i look for:

 

I understand this stores the current layout page setup?

 

(setq aDoc (vla-get-activedocument (vlax-get-acad-object))
clyt (vla-get-activelayout aDoc)
)

 

How to restore the setup in 'clyt' just for current layout after -plot?

 

Message 4 of 22
BlackBox_
in reply to: robert06


@robert06 wrote:

Hi, thanks! But could it be done without named Page Setup, my plotting lisp would be more universal then (previous page setup would be restored either a named page setup is there or not).

 

In the Autocadtips example I posted seems to have something i look for:

 

I understand this stores the current layout page setup?

 

(setq aDoc (vla-get-activedocument (vlax-get-acad-object))
clyt (vla-get-activelayout aDoc)
)

 

How to restore the setup in 'clyt' just for current layout after -plot?

 


Without more information, I can only offer a 'maybe?' at this time... You'll have to forgive my experience of having always used named Page Setups for their inherent benefits over having to set each-and-every-single setting correct for various PLOT options.

 

That said, the code you posted merely gets the 'active' Layout Object - that is to say which Tab is current - so for example, this yields the same result as CTAB sysvar:

 

(vla-get-name (vla-get-activelayout acDoc))

 

... The main difference being, that you can only get CTAB for the Active Document (the current open drawing), whereas the Visual LISP (ActiveX) code can be used to query other Documents open in the Editor, or even those not open in the Editor via ObjectDBX (mostly used for batch processing).

 

Cheers



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

Message 5 of 22
Jonathan3891
in reply to: BlackBox_

I would suggest having 3 page setups. Full, 11x17, & PDF.

You could even set them up in your project specific titleblocks, so when you import the titleblock it brings the page setups with it. Then you wont have to worry about changing pen tables for specific clients.

That's just my 02 Cents.

Jonathan Norton
Blog | Linkedin
Message 6 of 22
BlackBox_
in reply to: Jonathan3891


@dsm_dude wrote:
I would suggest having 3 page setups. Full, 11x17, & PDF.

You could even set them up in your project specific titleblocks, so when you import the titleblock it brings the page setups with it. Then you wont have to worry about changing pen tables for specific clients.

That's just my 02 Cents.

This is similar to what I do, although since the Autopublish mechanism was introduced back in 2009, I only use 'DWG to PDF' Page Setups, which allows me to always have a current plan set in PDF, given that as soon as I SAVE* my drawing, a PDF is produced.

 

When I need a sub-set of sheets for sendout, I just combine those PDFs that I need - no more PLOT, or PUBLISH required.

 

I mostly use the above linked custom LispFunction Method for ObjectDBX batch processing archived & inherited projects.

 

Cheers



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

Message 7 of 22
robert06
in reply to: BlackBox_

Thank you, I see the advantages of Named page setups. To avoid rewriting the procedure with Named page setups, which would take me ages, i'd like to stick to mine unless it's clear it is not possible at all.

 

This procedure i take as an example works well:

 

(defun c:cps (/ Adoc Layts clyt)
(prompt "\Copy current plot setup to all layouts")(terpri)
  (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)
)

 

 

I'd like to test it with current page only, is it possible?

 

First part to store current page setup:

 

(setq aDoc (vla-get-activedocument (vlax-get-acad-object))
clyt (vla-get-activelayout aDoc)
) ;; needs to be verifyed

 

2nd part plotting to network plotters, this is tested and works well:

....

(setq cnum (getreal "\nNumber of copies:\n"))

(command "-plot" "Yes" "" plname pasize "M" orient "No" "E" "1=1" "Center" "No" "." "Yes" "No" "No" "No" "No" "Yes" "No")
(vla-put-NumberOfCopies (setq plot (vla-get-plot (vla-get-activedocument
(vlax-get-acad-object)))) cnum)
(vlax-invoke-method plot 'PlotToDevice plname)

 

3rd part:

restore previous page setup stored in 1st part:

(foreach
        itm
           (vl-remove (vla-get-name clyt) (layoutlist))
    (vla-copyfrom (vla-item Layts itm) clyt)
) ;; how to write this for current layout only?

 

 

Message 8 of 22
thajmul2501
in reply to: robert06

hi

 

i have over 25 layout in one drawing. how can i put current plot style to rest of the layout .if anyone have lisp for this. its really appreciated.

 

Message 9 of 22
robert06
in reply to: thajmul2501

A simple way to accomplish this is to define plot style in model space page setup. It is prompted then to set the plot style table to all layouts.

Message 10 of 22
patrick_35
in reply to: thajmul2501

Hi

 

With MPL

 

@+

Message 11 of 22
robert06
in reply to: patrick_35

The MPL is a great lisp, but changes also all the other plot settings, not only the plot style.

Message 12 of 22
BlackBox_
in reply to: thajmul2501


@thajmul2501 wrote:

hi

 

i have over 25 layout in one drawing. how can i put current plot style to rest of the layout .if anyone have lisp for this. its really appreciated.

 


See post #2 of this thread.

 

You can use that as a custom routine to manually set the active Page Setup for any Layouts you like, or include in your AcadDoc.lsp to set them all on drawing open (which is what I do). 

 

Heck, you could even setup a routine to only set the active Page Setup for the Layouts you've selected, if you like:

 

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/i-need-a-list-of-selected-layout-tab...

 

 

 

Cheers



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

Message 13 of 22
patrick_35
in reply to: robert06

Oh sorry, I misunderstood the need

 

(defun c:pst(/ doc lay sty)
  (setq doc (vla-get-activedocument (vlax-get-acad-object))
	sty (vla-get-stylesheet (vla-get-activelayout doc))
  )
  (vla-startundomark doc)
  (vlax-for lay (vla-get-layouts doc)
    (vla-put-stylesheet lay sty)
  )
  (vla-endundomark doc)
  (princ)
)

@BlackBox_I was seeing your link post#2, I logged in to AUGI to see help that is not working.I have a hard time understanding what your job is for ?

 

@+

Message 14 of 22
BlackBox_
in reply to: patrick_35


@patrick_35 wrote:

Oh sorry, I misunderstood the need

 

(defun c:pst(/ doc lay sty)
  (setq doc (vla-get-activedocument (vlax-get-acad-object))
	sty (vla-get-stylesheet (vla-get-activelayout doc))
  )
  (vla-startundomark doc)
  (vlax-for lay (vla-get-layouts doc)
    (vla-put-stylesheet lay sty)
  )
  (vla-endundomark doc)
  (princ)
)

@BlackBox_I was seeing your link post#2, I logged in to AUGI to see help that is not working.I have a hard time understanding what your job is for ?

 

@+


Hi @patrick_35 - 

 

The code works fine, as I use it daily for my own work as a Civil Designer - that particular user seems to have an issue when copying the quotation marks in their text editor. If that is the case for you, simply replace the quotation marks in your text editor. 

 

I'm not sure that I understand what you're asking, when you say "I have a hard time understanding what your job is for ?

 

 

Cheers



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

Message 15 of 22
thajmul2501
in reply to: BlackBox_

thank you so much ur response
Message 16 of 22
thajmul2501
in reply to: robert06

hi robert

 

thank you so much ur quickly response. what i am trying to say, i attached the image. pls follow the image. i want to change at one time for all layout.

but i could not able to do. no need to change one by one then select apply again and again. can u help me. i am  waiting can anyone help me. god willingly i hope u will understand as i mentioned above.

 

thanks regards

 

hussain

Message 17 of 22
robert06
in reply to: thajmul2501

Hi,

I'm not sure what you're exactly trying to accomplish. Do you need to use exactly the same page setup in all layouts with plotter, page size, plot style & everything else set at once or to set just the plot style for all layouts?

 

Robert

 

Message 18 of 22
patrick_35
in reply to: BlackBox_

Hi

 

Simply, can you explain your function ?

 

@+

Message 19 of 22
BlackBox_
in reply to: patrick_35


@patrick_35 wrote:

Hi

 

Simply, can you explain your function ?

 

@+


Hi @patrick_35 -

 

So that I understand you correctly, which LISP-related function specifically (I've mentioned more than one), or did you mean the function I perform daily (aka, my job)?

 

 

Cheers



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

Message 20 of 22
patrick_35
in reply to: BlackBox_

No, I'm talking about the vla-SetActivePageSetup function because the help link is broken

 

@+

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

Post to forums  

Autodesk Design & Make Report

”Boost