Print to combined PDF based on specific string of text

I’m attempting to create a script that will print a view set within Revit to a single PDF, but the ordering of those sheets based on a string of text contained within the filename.

So far I’m having no issue in the creation of the PDFs, but the sorting is where I’m having issues.

Within my Revit file I have sheets that are like this:
S-1001
S-1002
S-5003
S-3004

What I would like to do is have the final PDF be combined based on the last three digits. Is this possible with Dynamo?

Hi @eseanq,

You can find the MergePdfs node in Genius Loci package version 2018.12.10 (and previous versions)

Is it possible to have them combined like the example? Where it would sort/combine them based on the last three digits?

You could try sorting the files based on the substring you’re after, and see if it works.

Happen to have an example of what that would look like? I came across this: http://dynamobim.org/forums/topic/sort-list-by-part-of-sublist-value/ but I’m having trouble trying to switch it from a list based on a Code block to a list based on Directory Contents that are *.pdf.

What I did to solve this problem is use a script that renames the files in order of their sheet number and with an extra number like 100, 101, 102 etc. I do this when they are plotted and in one folder so the computer puts them in the right order. Then I combine in Acrobat. It’s an extra step but works perfectly fine.

@erfajo, Within my Revit project file I do have a schedule that sorts the drawings based on a parameter within the file.

In response to your other post, Id prefer to be able to do it all from inside Revit/Dynamo. The sorting, printing, combining, everything.

@d.jansenMM3LJ, is that script sorting them based on the starting number or trailing numbers? In my example in the first post, the “true” sheet number is the last three digits. The starting digit indicates what type of drawing it is (Plans, Elevations, Sections, etc.). If I combine in Adobe, just using their combine tool, bookmarks can be automatically created based on the original filename.If I throw in a few extra digits just for the sorting, those would also get tacked on to the bookmark name.

I don’t know exactly what you mean but this is the script.