# Select the outermost contour of an imported SVG

I would like to programmatically import an SVG (see top left) and process the offset of the concave outline, that are the outermost edges of the imported SVG (see top right). Finally I want to have the result like the image at the bottom.

The only part I stuck with is how to select the outermost edge loop programmatically via a script. Manually it works by 2xALT+RMB. But how to make the script know, which is the initial edge?

Is there a way to either

• Iterate over the curve data and just remove all inner elements,
• select the first outermost edge and firing 2xALT+RMB,
• preprocess the SVG to remove the inner elements or
• fill the inner holes and simplify the mesh again?

I went for the solution to iterate over the imported object. For reference the import routine, to see how the SVG gets imported in detail. The data is avail in the objects data.spline collection then.

The correct function relies on that the remaining element has to be the first object in the collection (key not in 0). At least for exported SVGs from corel draw this is true, I guess for others, too.

code snippet I use for now:

# remove all inner elements
svg_splines_collection=obj.data.splines
splineset_to_remove = [value for key, value in svg_splines_collection.items() if key not in (0,)]
for spline in splineset_to_remove:
svg_splines_collection.remove(spline)


if someone comes up with a better solution I'd appreciate.