SVG Export via Code-Driven File IO - specify page size and scale

It is great to see the new Code-Driven File IO which came in with Rhino 8 by @stevebaer

I can successfully use it to export a headless document as a SVG file.
However unlike other formats I cannot see a FileSvgWriteOptions class to help me set the options for export.

I’d like to be able to specify the SVG page size and scale factor being used for the export.

Is there way I can specify these options programatically using RhinoCommon? @wim I think you might have experienced this before?

Hoping the Code-Driven File IO changes things since this.
Other requests for this

We should update the SVG export for consistency on this feature, but there is already a way to write SVGs with options in RhinoCommon. See the ViewCapture.CaptureToSVG function

https://developer.rhino3d.com/api/rhinocommon/rhino.display.viewcapture/capturetosvg

Thanks @stevebaer that would be great, does ViewCapture.CaptureToSVG work for a Headless document?

That’s a darn good question. I’m not sure; I would need to test.

A headless document has an empty collection of Views, so unfortunately that approach will not work for us.

SVG Export seems so close - the geometry is there and the export works - we only need to control page size and scale.

I tried scaling and offseting the headless document to suit the SVG export default settings but while i can get the scale roughly correct, I cannot figure out the offset its using - everything seems to get offset to the bottom right quadrant. (-12,-12)>(12,12) becomes (500,-2000)>(1700,-500). I suspect the scale factor is closers to 96dpi but the SVG file is always (0,0)>(2400,2400)

Really looking to just have control of output page size and then use Scale To Fit.

Would a peek at the export code enlighten us what settings its trying to use and why its offset?

tmpF646.3dm (2.0 MB)
tmpF646