Save as PDF with additional bookmarks (a tale)
Save as PDF with additional bookmarks (a tale)
(OP)
Just a small tip for people at companies rely which on PDFs. If you save a drawing as a PDF in SolidWorks, bookmarks in the PDF are automatically generated, one for each drawing view on the sheet. Just for review, a bookmark in PDF is simply a saved view of a particular section of the document. So, this got me thinking, “Hey, wouldn’t it be nice to have bookmarks of the drawing notes, revision and title book automatically generated too for our vendors and during change order review?”
So being the innocently minded fool that I am, I added three empty views to my E size drawing template, one over each of those areas mentioned. I choose E size to start with cuz no one here really uses that size very often and had I implemented the change too quickly (even though I was working with a backup copy at first), it wouldn’t have been a big deal to undo and try something else. Anyways, E worked great. When I saved it as a PDF, the empty views where automatically added as bookmarks to the PDF. In the PDF, each area was completely within their bookmark.
Ok, let’s try this on D size! Hmm, oh, empty views are sized based on a ratio of the sheet size where they appear. An empty view on an E size is a different size than an empty view on a D or C size. They are smaller by some unstated ratio. Since SolidWorks removed the ability to resize drawing views back in 2005, how was I going to get these empty views to be sized correctly?
I tried API. I discovered that there’s an old function in the API that does indeed allow for the creation of empty drawing views at whatever size you like. However, once the drawing is saved and reopen, SolidWorks resets all empty views back to the randomly static ratio default. The only way to use API was to create some complete code that would know what size sheet is open, and how to handle it each and every time someone saves as PDF. And what about multisheet drawings? Too hard! No dice. Dang!
I asked my VAR’s API expert if there was some other way in API. He wasn’t able to come up with anything either, except by creating what amounts to be a whole new application.
So, square one. How ARE drawing views sized? …by their content; lines, annotations, models, etc. ::sigh:: A line could be added to the view to give me whatever size I needed, but it couldn’t show up on the PDF or be accessible on the drawing itself within SolidWorks. Well, each of these areas of the drawing are near the top or bottom of the drawing. I could overlay it on top of the border itself. So, I added each empty view, added the line to get the desired width on top of the nearby border, and then fixed the line.
Wow, it worked! It worked pretty well. However, I feel like I’m using SolidWorks 1998Plus by using this sort of hack (anyone remember some of the kludges we had to use back then to get SW to allow us to just draft a drawing? But I am able to size the view as needed. I did have to make sure that each drawing view scale was set to custom to prevent that line from resizing when the sheet scale changed. Also, the only draw back is that SolidWorks does not currently allow for the fixing of the position of the drawing views themselves. So, in the heat of battle, it is possible that someone might move one of these views by accident and then have a strange line out in space that they didn’t realize (not to mention a rather pointless bookmark in the subsequent PDF). But overall, this solution works for what I wanted. It is a kludge after all.
Two enhancement requests have been made as a result. 1. Return the ability to control drawing view sizes via grips, but do so with a toggle and not as a default (since this function did annoy a lot of people in the past). Give the user the choice on a view-by-view basis as to whether or not it is manually resizable. Default of course would be automatic with the user selected option to make it manual. 2. Add the ability to lock the positions of drawing views.
So being the innocently minded fool that I am, I added three empty views to my E size drawing template, one over each of those areas mentioned. I choose E size to start with cuz no one here really uses that size very often and had I implemented the change too quickly (even though I was working with a backup copy at first), it wouldn’t have been a big deal to undo and try something else. Anyways, E worked great. When I saved it as a PDF, the empty views where automatically added as bookmarks to the PDF. In the PDF, each area was completely within their bookmark.
Ok, let’s try this on D size! Hmm, oh, empty views are sized based on a ratio of the sheet size where they appear. An empty view on an E size is a different size than an empty view on a D or C size. They are smaller by some unstated ratio. Since SolidWorks removed the ability to resize drawing views back in 2005, how was I going to get these empty views to be sized correctly?
I tried API. I discovered that there’s an old function in the API that does indeed allow for the creation of empty drawing views at whatever size you like. However, once the drawing is saved and reopen, SolidWorks resets all empty views back to the randomly static ratio default. The only way to use API was to create some complete code that would know what size sheet is open, and how to handle it each and every time someone saves as PDF. And what about multisheet drawings? Too hard! No dice. Dang!
I asked my VAR’s API expert if there was some other way in API. He wasn’t able to come up with anything either, except by creating what amounts to be a whole new application.
So, square one. How ARE drawing views sized? …by their content; lines, annotations, models, etc. ::sigh:: A line could be added to the view to give me whatever size I needed, but it couldn’t show up on the PDF or be accessible on the drawing itself within SolidWorks. Well, each of these areas of the drawing are near the top or bottom of the drawing. I could overlay it on top of the border itself. So, I added each empty view, added the line to get the desired width on top of the nearby border, and then fixed the line.
Wow, it worked! It worked pretty well. However, I feel like I’m using SolidWorks 1998Plus by using this sort of hack (anyone remember some of the kludges we had to use back then to get SW to allow us to just draft a drawing? But I am able to size the view as needed. I did have to make sure that each drawing view scale was set to custom to prevent that line from resizing when the sheet scale changed. Also, the only draw back is that SolidWorks does not currently allow for the fixing of the position of the drawing views themselves. So, in the heat of battle, it is possible that someone might move one of these views by accident and then have a strange line out in space that they didn’t realize (not to mention a rather pointless bookmark in the subsequent PDF). But overall, this solution works for what I wanted. It is a kludge after all.
Two enhancement requests have been made as a result. 1. Return the ability to control drawing view sizes via grips, but do so with a toggle and not as a default (since this function did annoy a lot of people in the past). Give the user the choice on a view-by-view basis as to whether or not it is manually resizable. Default of course would be automatic with the user selected option to make it manual. 2. Add the ability to lock the positions of drawing views.
Matt
CAD Engineer/ECN Analyst
Silicon Valley, CA
sw.fcsuper.com
Co-moderator of Solidworks Yahoo! Group






RE: Save as PDF with additional bookmarks (a tale)
Your idea of controlling drawing view sizes via grips is a good one. I forgot all about them. So I put in your enhancement request also for both ideas.
Good tale.
Bradley
SolidWorks Premim 2007 x64 SP4.0
PDM Works, Intel(R) Pentium(R) D CPU
3.00 GHz, 5 GB RAM, Virtual memory 12577 MB, nVidia 3400