algorithmic modeling for Rhino
This is not a Grasshopper geometry exporter, but a Grasshopper-based Rhino SVG exporter.
SVG files are infinitely scaleable vector art files for web browsers. They are just text files meant to be human readable.
Rhino lacks an SVG exporter it seems since there's no way to define stroke and fill beyond linewidths and print colors and layer colors, well, that's fine with me to re-purpose those things and turn Rhino into an Illustrator-like layer and sublayer aware SVG editor.
In fact, Rhino screws up Illustrator exports to only do layer order in the sequence the layers were created instead of the arranged order you have manually created in the Layers palette, so I grab that info and use it correctly and this then becomes a reliable Illustrator exporter for Rhino too that let's you define lineweights and stroke/fill colors.
A Python script pulls curves and text from the Rhino document and exports an SVG file to the C: drive and Illustrator can then open the file with layers intact, albeit a little eccentrically since everything is placed in an Illustrator Layer01 for some reason, and for my part I've considered everything to be a level two sublayer, so simple layer items come inside of their own redundant sublayer. That keeps geometry out of parent layers in Illustrator though.
Alter this line to change the export location:
text_file = open("C:\Output.svg", "w")
Command-R to refresh your browser page for a real preview of the output after pushing my Recompute button or using Grasshopper F5 Recompute. You can toggle preview by double clicking a toggle button too.
So stroke color is normal layer color, just as Rhino shows, whereas Print Color becomes fill color and Print Width (in millimeters) becomes stroke width.
It's 170 lines of code.
It requires the latest Human plug-in for the Grasshopper-created previews:
Python is here:
Preview could possibly be improved by physically displacing objects in Z, but the plot order alone seems to handle fill just fine but I think Grasshopper adds different types of objects to the canvas all at once or something so the strokes can fail to be hidden behind other objects.
Hi Nik, nice work !!
Here also an old attempt to do the same using standard GH components.
It works with line, polyline, polygon, circle, curve (not too well), texts an there is a final composer.
If it's useful to you feel free to use it since we don't have time to make a standard plugin of it and to mantain it updated.
Example of use of my script to access a nesting utility on the web:
Hello Nik I put an exporter for Rhino on the discourse
I could do as you, using print color and layer color and many other things...
Comments are welcome
Hello! Could you explain how to make this work and what do you mean by "Alter this line to change the export location: text_file = open("C:\Output.svg", "w")"?
I just managed this to GH.