the dialog box appears where you need to specify parameters such as size, view, scale, and so on.
How to make that without the dialog box? But with the following parameters:
Size: custom, 10x10 cm
Output Type: Vector output
Output Color: Print Color
View and Output Scale: Top, Extents
Hi Bobrovnich, I’m running into the same problem while trying to export SVG. Did you manage to solve this? I am trying to initiate the export from grasshopper. I have very limited knowledge of scripting.
i’ve been using your above code in Rhino 7 for a bunch of scripts and have a problem now using Rhino 8. In Rhino 7 it exported the svg file with a single <path> node for each curve object, eg exporting 2 curves resulted in:
<svg>
<path d="M...."/>
<path d="M...."/>
</svg>
Using Rhino 8 i now get this structure in the xml, again for 2 curves:
It seems that i get a a lot of extra path nodes, curves fall apart into pieces, polylines are broken into lines and everything seems to be grouped when opening the file in Illustrator. This is breaking a lot for me.
Two questions:
How to get the old behaviour of CaptureToSvg as it has been in Rhino 7 ?
I am modifying svgxml before saving it, eg. to add id attributes to each path node and other things. When i try to access the XmlDocument created by CaptureToSvg using any XPath language, it fails eg. try to access the <path> nodes like this:
print svgxml.SelectNodes("//path").Count
always returns 0. But the XPath syntax is correct. I would appreciate any help on this.
Below is the origin Rhino 7 file containing 4 curves. In Rhino 7 i get 4 <path> nodes in the svg file, they are ungrouped once imported into Illustrator. Doing the same capture in Rhino 8 i get 28 <path> nodes in the svg file nested under the new <g> node. This results into 28 curves in Illustrator. Grouped and nested under an extra layer…
I’ve zipped the files since svg did not upload: Example.zip (145.9 KB)
thank you for fixing above mentioned bug. It works in Rhino 8 SR2 now and i get the same amount of <path> nodes. The extra <g> nodes for layers and sublayers seems to be a new Rhino 8 feature which i can get rid of in the xml on my own to save the same output using Rhino 7 and 8.
I’ve found another issue which i don’t understand which applies to Rhino 7 and 8: The example curve below (a curve with degree 3) is captured as polyline using CaptureToSvg once opened in Illustrator. Is there a way to control this ?
One last question: When using CaptureToSvg with DrawSelectedObjectsOnly=True it seems the order of <path> nodes in the xml does not match the order of selected objects in Rhino. Does the exporter change the order ? If so, which order is used ?