Programmatic/Scripted Access to Import_SVG Plugin

Is it possible to use the functionality of the Import SVG Plugin in a C# context? I’ve tried referencing the RHP and poked around a bit… I see almost all the classes are internal/protected/private.

Ideally I’d like to go straight from an SVG file to a collection of Geometry (or maybe RhinoObjects) without importing them into the active rhinodoc… any chance this is possible?

This should be possible in the Rhino 7 WIP.

// create a headless doc and import
using(var doc = RhinoDoc.New(null))
{
  doc.Import("my_path_to_svg.svg");
  // copy objects out of Document.Object table for use later
}
2 Likes

Hi @stevebaer,

Thanks for your example, it worked great for importing many file types. However, I noticed that when trying to importing .3dm files using your example, the UI prompts user for a import scale (as shown below). Is importing rhino files headlessly not supported yet?

I never thanked you for this bug report. I added it to our todo list at
https://mcneel.myjetbrains.com/youtrack/issue/RH-61998

This should work in Rhino 7 if you use the
RhinoDoc.CreateHeadless(null)
function to create your doc. The SVG importer will not prompt for input when the doc is “headless”