Help with renaming multiple pdf files - First Dynamo graph

#1

Hi… I’m an absolute beginner in Dynamo so not exactly sure of the ways that it is going to help me but I can see the potential is there to be unlocked if I can pick up some skills.

I am a Revit technician (Structural) and have a need to improve Revit’s limited pdf creation tools and following various online research and painstaking baby steps I have written my first Dynamo Graph which does do what I need but in quite a basic way, but I would appreciate some simple guidance on how I can get over a hurdle as follows…

I sometimes work on projects that have strict naming conventions for issued pdf files, which are a bit of a pain to change manually so have written a graph to do it for me. At the moment I have got it set to rename five files as that’s how many I am using in my test set up, but obviously each project may have a different number of sheets therefore I am wondering what my options are for building into my graph some way of Dynamo working out how many files it needs to rename ?

I’m guessing this is obvious to experienced users but with my basically non-existent Dynamo/Programming experience, I have no idea what to look for beyond this point in my graph. I understand that this problem may have been solved/discussed many times in the past but if I just copy what someone else has created I won’t learn a thing so I wanted to try to solve the problem as much as I could.

Does anyone have any suggestions ?

Thanks

This is a screenshot of my graph (assuming I have uploaded correctly)…

0 Likes

#2

Hi DeanB72

Could you get the information you need for the new name from parameters within the project? i.e Sheet Number, sheet name, current revision.

If so then I recommend reading Konrad’s blog (link below)

This helped me a lot as I have learnt how to write a graph which allows you to print multiple sheets (different sheet sizes as well) and rename them within the one graph.

0 Likes

#3

@DeanB72
You can also look at this as an alternative

It has built-in renaming, auto sheet detection and auto-save to a given location.

thanks.

0 Likes

#4

Hi… Thanks for the replies. I have read Konrad’s articles and used them to get this far. My main problem now is figuring out how to get dynamo to rename all of the pdfs I create in a folder (however many that may be) without me needing to have a section of the graph for each one. ie… Is there a specific node I should be looking into that effectively specifies that a command is applicable to “all” the files that match a set criteria?
Apologies if it’s in the articles mentioned but I haven’t seen it and when coding is shown, it goes completely over my head.

Thanks

0 Likes

#6

@Konrad_K_Sobon’s node is set up to take a list of identifiers and rename any files which contain the matching identifier, no need to have multiple instances of this node as a result unless you want to run it on multiple directories. Just build coordinated lists of matching length and go to town. Try this:

Note that I had previously modified the Rename Files node to remove the loading of Revit specific libraries, transaction handling and document stuff which weren’t used and throw an error if you’re running it in studio.

0 Likes

#7

Thanks for that Jacob… I’ll look over this in detail as soon as I get chance.

0 Likes

#8

Hi Jacob… I got error messages as follows when I tried it. From looking online I found a post that suggested each \ should be replaced with \ but it still didn’t work.

0 Likes

#9

This is one situation where it is better to use a String node than just a code block with “”.
String nodes have no problem with \ and other characters

0 Likes

#10

Thanks Joseph… That worked for the code block problem but now I get Traceback/WindowsErrors which I believe has got something to do with the Rename Files Node.

0 Likes

#11

It looks like you’re feeding a “path”+“Name” when all revit wants is the “Name” for the New Names input. The string replace needs the empty string input to remove the path.

0 Likes

#12

I believe I have done that ??

0 Likes

#13

Wire a watch node onto the “String.Replace” to see the results. It should just be “Current File Name.PDF” or something is amiss prior to the renaming.

0 Likes

#14

I already have got a watch node I think, unless I’m misunderstanding even more than I thought ? It seems to come out the same as it went in.

0 Likes

#15

The String.Replace node not the String.Insert node. I believe you need to set the lower string node which currently has “”; with “” and remove the quotes form the start and end of the upper string node. Quotes in a code block is telling dynamo that this bit of content in the code block is a string. If you call a string node there is no need for the quotes.

0 Likes

#16

I think that’s solved it Jacob…

but also involved changing the Rename Files node…

I will test it further and tidy it all up but that’s given me a great start in Dynamo.

Thanks everyone’s peristence.

2 Likes

#17

@DeanB72

I know you have your solution already, well done.

In addition if you just need to rename. You can also use the old fashion “RENAME” graph below will create a CMD in your desired folder and you can run it separately outside by double clicking the Rename.cmd

do not worry about the “null” on the write to CSV node it will create the cmd.

here is the graph if you want to use it.

rename_files.dyn (10.3 KB)

thanks…

0 Likes

#18

Thanks for this. I haven’t had chance to look into it yet but are you saying a file can be created using dynamo but that can then be run independently/separate to dynamo?

0 Likes

#19

Yes it will create a file located on your specified location. Just try it…it will create a file called rename.cmd that you can run separately outside revit and dynamo. Its just a batch file a very old trick but really works and simple.

0 Likes

#20

I’ll give that a try as soon as I get chance. Do you know if there is list of other “. cmd” files readily available or easily creatable. I’m not sure what I would want them to do but the concept intrigues me as I had no idea things like that were possible without having advanced coding skills (which I obviously haven’t).
Thanks for the tip off

0 Likes

#21

I am not sure what else…depending on your requirement. Dynamo is not built for this purpose but its good it can do this trick on writing ‘cmd’. Try it first and see if it will do the trick as an alternative to the above solution.

0 Likes