Automatic Papersize

Automatic Papersize

thomas_schluesselberger
Advocate Advocate
10,718 Views
93 Replies
Message 1 of 94

Automatic Papersize

thomas_schluesselberger
Advocate
Advocate

Hi!

 

I don't think there is a solution for this, but please convince me otherwise:

 

I would like a LISP program that allows me to automatically crop the paper sizes of all layouts. So the paper size should automatically adapt to the objects in the layout. So that there is no white border outside the viewport.

I would then like to create pdfs with "publish" as normal, but I don't want to have to crop the PDF every time.

 

Until now i always have to manually create a new paper size and set each layout individually.

 

0 Likes
Accepted solutions (1)
10,719 Views
93 Replies
Replies (93)
Message 2 of 94

pendean
Community Legend
Community Legend
Are you aware that you can create a Named VIEW with a CANNOSCALE set to your desired plot scale, then create a viewport using MVIEW command from that saved named view? Sort of like this freeware does it https://apps.autodesk.com/ACD/en/Detail/Index?id=2430986909281925511&appLang=en&os=Win32_64
Would that work?

>>>... manually create a new paper size...<<<
I'm curious more than anything about why you need to do this: whenever you feel inclined to reply with examples of course, no rush.
0 Likes
Message 3 of 94

thomas_schluesselberger
Advocate
Advocate

That's not really what I was trying to explain.

Example: In my layout, there are various lines around the plan frame, several viewports and blocks for the plan header. The limits of all objects together are 2000mm wide and 900mm high. My paper size is e.g. set to 5000x914mm. But I want a LISP that automatically sets the paper format to 2000x900mm. If the plan is only 1750x600mm in another layout, then the LISP should automatically cut the paper format to this size here as well. I also want to eventually enlarge a plan later and then I just want to run the LISP again and all the paper sizes will fit again.

 

I hope that is now understood.

0 Likes
Message 4 of 94

pendean
Community Legend
Community Legend

@thomas_schluesselberger wrote:

That's not really what I was trying to explain.

Example: In my layout, there are various lines around the plan frame, several viewports and blocks for the plan header. The limits of all objects together are 2000mm wide and 900mm high. My paper size is e.g. set to 5000x914mm. But I want a LISP that automatically sets the paper format to 2000x900mm. If the plan is only 1750x600mm in another layout, then the LISP should automatically cut the paper format to this size here as well. I also want to eventually enlarge a plan later and then I just want to run the LISP again and all the paper sizes will fit again.

 

I hope that is now understood.


Thanks for that extra info: explore and if possible give this a test run http://autolisps.blogspot.com/p/papersheetformat.html

 

And starting here (scroll down for more) https://www.cadtutor.net/forum/topic/61828-plot-user-paper-size/?do=findComment&comment=510281

 

Message 5 of 94

thomas_schluesselberger
Advocate
Advocate

Well, thanks for the answer.

 

I have tried the "paper sheet format" LISP but it doesnt work for me.

I always get the following error: "Bad argument type: streamp nil"

This happens with all these commands.

But I'm also not sure if the lisp does what I want. I would not have seen in the gifs that the paper format in the layout gets adjusted. 

 

Unfortunately, the other link doesn't help me either because I have almost no knowledge of LISP programming.

 

In principle, I would simply need an extra option for the plot area. So an option for "objects", that is, which limits the plot area to the objects in the layout. Regardless of how the paper format is set, only the objects are then printed.

 

See photo below: Only the objects (marked red) are printed and the blue area is automatically not printed.

thomas_schlu_0-1671609142833.png

 

 

0 Likes
Message 6 of 94

david.waight
Contributor
Contributor

Thomas,

 

I'm pretty sure what you are asking for isn't possible as there is no access to the custom page size settings via lisp (or .net).

 

It is something I have wanted for years, but it doesn't seem to be enough people wanting it to justify Autodesk providing access to that part of Autocad programmatically.

 

I find this strange as .pdf isn't restricted to any physical printer, so it should be easier to create page sizes just by selecting what you want to print and perhaps having default margins to make it look better on screen.

 

If a person wants to print the .pdf then they can scale it to their default printer (if it is too big) or request a .pdf scaled to a certain standard sheet.

0 Likes
Message 7 of 94

Moshe-A
Mentor
Mentor

@thomas_schluesselberger  hi,

 


@thomas_schluesselberger wrote:

That's not really what I was trying to explain.

Example: In my layout, there are various lines around the plan frame, several viewports and blocks for the plan header. The limits of all objects together are 2000mm wide and 900mm high. My paper size is e.g. set to 5000x914mm. But I want a LISP that automatically sets the paper format to 2000x900mm. If the plan is only 1750x600mm in another layout, then the LISP should automatically cut the paper format to this size here as well. I also want to eventually enlarge a plan later and then I just want to run the LISP again and all the paper sizes will fit again.

 

