Automatic Papersize

Automatic Papersize

thomas_schluesselberger
Advocate Advocate
10,792 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,793 Views
93 Replies
Replies (93)
Message 61 of 94

Moshe-A
Mentor
Mentor

@thomas_schluesselberger ,

 

Well, to our unfortunate (and as far as i know) autolisp \ activex doesn't provide us with a function to know the bounding box of a visibility state, only the whole block reference.

 

Moshe

 

 

 

0 Likes
Message 62 of 94

thomas_schluesselberger
Advocate
Advocate

Ok,

 

that's not so great, but thanks for the answer.

 

 

0 Likes
Message 63 of 94

thomas_schluesselberger
Advocate
Advocate

Hi @Moshe-A ,

 

i have another question:

 

As you already answered it's not possible to get the bounding box of a visibility state of a block.

I just built my dynamic block in a different way and it works just like i want.

 

But now i tried to add a visual display of the length and height of my dynamic block.

I do this with an attribute and a textfield which displays the length and hight parameter. 

 

The problem:

When the attribute and text are outside of my polylines (the lines the LISP gets the papersize from), the LISP doesn't read the right box. It always adds the attribute and text to the papersize box.

 

Is there a way to edit the LISP, that it doesn't react to attributes and texts.

When there are texts in the layout, it works that the LISP doesn't react on them.

But when they are inside a block it does.

 

0 Likes
Message 64 of 94

Moshe-A
Mentor
Mentor

@thomas_schluesselberger  hi,

 

to solve this you have 2 options:

 

1. the texts will not be part of the title block

 

or

 

2. the texts are part of the title block and MPSETUP instead of looking for the largest block \ polyline in layout will look for the largest close polyline inside title block and take it's boundary dimensions. for this you will have to decide what is the block (or blocks) name cause it should be hard coded and to keep it simple by inserting it in 1X1 scale and rotation=0 

 

Moshe

 

0 Likes
Message 65 of 94

thomas_schluesselberger
Advocate
Advocate

Hi, 

 

i did it with option 1, thanks for you help again!

0 Likes
Message 66 of 94

Moshe-A
Mentor
Mentor

@thomas_schluesselberger ,

 

i will create a version that start by looking for the big polyline in current layout, if it found that it. if a title block found it will enter inside to look for the big polyline - how is that sounds?

 

Moshe

0 Likes
Message 67 of 94

thomas_schluesselberger
Advocate
Advocate

Sounds even better, so i can have my text's inside the title block.

0 Likes
Message 68 of 94

Moshe-A
Mentor
Mentor

@thomas_schluesselberger ,

 

yes

 

tonight is the night 🤣

0 Likes
Message 69 of 94

Moshe-A
Mentor
Mentor

@thomas_schluesselberger ,

 


@Moshe-A wrote:

@thomas_schluesselberger ,

 

i will create a version that start by looking for the big polyline in current layout, if it found that it. if a title block found it will enter inside to look for the big polyline - how is that sounds?

 

Moshe


i had success in implementing the above but than i fell into the catch, the media is stretched 😩

now we have to decide what to do?

Can you say for sure that all your title blocks always dynamic? contain (at least) 2 dynamic properties Lange + Hohe (i need to install German language to create these strings 😀).

 

Moshe

 

 

 

 

0 Likes
Message 70 of 94

thomas_schluesselberger
Advocate
Advocate

Hi!

 

I've attached a drawing where I created a layout for each of the 3 possible cases.

 

1.) titleblock -> if the block is used, the linear parameters are always included. All the polylines are inside this block. There are also attributes outside of the polylines (where i show the lenght and hight of the block)

 

2.) titleblock-bursted -> the titleblock got bursted, a closed polyline outlines the border.

 

3.) A3-landscape -> a non-dynamic block is used here (no parameters). The same block is available in a similar design for A3-portrait, A4-landscape and A4-portrait.

 

It is also likely that there will be several of these 3 options in one drawing. e.g.: 5x layout with title block, 1x layout with bursted titleblock and 2x layout with A3/A4 block. 

 

0 Likes
Message 71 of 94

Sea-Haven
Mentor
Mentor

Just a comment looking for burst title bock is not a good idea and possibly not a good drafting practice. Any way look at this is setup for numerous title blocks looking in each layout before plotting.

 

 

