Lately I've found myself jotting down and formatting notes in Grasshopper then exporting to a text file. (If this is strange to you, I understand completely.) So I've written a quick script making that workflow a bit easier. I know there are other codes out there, but I thought it might be interesting to share nonetheless.
There are some simple built-in safety protocols. It checks for an existing file path first then proceeds with the exporting process. If the specified file contains data the user is prompted with a warning, asking him/her to allow an overwrite or specify a new path.
It also works with CSV files. You will need GHPython.
You're welcome to download it here. Image of it in use below.
Best,
/SPM
EDIT 05/2016: The above file now includes the latest script with the additional functions (append, relative path, etc.).
筑梦NARUTO
Thanks for sharing
Aug 21, 2015
Matt Gaydon
Guessing you know when you write click on a panel you can click stream contents and set file path to stream to. Only down side is it will stream them in real time with the only way to stop the over ride is right click the panel and click the stream contents icon again to stop it.
P.s I like the idea of a boolean switch to stop and start writing. As means you can design things then break the stream and use the saved data for something else. Guess you can do it with Data Dam though that does not have a switch and must be done manually.
Aug 21, 2015
Stephen Maher
Matt,
My thoughts exactly. I was looking for a more user-friendly way to export text. The script allows me to stream data in real time or not. Fits better with my workflow.
/SPM
P.S. Just finished a bit of code that prompts the user to choose a file upon setting "write" to "True." This cut the code a few lines and removes the '"file" input, but may not be desirable if the user is constantly overwriting the same file.
Aug 21, 2015
Christian Schmidts
The component is a useful alternative to stream content option of the panel.
But I was even more excited component you have 'hidden' which shows you the plug ins used in a definition. That is really helpful if you hand out definitions to people!
Aug 23, 2015
Stephen Maher
Christian,
That code is an adapted version of Giulio and Brian's (see discussion here), which is why I credit them in the script.
The code pings the GH Document, so if you're passing along a definition to someone who doesn't have a particular plugin the file uses, it will not display in the [Panel]. But the user will still be prompted with the "Unrecognized Objects" warning.
/SPM
Aug 23, 2015
Stephen Maher
Now with an 'append' option. Should have thought of that before.
/SPM
Sep 4, 2015
Nick Devlin
Hi Stephen,
Is there a link to the updated version with the append function? I downloaded from the link in the original post but it includes the overwrite function instead? Many thanks - this looks like just what I need.
regards
Nick
May 27, 2016
Stephen Maher
Hey, Nick. Sure thing; I just updated the file in the post. I hope it helps!
/SPM
May 27, 2016
Nick Devlin
thanks Stephen.
May 27, 2016
Patrick Monte
This would be really useful to me because I am doing some operations that max out the panel character limit. I've tried writing to excel, but there again hit cell character limits, so I really need to be able to write a text file directly. I seem to be getting encoding errors though:
1. Solution exception:'ascii' codec can't encode character '\u2019' in position 54
Oct 22, 2016
Stephen Maher
Hey Patrick, mind posting your file so I can take a look? Or shoot me a DM with the file.
/SPM
Oct 23, 2016
tsaohy
Hi Stephen. Thanks for sharing this GH file. However, the gcode one doesn't work for me, I'm not sure why, there is no any .gcode file showing up. Thx for helping.
Apr 19, 2017
Stephen Maher
tsaohy – What .gcode are you referring to? This is a Python code that only requires the GHPython scripting component.
Are you trying to write a .gcode file with this script?
/SPM
Apr 19, 2017
Philippe HAMON
hi, in the original data set, the text has only got "CRLF" hidden character:
Jun 24, 2017
Stephen Maher
Philippe – I've never tried using this particular script with a CIX file. Do you mind posting the file so I can take a look?
Jun 25, 2017