question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add support for Inkscape SVGs

See original GitHub issue

Situation: I have a maths paper. I run pdf2svg or dvisvgm. I modify the svg with inkscape just minimally (for example I change the grouping of elements). I try to load it with SVGMobject. This fails.

Cause of the Problem: Manim does not expect g and defs tags to have an id. They have no id on dvisvgm output, but they do when saving the same svg from Inkscape.

Solution in svg_mobject.py replace get_all_childNodes_have_id with

    def get_all_childNodes_have_id(self, element):
        all_childNodes_have_id = []
        if not isinstance(element, minidom.Element):
            return
        if element.hasAttribute('id') and (
                not element.tagName == "g"
                and
                not element.tagName == "defs"
                ):
            return [element]
        for e in element.childNodes:
            all_childNodes_have_id.append(self.get_all_childNodes_have_id(e))
        return self.flatten([e for e in all_childNodes_have_id if e])

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
yoshiaskcommented, Jul 6, 2020

Looks good to me, I’ll get this change made in the svg_parser branch

0reactions
leotrscommented, Oct 8, 2020

Yes it needs a lot of work, but thanks for closing this one. cc @yoshiask

Read more comments on GitHub >

github_iconTop Results From Across the Web

Essential Step to Save SVGs Correctly in Inkscape! - YouTube
Ever get errors when you upload SVG files to Design Space or cutting software? It's probably because you forgot this SUPER important step....
Read more >
How To Create SVGs in Inkscape - YouTube
Learn how to create SVG files for free in Inkscape. We'll go over everything you need to make easy to use SVG files...
Read more >
About SVG - Inkscape
Inkscape prides itself on being a fully standard-compliant SVG editor. As of March 2015, it even supports rendering of SVG properties which are...
Read more >
How to Make an SVG File in Inkscape in Five Easy Steps!
Step 1. Install Inkscape on your Computer · Step 2. Open Your Image File in Inkscape · Step 3. Select and Trace Your...
Read more >
How to Make an SVG in Inkscape Easily | Design Bundles
Open Inkscape and click on New Document. On the left side panel click Create and Edit Text Objects then click anywhere on the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found