Dynamo: Writing data to text files

There's been some recent discussion about how to write geometric data out to external data sources.  Here is the most basic on both ends:  xyz coordinates written to a .txt file.


Of course, you may want to do some fine tuning of this kind of thing.  Here is a version that cleans up the data, reducing significant digits and other formating.

You might also add some information about these points to each line of data.  Adding a couple nodes tells how far each point in from the origin, and labels what this data is:

Resulting in this .txt file.


There are surely a number of ways to do similar things.
A couple things to note here:
1. XYZ's are Containers, that is, they are a specific kind of chunk of computational stuff that is not automatically recognized as a series of numerical element or strings.  They need to be decomposed to something consumable by a text file if that is what you are writing to.  "To String" is the simplest way to do this, but there are other methods to create more fine tuned data.
2.  You need to format your data for your consuming file format.  Writing to a text file, you need to add commas, carriage returns, or other pertinent delimiters.  In the "Joing Strings" node, the "del" or delimeter that is being added is a carriage return, this basically says "return" after every line of x,y,z that comes across
3.  you can add all sorts of other data to this.  For String processessing, just enter "string" in the search bar and take a look at some of the tools that are available.

Don't forget to also take a look at a couple other examples in the Help>Samples>23 Data Import and Export, for tips on how to write to Excel.  There are also explanations in the pdf tutorial.

Thanks to the folks who participated in this discussion over on the Vasari Forum.

Comments