Skip to content Skip to sidebar Skip to footer

Python Get Coordinates Of The Vector Path From .svg File

So for a school project Iam supposed to program a so called 'V-Plotter', my team built it and I managed to program all calculations and so on, basicly I can make it move to a certa

Solution 1:

SVGs are very simple formats, you could simply open it with a notepad and see the xml code for it. The xml tag is the type of curve you need to plot, and it can have some metadata inside it. You can directly use python to read this XML if you want.

But SVGs aren't as easy as you're assuming it to be - it isn't simply a bunch of vectors (not the classical vectors anyway)

In SVG, you basically define shapes - like Line, Arc, CubicBezier, etc. You'd need to implement each of these into your program, because something that shows an SVG image is expected to understand these already.


Now, as your question asked about the packages, I'm adding packages that are useful for SVG handling in python:

svg.path - https://pypi.python.org/pypi/svg.path - is a great library to create paths and also to get the XML info and convert into usable classes like Line, Arc etc. But I dont think they have support to read complete svg files.

pysvg - https://pypi.python.org/pypi/pysvg/0.2.2 - is another utilitiy i used a while back which can import an svg and make classes like PolyLinecircleellipse etc.

Post a Comment for "Python Get Coordinates Of The Vector Path From .svg File"