Hey dynapeeps,
I’m trying to create a simple script to roll out and use in the office to export dwg files rather quickly from within a revit view. To do this I want to randomize a filename so that there is no need for any kind of input and everybody can use from within the dynamo player but I’m not sure how to create a random number or string generator (doesn’t really matter) that creates an output that is a valid filename to save within the file directory i.e., no dots or commas and symbols of the sort. Ideas and comments are greatly appreciated.
Also, thanks to the WombatDynamo people for the awesome package.
If the filename doesn’t matter then can you just use a randomly generated number? Maybe even a string of numbers if you’re worried about duplicates.
Edit: Zebra has a nice node for this - String.Randomize. It only generates one item but you could probably rework it to create multiple items if needed.
Or read the file names in the directory (Can we get the modified date too?) and append a value?
Hey Nick, the problem is that I don’t think the math number node generates whole numbers and it also does not give you a new one every time you run the script
You’re right. I forgot about this. Really annoying. Check out the Zebra node I mentioned. It produces different strings and could be very useful. Appending timestamps and even usernames could work too.
doing so right now I’ll let you know in a bit
Ahh… Giving it a list of characters needed returns a list of strings.
2 Likes
You could use a DateTime string at the end. This is quite common. Or perhaps use a UUID (although these can be quite long)…
https://docs.python.org/2/library/uuid.html
Scratch that. @Nick_Boyts answer looks good.
I see you took a turn down the danger zone…
Its a great start and the date time string stamp would also lower the odds of repetition, but it still doesn’t solve the issue of re-creating a new set every time I run the script. I’m gonna try the UUID route and see what happens. Thanks!
This way is much simpler. No need to make random entities just grabbing the name of the view is fine since its assumed that each name is unique. But thank you guys for the input. Would be fun to see this work for a current sheet
Instead of a current sheet why not a series of sheets based on a datashapes UI++ radio selection for every sheet in the set?
1 Like