GH to SVG – your graphics directly from grasshopper
We all know the value of data in computational design field. We often need to inform our models with several fluxes of information and just as often show those information using dataviz or infoviz graphics. Co-de-iT decides to maximize the workflow speed in Grasshopper and code some components in order to export real-time graphics in SVG format.
SVG is fully compatible with your favorite vector graphics software (Inkscape or Illustrator) and… your browser! Just drag and drop the .svg file in a new Chrome browser tab.
– line SVG
– polyline SVG
– polygon SVG
– circle SVG
– curve SVG
– text SVG
– composer SVG
– First of all you have to define the background size and color in the composer SVG component.
– Use all the clusters you need to convert your grasshopper geometries and text to svg syntax.
– use a merge component to collect all the data you want to export. Remember! the first data in the merge component will be on the bottom and the last one will be in front (as the photoshop layers) so if you want to chance the appearence position on the background of a set of geometries you can chance the position in the merge component.
– connect the merge component output data to the composer (all the data must be flattened).
– save your .svg file with the dedicated button in the definition.
– drag and drop your SVG file into a new Chrome Tab and press F5 to refresh the file after any change you do in GH*.
*there are some Chrome extensions that refresh the page after any change of source code but we haven’t tested it until now.
– or if you prefer open your SVG fle in your preferred graphic software as Inkscape or Illustrator.
This is a raw sketch of an SVG exporter; maybe it will be updated in the future, but as Co-de-iT we ARE NOT interested into developing a Grasshopper plugin (we really don’t have time to spend on the manteinance and future upgrades to grasshopper new versions) so feel free to use it, to customize it to your needs (if you want to report us your improvements and share your work with the GH community you are more than welcome) and if someone of you want to use it as base to develop a SVG plugin … feel free to do it (if you want to give us credits for the initial idea it would be great too).
Some reference links just in case you want to understand more about SVG syntax and code:
http://www.w3schools.com/svg/svg_examples.asp
http://www.w3schools.com/svg/svg_reference.asp
Is there a way to put a complete excel file in to grasshopper to get all the data for this definition ? Because things which actually make this graph are a bunch of entries to be mixed with a couple of numbers. But in an excel file i can use the actual database to graph. (like Raw ; http://app.raw.densitydesign.org/ )
At the end of the day i wanna use grasshopper to achieve what raw does. Any recommendations?
Hi Mustafa,
sure there are multiple ways of linking data from an Excel file into Grasshopper (and then usgin such data to produce an .svg). Options I know of are through some plugins such as gHowl, lunchBox and BumbleBee by David Mans.
Hope this helps!
Best,
Alessio
Hello Co-de-iT,
This is a great cluster! I kinda get the logic, but I am confused about and don’t know how to export this as a SVG file. Can you explain it little bit more? Thank you!
Best,
Ben
Great cluster.I am new in grasshopper,could you please send the definition of GH TO SVG file ,thanks! whoisdavidzangel@gmail.com
Hi David, you can download the definition at the link provided at the end of the article.
Cheers,
Alessio
Hello Alessio
How to ‘Stream content’ it is not clear how to save
Panel to stream the data > customize your destination folder
this is not working
i put a panel > stream content but it doesn’t save a .svg file //
when you stream the panel content, you can save a .txt file and then change its extension to .svg in the Windows Explorer.
[…] you can dowload the file at: https://www.co-de-it.com/wordpress/gh-to-svg.html […]
Fantastic work on this component! I’m having trouble with the download link, is there another direct link?
Hi so my computer is running OSX with Windows via VMWare. My settings allows me to share both operating systems files into one hard rive. In the past I have been able to successfully stream Excel data from my Mac side to Rhino+GH in my Windows by saving the file in a shared folder.
So currently I have “streamed contents” of the panel to my desktop as a txt file because “.svg” is not listed as an option. So first I set the destination folder to my desktop as a text file, and then stream the contents. I then change the file name to an .svg file which I then open with Illustrator on my Mac side. However when I make changes in Grasshopper I am unable to refresh Illustrator. I have tried to drop the svg file into a Chrome window on my Mac and Windows side. I hit refresh…nothing. The only way to update any changes is to reset the stream destination as a new file, renaming it to svg, then opening another Illustrator file. Am I doing something wrong?
Hi Gilberto,
in GH the option to save as .svg is not there, so when you stream the file from your panel component in GH you have to manually type in also the “.svg” extension along with the file name. For example, when you choose stream content type in “myFile.svg” and keep the file type to “all files”.
If you stream as a “.txt” from GH, every time you change something in GH, it will save a “.txt” file, not the one you renamed manually as “.svg”. This should solve the sync problems you have encountered.
Best,
Alessio