I hope that is now understood.


post a sample dwg with your title block.

 

to make it clear, you want the lisp to shrink (or enlarge) the paper size around your title block and some time after run it again and it will restore the origin back?

 

Moshe

 

 

0 Likes
Message 8 of 94

Sea-Haven
Mentor
Mentor

So your plotting at 1:1 but on a roll plotter if you can have a plot length of 5m. 

 

If you make custom sheet sizes for length say 200mm intervals starting at 1000m that would be 20 custom sizes. with length controlling.

 

You can set your sheet size in a plot lisp. Looking at this,

 

 

(COMMAND "-PLOT"  "Y"  "" "DWG To PDF"
	       "Iso full bleed A3 (420.00 x 297.00 MM)" "m" "LANDSCAPE"
"y" "Acad.ctb" "Y"	"n" "n" "n" pdfName "N" "y"
    )

 

 

 

So Iso A3 is sheet size in the plot lisp you would have 

 

 

(COMMAND "-PLOT"  "Y"  "" "DWG To PDF"
	       Sheetsize "m" "LANDSCAPE"
"y" "Acad.ctb" "Y"	"n" "n" "n" pdfName "N" "y"
    )

 

 

Sheetsize is correct custom size.

 

You would just window the objects get a length and look for closest enclosed size. You only need to do the custom sizes once.

 

(cond
((> len 4801)(setq sheetsize "5000x900"))
((> len 4601)(setq sheetsize "4800x900"))
((> len 4401)(setq sheetsize "4600x900"))
........
)
0 Likes
Message 9 of 94

maratovich
Advisor
Advisor

Maybe this will help you - Revers 

---------------------------------------------------------------------
Software development
Automatic creation layouts and viewport. Batch printing drawings from model.
www.kdmsoft.net
0 Likes
Message 10 of 94

Moshe-A
Mentor
Mentor

@thomas_schluesselberger  hi,

 

Have a prefect solution for you, are you here?

 

 

0 Likes
Message 11 of 94

thomas_schluesselberger
Advocate
Advocate

Yes, im here now.

0 Likes
Message 12 of 94

Moshe-A
Mentor
Mentor

@thomas_schluesselberger  hi,

 

Attached mpsetup.zip file contains 4 files:

mpsetup.vlx                     - the lisp file.

mps_supp.lsp                  - support the first file.

DWG to PDF - MPS.pc3   - sample plotting configuration file

mpsetup.dwg                   - sample drawing file.

 

save the pc3 file in plotter folder (with all yours pc3 files) save the lisp files (+ sample dwg) in a recognized folder by AutoCAD support files. 

 

First open the sample drawing i made (do not rush to run it on yours) it contains 13 layouts from A4,A3 up to 150x91 cm sheets. i'm aware you are looking only solution for large sheet format but a decent program must be prepare for all sheets format. each layout contain a block called it titleblock you can replace it with your title block (the name does not matter) or just put a rectangle. 

 

now load mpsetup.vlx in and invoke MPSETUP command.

 

Command: MPSETUP
Apply Plotting Configuration to Layout(s) [All/Current] <Current>:

 

All to set the suitable media page to each layout (according to your title block) and set the same printer. (Current obviously  is for the current layout)

 

now if you go to pagesetup command choose my  DWG to PDF - MPS.pc3  printer drop down the page size you will see there a lot of custom "User 1" papers i added.  

 

now open mps_supp.lsp file in text editor like notepad (better in Autolisp IDE)  you will see the following lines

(setq PCONFIGFILE "DWG to PDF - MPS.pc3") 
(setq MEDIASTEP 100) 

 

these are two variables that you can set, the first PCONFIGFILE your favorite printer and the second MEDIASTEP in mm. the mediastep defines the increment for the media page starting from 1200x914, 1300x914....up to 5080,914 (which is the max for pdf)

 

unfortunately AutoLisp does not provide us with functions (tools) to modify the pc3 media size programmaticlly  and you must add yours manually (just as i did) to cover all your media pages.

 

program course:

tries to load mps_supp.lsp (yours favorites for printer & media step) and if it does not find it uses the defaults which is what you see now in the file than it looks for the printer file (pc3) which must lay in plotter folder. if the file is not found, program stop. the process than step into each layout to auto assign the printer + suitable media size + 1:1 scale on mm units. the layout names is echoed to the command line. 

 

each run of MPSETUP, the current printer & media size (also plot scale & units) is saved to dwg database.

Use the RPSETUP command to restore the previous settings 😀

 

if it does not work for you, post the dwg.

 

enjoy

Moshe

 

Message 13 of 94

thomas_schluesselberger
Advocate
Advocate

thank you in advance. I'll take a look and get back to you

0 Likes
Message 14 of 94

Moshe-A
Mentor
Mentor

@thomas_schluesselberger ,

 


@thomas_schluesselberger wrote:

