Ultra Large PDF

One of my colleagues created a 7MB PDF from a CAD file today. This in itself is a sure sign that something was wrong with either the PDF or the generation of it. So after crashing Acrobat in an attempt to reduce the file size, I reviewed the PDF to see what might be the issue.

One part of the PDF took a while render in Acrobat which pointed out that the PDF contained something with dense information that was taking a while to load. Usually this is an image or some large single object like that.

Once I reviewed the source I discovered that there was no images attached to the file. So this was not the issue.

A quick Audit revealed 4 errors but this was not the issue either.

So, process of elimination. What is causing the issue. Delete various items from the sheet to see which item is cuasing the issue. I usually start with viewports.

This was done by deleting one at a time and creating a PDF each time. Each time I noted that the PDF was taking ages to generate, which also is a sign that something is not quite right.

Once I found the viewport I could look at that part of the model to see what the issue could be. From experience hatches can be problematic and it turned out that my colleague had created an ultra dense hatch that looked like a solid. Once changed to a solid hatch (which I don’t like, but that’s another story), the file printed file.

Interestingly AutoCAD sometimes pops up a box saying to convert these to solid or increase the scale but it did not do so on this drawing, so don’t rely on that to tell you if there is an issue with ultra-dense hatches.

Create Hatch

Bizarrely AutoCAD has not (as far as I am aware) created an easy hatch creation method, preferably in a GUI. This is long, long, long outstanding and should have been introduced back in R14 or earlier. If you want to create a hatch, you have to write it out by hand in a text file (there is no automation either), giving the text file a .pat extension.

Apart from the header row for the name and description of the hatch file, the hatch format is like this:

angle, x-origin,y-origin, delta-x,delta-y,dash-1,dash-2

Each line in the text file describes a drawn line, whether this is solid or dashed. All patterns are made from lines that are dashed or continuous and nothing else (a dot a line with a very short or no length). The dash length is variable so you then build up a hatch patten from a set of dashed lines that intersect. 

In order to create say herringbone brick you have the following pattern text:

0, 0,0, 10,10, 30,-10
90, 20,-30, -10,10, 30,-10

This creates a dashed line one way that intersects with one 90 degrees to it and when they repeat a brick pattern occurs. For such a simple shape it is still quite hard to wrap your head around the way they work!

If a complex hatch is required it is expected of the user to somehow translate their drawings from a set of lines into the hatch format. This is of course nigh-on impossible for most users and for a pattern with over one hundred entities will take forever to measure and write out the results, and the 7 step help file isn’t really that helpful and is quite vague.

This is one my major annoyances in AutoCAD that they fiddle with this and that and don’t fix fundamentally missing features like this!

——

If you are thinking, man I cannot do that, don’t worry if you have the full version of AutoCAD (sorry LT guys) you can install a LISP file to do this for you. The awesome guys at Cadalyst posted in one of their tips a hatch creation LISP.

This LISP has two functions, draw and save. Accessed through DRAWHATCH and SAVEHATCH (strangely enough).

The draw hatch command command creates a 1×1 box in drawing units, so for metric in my case this is a 1x1mm box. Tiny!

——

So this is the process I followed to create my hatch.

Firstly, draw your tessellating hatch inside a square, using only line entities. Make sure no curves are present. Then copy this in all directions to make sure the tessellation works! Save this drawing as your template for the hatch.

Secondly, scale your square down to a 1×1 unit square. You can save this as another file if you want. Leave this drawing open (save first, as always before doing anything major).

Thirdly create a new drawing and run DRAWHATCH. This will create a 1×1 unit square with nothing in it. Go back to your open drawing and copy the entities within the square (you can copy the square for ease and delete it after the copy if you want), and paste inside the square drawn in the new drawing by DRAWHATCH.

Fourthly, run SAVEHATCH and select the line objects (polylines won’t work so explode them first) and follow the prompts. A command line window will appear to make things easier.

Fifthly, give it a description and then save it as a file name in a place where you can load them into AutoCAD. Our practice as a server folder for custom hatches.

So that’s it you now have a hatch. One of the problems I encountered with this method is that the created hatch is very small. You will have to enter a large scale factor to correct this.

——

If you are feeling adventurous, you can load the pattern file into Excel and scale the numbers created up to suit. Save out as CSV to get the comma delimited text file back!