Some time ago I have spotted this post by Sol Armor at DynamoBIM forum, asking about printing PDFs out of Dynamo and I was a little sad that we didn’t already have any tools for that. Recently (last Friday) I was also asked by my PA to print some stuff for him, and I was reminded just how limited current printing tools in Revit are. It’s not like I needed any more reasons to look at this issue, but also on Friday a colleague of mine told me they are “issuing a set” and are currently in a process of re-naming of hundreds of PDFs that were printed out of Revit. Why? Because per client wish/requirement they were obliged to name each PDF document with a Sheet Revision in its name…duh! Since every sheet was in a different revision state, we had a little pickle on our hands that couldn’t be solved without custom plug-in or x-amount of man hours. This is what I came up with in Dynamo instead:
So first thing that bothered me when I was printing, was that I couldn’t quickly print sheets that I needed at the moment and creating new sets every time I wanted to print but a new sheet was added to the set and I had to go back and edit the set that I created in a first place. It’s like my “100% CD” view set is good today, but tomorrow it sucks. So I though it would be way easier to use Dynamo to dynamically filter for sheets that I wanted, by any parameter – like Sheet Issue Date. So instead of relying on View Sets I can now dynamically create lists of sheets that I want to print.
Of course view sets are still a viable method of defining what sheets we want to print so I am still supporting that method. As a matter of time here’s how:
This way I can use both ways of defining what sheets I want to print but the final input into the Print PDF node will have to be a list of Sheet View Elements. Speaking of Print PDF node, here’s how it is set up:
Here’s the code for it:
We already covered Views, so let’s look at Print Range. In order to use a list of views we have to set Print Range to Select. This aligns with the procedure that you would use while working in the UI. I haven’t really tested other options like Current and Visible, but if someone gives them a try and they fail, let me know how they failed and i will try to fix it. Next thing up is a Combined File boolean input. If you set to to True the printout will be a single file, while if set to False you will print each sheet separately. Now, here’s an Adobe tip: Since I hate being prompted for a file name for every sheet, I guess others too, you can go to Start>Devices and Printers then Right Click on Adobe PDF (that’s the printer that I am using) to set Printer Preferences. Here’s what I set mine to: Unchecking “View Adobe PDF Results” will make sure that Adobe doesn’t open the newly printed file. It should speed things up a bit. Also, unchecking “Ask to replace existing PDF file” will supress any warnings caused by already existing files in the destination folder and they will be overridden by default. Last bit is to set the “Adobe PDF Output Folder”, which is a folder that all PDFs will be printed regardless of your current destination folder setting in Revit. Since these settings take precedent over in Revit settings, get used to seeing all of your prints always get dropped to this folder. It’s not the end of the day, and sure as hell is a decent time saver for me when plotting multiple sheets to a single PDF each. Next is a Printer Name. For this exercise I was using a Adobe PDF printer, but I guess some people prefer to use Bluebeam PDF or PDF995 printers as well. I haven’t tested it with any other printer, but again, feel free to give it a whirl and let me know how it went. To obtain names of all locally installed printers I use a node called Local Printers Names which wouldn’t be possible without great help from Stack Overflow community. I am in all honesty admitting that this kind of use of ctypes library is not in my tool belt. Anyhow, I got some help on this one and its pretty amazing: Next up are Print Settings. For now I was happy to just use one of the pre-defined user Print Settings, but in the future I will make a node where user can define its own settings. I guess ability to define your own settings will come super helpful when plotting PDFs to multiple sheet sizes. We could easily automate print setting assignment based on sheet size and make this tool even better. For now just pre-make one and use this node to select it: Edit 2015/08/08 : Print Settings now accepts a single item and/or a list. What that means is you can plot (100) sheets and for each one you can define (100) different print settings. Of course this is just one step closer to what I was discussing above where the intent is to be able to plot different sheet sizes in one run. Now, you can. Just supply a Print Setting name for each sheet and they will all be plotted to that setting. So if we have a setting for each sheet size, then we can pair up sheets with proper print settings and problem solved. We no longer have to run multiple plots because we have multiple sheet size that get issued. Below are two examples for each case: Next input is a File Path. This is a weird input. You remember that few lines up I said that when we specify a Default Output Folder in Adobe PDF Printing Preferences, then it will override this setting. Yes, it will, but Revit API is still expecting you to set it to something, or you can expect an error. Hence, I am making it an input and you can set it to some random file name but make sure that it ends with a *.pdf format. The final input is a Boolean toggle to make the script execute. I have started to put boolean toggles on most of my nodes, because I don’t want this node to print (it might take a while with a large set of sheets) every time I hit F5. Ok, at this moment we should have printed our drawing set and assuming they were individual sheets, they will all be named with the standard Revit naming convention: FileName – UserName – Sheet – SheetNumber – SheetName.pdf Of course this not the name that I want. If I am only interested in removing all of the stuff before Sheet Number and Name, then I am usually using a tool like Bulk Rename Utility. However, if my goal is to rename each sheet with a more customized name that for example would include a current Sheet Revision Number, then I can use another tool that I have developed for this workflow: Here’s code that I used to create this node:
Rename Files is a node that will take a Directory Path input. It will then look for all files contained in that directory and rename only those files that in their full name have an “identifier”. An identifier is a string that is unique to that particular file name. In case of our sheets its usually a Sheet Number value. Since, Revit by default puts a Sheet Number into file name, then we can use that as an identifier to isolate and rename only sheets that contain our identifier.
I can obtain an identifier by extracting a Sheet Number value from each view that I extracted from a View Set:
This brings us to another custom node added to archi-lab package: Get Built In Parameter. This is particularly useful when you are extracting Sheet Name and Number parameters, because since there exists multiple parameters in Revit API with the same name, the standard GetParameterByName node fails miserably to obtain the right one and often returns empty or null values. With this node you can get the BuiltIn SHEET_NUMBER or SHEET_NAME parameters and since its an unique name, then you can rest assured that you are getting the right value. Also, ParameterNames input can either be a list or a single string and will either return a list or a nested list.
Back to our Rename File node. Here we are getting a Sheet Number and since that’s a unique part of each file’s name we can use that to identify only files that we want to rename. Next input is a NewNames input. This has to be a matching length list of strings that we want to rename our files to with a proper *.pdf suffix (I usually have known file extensions turned on in my windows settings so I am required to add this to my file name).
Ha! This is pretty sweet method to construct a new file name from random strings, and combination of sheet specific parameters. Now, this is pretty much the reason why I did this whole printing exercise in Dynamo, because I knew that I can create custom/sheet specific file names. Awesome!
String From List is a new archi-lab node that just joins all list items into a single string with a separator and then adds a suffix at the end (.pdf).
Once this is complete, we set the Boolean toggle to True for the Rename Files node, and watch our files get renamed. Pretty awesome stuff if you ask me.
10.01.2015 Update 1:
I did make some changes to my package recently. One main change was replacing all Enum based nodes with Dynamo UI nodes and proper drop-downs. Now, I did make a small mistake with those that resulted with some broken functionality. It has just been fixed. Apologies to all users that were posting comments below. Please download latest archi-lab_Grimshaw package. Thank you.