thank you in advance. I'll take a look and get back to you


 

Well? any conclusion?

 

Moshe

 

0 Likes
Message 15 of 94

thomas_schluesselberger
Advocate
Advocate

I have to talk to our system administrator first because i don't have administrator rights on my pc to add new pc3 plotter files. It may take a while, but I'll report back once I've tested it.

0 Likes
Message 16 of 94

Sea-Haven
Mentor
Mentor

You dont add PC3 just modify existing pc3 and add pdf sizes etc.

0 Likes
Message 17 of 94

thomas_schluesselberger
Advocate
Advocate

Ok but @Moshe-A wrote i should save the pc3 in the printer folder. And that's what I can't do without admin rights.

 

And i don't want to modify my existing printer settings or add extra paper sizes to it.

 

 

0 Likes
Message 18 of 94

Moshe-A
Mentor
Mentor

@thomas_schluesselberger ,

 

that's a little weird, cause the plotters folder is under your personal profile. surely the system admin can direct it to a network shared folder (which by the way i do not recommend cause anyone can modify it) but with OPTIONS you can add another private plotter folder on your disk C to coexist with the system admin folder. of course do it only with his permission. another way is to copy your DWG to PDF.pc3 with other name and add media sizes.

 

wonder 🤔 if you are not allowed to add outside pc3 how do you plan to add outside lisp file?

 

Moshe

 

 

 

0 Likes
Message 19 of 94

thomas_schluesselberger
Advocate
Advocate

Hi!

 

I've tested the program now and it doesn't work for me.

 

I did the following steps:
1.) At first it couldn't find the pc3 and support LISP but then i added a new path in AutoCAD where to locate recognized folder by AutoCAD support files. Also i renamed the pc3 from "DWG To PDF - MPS.pc3" to "DWG to PDF - MPS.pc3" (small t because it couldn't find the LISP with an big T).

 

2.) Opened your DWG.
(Question: You said that there are blocks in every layout. But these are only polylines, is that intentional?)

 

3.) Then, like you said, I loaded mpsetup.vlx and executed the MPSETUP command.

 

4.) Then I selected "all".

 

5.) At "pagesetup" I didn't find any new page setup with "User1...".

 

6.) In the LISP "mps_supp.lsp" I left everything as it was

 

Unfortunately I didn't understand this sentence you wrote:
"unfortunately AutoLisp does not provide us with functions (tools) to modify the pc3 media size programmatically and you must add yours manually (just as i did) to cover all your media pages."
Does that mean I have to add the paper sizes manually once and then the LISP can choose the paper size automatically?

 

Attached is the DWG where I tested the LISP. For testing I created a layout with a 1000x900 polyline.

Unfortunately that didn't work either

 

 

 

0 Likes
Message 20 of 94

Moshe-A
Mentor
Mentor

@thomas_schluesselberger ,

 


@thomas_schluesselberger wrote:

Hi!

 

I've tested the program now and it doesn't work for me.

 

I did the following steps:
1.) At first it couldn't find the pc3 and support LISP but then i added a new path in AutoCAD where to locate recognized folder by AutoCAD support files.

did you add it to?

Options\Files - Printer Support File Path\Printer Configuration Search Path

only there Autocad knows to find pc3 files.

 

 Also i renamed the pc3 from "DWG To PDF - MPS.pc3" to "DWG to PDF - MPS.pc3" (small t because it couldn't find the LISP with an big T).

No need to do that, upcase \ locase does not matter here.

 

2.) Opened your DWG.
(Question: You said that there are blocks in every layout. But these are only polylines, is that intentional?)

yes my mistake but as said also a simple rectangle is acceptable.

 

3.) Then, like you said, I loaded mpsetup.vlx and executed the MPSETUP command.

 

4.) Then I selected "all".

 

5.) At "pagesetup" I didn't find any new page setup with "User1...".

of course as i said: you need to add them manually but my DWG to PDF - MPS.pce already conatins a lot of media sizes.

 

6.) In the LISP "mps_supp.lsp" I left everything as it was, - OK

 

Unfortunately I didn't understand this sentence you wrote:
"unfortunately AutoLisp does not provide us with functions (tools) to modify the pc3 media size programmatically and you must add yours manually (just as i did) to cover all your media pages."

never mind


Does that mean I have to add the paper sizes manually once and then the LISP can choose the paper size automatically?

yes you got it

 

Attached is the DWG where I tested the LISP. For testing I created a layout with a 1000x900 polyline.

Unfortunately that didn't work either


 

Attached a video to exhibit how it works. track layouts from 120x91.4, 130x91.4, 140x91.4 & 150x91.4

i set (in all of them) media page 2000x914 which is large enough, PAGESETUP is invoked to show you the User 1 media sizes in pc3.  than MPSETUP invoked + REGENALL (this is needed to update all layouts)

 

See the change?

 

Moshe

 

 

 

0 Likes