I would like to ‘brainstorm’ a little bit… Or hear some suggestions how to tackle this problem.
I have a very large script to print PDFs of all sizes and rename them accordingly.
Unfortunately i am running into some issues.
Normally, an A2 sheet would be 420mm high, but now i have a revit file from a client that uses 421 mm. Therefore the script doesnt work.
It filters the sheets on height and width. So a mm difference will cause the sheet to not be printed…
My best bet is to round the height and width… But i am not sure how to round to a specific number.
For example, I have 2 A4 heights, 297 and 294. I would want to round 294 to 297 so the correct size (297) is used. I dont think clients will notice their A4 titleblock became 3mm taller…
Adding every single paper size to my PDF Printer will be a pain… This would mean the script could become defective every single time we start a new project.
I have to filter on height and width since titleblocks from different clients can both be called A0, but have 30cm size difference…
I would like to know what some of you would do to solve this issue, maybe some of you ran into a similar problem.
Tldr; Different clients use different paper sizes( A2=421mm high or 420mm high). This causes the script to not print this specific size. I HAVE to filter on sheet height and width and cant filter by titleblock name.
To clarify a part of my script that filters all sheets:
I have two thoughts. The first is to use a dictionary and pull the get via nested if statement. The second is to use a geometry test to pull the first TB which completely encompasses the max point of the TB.
Set up a series of rounding limits for the various values and use a dictionary to pull the right paper size. Since you’ll always ‘round up’ (drawing won’t fit on the paper otherwise) you will be asking if the page is less than the ‘max’ your page will allow. An example using numbers which aren’t paper based:
W < 5 ? “A” : W < 10 ? “B” : W < 15 ? “C” : “Too big to fit”; In English instead of design script:
If the width is less than 5 return “A”, otherwise if the length is less than 10 return “B”, otherwise if the length is less than 15 return “C”, otherwise return “Too big to fit”. Assuming you have standard sizes, I would recommend only testing the width, or the height, and see how that works in a variety of projects.
For the geometry test build a list of rectangles which represents all of your page sizes in landscape orientation, in increasing size. Then rotate them all by [0,90] on the Z axis with cross product lacing, and flatten the list - the sizes should still be increasing when done. Next pull the titleblock’s width and height, divide by two, and make a point at that location (so page size was 8.5x11, the point would be 4.25, 5.5). Then use a polygon containment test to see if the point is inside each rectangle. Now use a List.IndexOf node to pull the first ‘true’ value, and get the page size from your list of page sizes.
I would recommend using the first method, but if you have a really large number of page sizes the if statement can get overwhelming, and with inconsistent ratios the need to test the height can complicate things further.
You could have the filter check for either of the two values, or search for a range of values 410…430
Hello Jacob and Hamish,
My apoligies for my late reply… Unfortunately i ran into some other, more pressing issues with my script…
After reading your proposal to solve this i came up with another way to solve this issue that i would like to share here. I can imagine someone else will run into this while recreating a PDF print script from examples on this forum.
The 1mm difference was a user error, so that solves it. But the main problem with the way i was filtering sheets was that the script got painfully slow.
As you can see in the picture below, this script got enormous for determining print settings (64 print settings in total…)
I replaced that entire monstrocity with a simple dictionairy.
This made the script so much faster i couldnt even believe it.
So for anyone trying to filter titleblock sizes against print settings, this is the way you could do it with a dictionairy.
Again, thanks for your suggestions:)