algorithmic modeling for Rhino
Hi David et al,
I think the current Read File component is great, but it seems to be missing a friend. The current practice of streaming content by the Panel offer too little option. For example I would expect a WriteTxtFile tool, would take data like panels, and write it to a location (file path can be defined parametrically), write enable toggle, file exist check etc.
Because some of the time writing to a text file is preferred and that streaming content is not desired (which could accidentally overwrite my previous data). So a WriteTxtFile and StreamTxtFile could be two different component. So we could formally do the operation but not restricted to relying on the Panel.
Tags:
Ah, good idea about the Data Dam, thanks.
I have just written it in the pain points discussion. Theoretically its very simple stuff. The operating system provides the way to pick a folder and all it outputs are strings, but they are not file paths, but folder paths. Then its easy to make file paths using concatenate or text join. Having the "self" node that outputs the folder of the current GH document, I could easily save a file like output.txt next to the GH doc or even use a counter so every time it saves it increments like output01.txt, output02.txt, etc. without ever writing a file path or having to create a file in the first place.
Lets hope we get this at some point. If i knew any VB I'd just create it myself, but I'm more of a node based guy. Coming from vvvv, there is a lot of stuff that I am missing, but then vvvv has ridiculous amounts of nodes built in.
If you have specific requirements for such functionality it is fairly trivial to script it. Attached a basic Python example. You'll need the GHPython component to run it. Hope that helps..
Hey Anders,
Thanks for your answer and file. You actually gave me an idea. I could use a file primitive and just set one file path to the current .gh document. Then I use text split, cull index and text join to get the folder it is in. Then I can build the filename I want to use for saving using a Counter from Firefly (which appears to be partly broken) and some concatenating. It works well together with your file.
You need Firefly and GHpython for this.
It outputs files in the format filename_0001.txt, filename_0002.txt, etc. incrementing every time you save. You can set the number of digits for the numbers. Whats weird is that the Firefly counter is partly broken: Reset Counter doesn't work and the last input I is actually not optional at all :/
Hi Armin. I updated the script with a counter variable and set the directory to the current Grasshopper definition save folder (which you mentioned in the "Pain Points" thread). I think this might be closer to what you are looking for based on your description above. Happy file writing :)
Thanks this code was really useful!
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by