(cond 
((=  blkname "TITLE_BLOCK_A0_V4" )(setq sc "1=1" psize "ISO full bleed A1 (841.00 x 1189.00 MM)" ll "-6,-6" ur "1175,837" orien "Landscape"))
((=  blkname "TITLE_BLOCK_A1_V4" )(setq sc "1=1" psize "ISO full bleed A1 (594.00 x 841.00 MM)" ll "-6,-6" ur "837,590" orien "Landscape"))
((=  blkname "TITLE_BLOCK_A1PORT_V4" )(setq sc "1=1" psize "ISO full bleed A1 (594.00 x 841.00 MM)" ll "-6,-6" ur "577,823" orien "Portrait"))
((=  blkname "TITLE_BLOCK_A2PORT_V4")(setq sc "1=1" psize "ISO full bleed A2 (420.00 x 594.00 MM)" ll "-6,-6" ur "416,591" orien "Portrait"))
((=  blkname "TITLE_BLOCK_A3PORT_V4")(setq sc "1=1" psize "ISO expand A3 (297.00 x 420.00 MM)" ll "-3,-3" ur "280.4,403.5" orien "Portrait"))
((=  blkname "TITLE_BLOCK_A4PORT_V4")(setq sc "1=1" psize "ISO full bleed A4 (210.00 x 297.00 MM)" ll "-6,-6" ur "206,293" orien "Portrait"))
((= blkname "TITLE_BLOCK_A1_V4")(setq sc "1=1" psize "ISO full bleed A1 (841.00 x 594.00 MM)" ll "-6,-6" ur "837,590" orien "Landscape"))
((= blkname "TITLE_BLOCK_A2_V3")(setq sc "1=1" psize "ISO full bleed A2 (594.00 x 420.00 MM)" ll "-6,-6" ur "590,416" orien "Landscape"))
((= blkname "TITLE_BLOCK_A3_V4")(setq sc "1=1" psize "ISO full bleed A3 (420.00 x 297.00 MM)" ll "-6,-6" ur "406.5,283.4" orien "Landscape"))
((= blkname "TITLE_BLOCK_A4_V4")(setq sc "1=1" psize "ISO full bleed A4 (297.00 x 210.00 MM)" ll "-6,-6" ur "293,206" orien "Landscape"))
)

 

 

 

0 Likes
Message 72 of 94

Moshe-A
Mentor
Mentor

@thomas_schluesselberger 

 

Probably you missed some heart beats i did not been here for two days? i was very busy at work and looking for solution to this and i have found ‌‌😀

 

Here are the details how this works now:

It start by looking for the biggest object (pline or title block) in current layout. if it's a pline, it's bounding box is taken. if it's an insert, it scans inside looking for the biggest pline. if there is no polyline inside, the bounding box of the outer insert is taken. if pline found, it's bounding box points is translated to the outer coordinates system e.g the Layout. if the insert is dynamic block and has "Lange" + "Hohe" parameters, these values is applied to the bounding box but  Thomas there is a problem here. AutoLISP\ActiveX does not give us tools (functions) to know how the Linear parameter is build (e.g it's geometric) i mean it's start\end point only it's name, desc and current value can be retrieve . this info is important to know how to apply the parameter\action to the bounding box so to resolve this i made an assumtion that the "Lange" and "Hohe" parameters start points is aligned with the title block insertion point. if it isn't, the outcome will be wrong also the insertion point of the block should be on the pline corner.

 

Unfortunatly my english AutoCAD version could not read the German 'a' and 'o' characters. when it reads the parameter name it returns with '?' (and i have installed German Langauge) so to make it work, i change them to english characters. you also must change them. Attached 123.dwg after i changed the parameters name and it works on all 3 Layouts. Note about "A3 Landscape", you must set to "No" the Sps option.

 

Oh,  one last thing...

i have changed things order. this version first echos prompt (no delay) and then read media pages + process layouts

 

enjoy,

Moshe

0 Likes
Message 73 of 94

Moshe-A
Mentor
Mentor

@thomas_schluesselberger ,

 

Made fine tuning to mpsetup.vlx, Sps option now accepts integer value 1/0 but also i left Yes/No

i added more descriptive error messages when a pline is not found or dynamic parameters are not exist.

 

also attached chk.lsp file , i want you to run CHK command on your dynamic title block and copy and paste it's output to a text file and sent it back here. this command will show us how your German AutoCAD version saves dynamic properties name. it will help us to decide if you can keep naming in German or change it to English?!

 

Moshe

 

 

0 Likes
Message 74 of 94

thomas_schluesselberger
Advocate
Advocate

Hello! @Moshe-A 

 

I hope your weekend was nice.


As you wanted, I ran the chk LISP and attached you the output below.

 

If it's not possible to keep my german parameter names, then please change it so that i can use the following names: "Laenge" and "Hoehe".

 

(In German, umlauts can be converted like this: ä -> ae, ö -> oe, ü -> ue.)

 

And because I have to mention it every time:

Thank you again for your work and time!

0 Likes
Message 75 of 94

Moshe-A
Mentor
Mentor

@thomas_schluesselberger ,

 

Attached is my print when i'm doing it on English AutoCAD version, as you can see there are '?' question marks where Autocad can not understand the character and it's in the dwg database. so there are 2 options for solution:

 

 i prefer to read these 2 strings from outsize file (or some settings) which you can control

        or 

if 1 is not convenient i'll go with your suggestion.

 

agree? 😀

 

Moshe

 

0 Likes
Message 76 of 94

thomas_schluesselberger
Advocate
Advocate

Hi,

 

i think it's easier to just rename the parameter to "Laenge" and "Hoehe".

So it doesn't get too complicated.

0 Likes
Message 77 of 94

Moshe-A
Mentor
Mentor

Ok you are the Boss 😀

0 Likes
Message 78 of 94

Moshe-A
Mentor
Mentor

@thomas_schluesselberger ,

 

That's it my friend - done!

(do not forget to change the Linear Parameter Name 😀)

 

Moshe

 

0 Likes
Message 79 of 94

thomas_schluesselberger
Advocate
Advocate

Thank's for your help again!

0 Likes
Message 80 of 94

Moshe-A
Mentor
Mentor

Tell me how it is working?

0 Likes