First of all Happy Easter to all! After a week of sunshine which I think may have been our summer we are back to autumn in Mordor where blue skies are a long forgotten memory and leaving the house is optional… perfect time to do some coding!

There have been many instances where I need to get some Data out of Dynamo but need to create a new file, whether it be a .txt file or a .csv file or and .xslx file or…. You get the point. My C:\ drive is literally cluttered with these tiny little files in arbitary folders on my Desktop or my Documents.

space-debris.jpg
My C:\ drive

I say Nay to this plague of text files, I want a simple way to get Data from Dynamo and into Excel!!!

If you have ever used Grasshopper you will know (or maybe not) that you can right click on the Panel component and you can copy the Data to Clipboard! Such a simple thing, but in Dynamo this feature is not Built-In. The closest thing I found to it was this neat little Node made by Luke Johnson in the Bakery Package. But, it only takes strings and doesn’t (as far as I’m aware) support arrays.

As I’m learning Zero-Touch nodes and given some inspiration from the Bakery Node I thought I would give it a go in Visual Studio. Setting data to ClipBoard is super easy to implement in C#. In fact, so easy the code is pretty much one line…Well, there is more than that, but that is to handle the list structure coming from Dynamo and formatting to something Excel will understand when you paste (I am a lazy coder and didn’t want to spend long on it so I did liberate a little from the DynamoDS GitHub for this as they have some awesome code that converts Jagged Arrays to MD Arrays for the Excel Node). But still, actually setting the ClipBoard data is just so easy.

Here is an Demo of the CopyToClipboard node in use…

You can grab my sandbox .dll from here if you want to have a go (also has a counter node which I use to iterate lists by an amount of time). Information about how to import .dll file can be found in the Dynamo Primer and make sure you unblock before you import.

Very simple I know, but I think quite handy for quick Data extraction so thought I would share. I hope you find this useful! 🙂