Wish: SVG export

wow, this is so amazing! thanks so much for adding svg import/export, it’s an incredible tool for anybody working between rhino and web/digital publishing

are there plans to include any svg functionality in grasshopper?

with the web thing in mind, one thing that would be super useful would be the ability to output class and id tags on svg paths, maybe based on rhino object name or component inputs in grasshopper. that way geometry could be easily referenced and restyled using css & javascript

1 Like

Inkscape uses several formats at the same time:

Yes, the CF_ENHMETAFILE format looks to be what illustrator is using

That has size zero, though. No idea what it’s about. Anyhow, here is what AI CS6 is putting in the clipboard on copy:


The smallest common denominator between Inkscape and AI seems to be PDF.

I haven’t used InsideClipboard; I was using CLCL (another clipboard manager) and saw the CF_ENHMETAFILE was getting filled. Yes, all of these formats get written to the clipboard, but Illustrator apparently only uses one or maybe two when it pastes from the clipboard.

I got this to work with an experiment using CF_ENHMETAFILE; unfortunately that turns into a much bigger project than placing svg text in the clipboard.

Two things come to mind:

Would it be useful to assemble a matrix of what Illustrator, Affinity, Inkscape (and CorelDraw & Xara Designer too?) appear to write to and read from the clipboard? That may show what if anything they have in common.

From that, see if it’s worth making Rhino export SVG to clipboard. From what’s been said here, although it’s possible to make it copy SVG to clipboard, it may be sending it to Destination Unknown. I must admit I love the idea of being able to copy/paste stuff between Rhino and other apps; it would save time and cut down on the amount of clutter that currently fills project folders immensely. I’m not informed enough to know what strengths SVG has over PDF, metafile etc formats, if any. That’s why I’m reading this thread, I guess. Can any of the formats support/preserve layer structure/ name and colour information from Rhino?

It wouldn’t really be useful to create a matrix for my purposes. I’ve already tested and know what is supported by Illustrator and Affinity Designer. Thanks for the offer though.

So is SVG the best way to go in your view?

Unfortunately no… We would have to support both SVG and EMF to work between Affinity Designer AND Illustrator.

This isn’t a “deal breaker”; it just involves more typing.

OK, thanks Steve. This is all interesting reading. Until I read this thread I didn’t know that copying to clipboard actually triggers saving in several formats.

Going back to the earlier comments about checking for planarity and saving to XY plane etc, would it possible to have a pane in Rhino Options where these preferences could be set, so that simple one-click copy to clipboard could still be preserved?

You’re getting ahead of yourself; this feature doesn’t even exist yet :slight_smile: I would imagine that this would have some set of options that you could use to define how the 3D geometry is converted to 2D and that these options could either be set in the options dialog or in some sort of “SvgCopyOptions” type command.

I’ve just tried my first SVG export.

  1. The preview doesn’t seem to update.

  2. The output is not quite as I thought it would be:


    This picture is from Inkscape and is severely scaled (compressed) in the y-direction. Chrome and IE show the same.

  3. That simple test file doesn’t round-trip. When imported into Rhino, nothing comes in.

Me too with a rectangle and a circle. Preview in Rhino and import in AI CS6 worked flawlessly. Are you sure that you had the correct viewport selected when exporting?

Yes.
I tried again and now the preview in Rhino was correct but the output is still the same in Chrome and Inkscape.
In Inkscape the properties are shown like this:

If I manually scale to height = 20 cm, the curves look like this (I’ve moved the two curves away from each other in this one):

SVG attached (renamed as .txt to be able to upload here):
test-svg-out-2.svg.txt (1.4 KB)

3DM file would be more interesting, I’d say.

Here comes…
test-svg-out.3dm (50.0 KB)

Looks like the exporter is using your computer’s locale and using commas instead of periods as the decimal separator. I’ll try to get that fixed for the next WIP.

This issue has been logged at https://mcneel.myjetbrains.com/youtrack/issue/RH-38125

2 Likes

Related? :wink:
https://mcneel.myjetbrains.com/youtrack/issue/RH-35655

Hmm… not really. Regardless of what certain locales use for their decimal separator, files with text content typically have to use the period. Presentation and input of that text is different.

1 Like