manim icon indicating copy to clipboard operation
manim copied to clipboard

Render SVG from Draw.io

Open alex-lairan opened this issue 6 years ago • 6 comments

Hi, I'm trying to display some SVG from Draw.io, but I got some strange results.

I want to use manim for development and programming videos :smile:

The code :

class Uml(SVGMobject):
  CONFIG = {
    "file_name": "/home/necros/Downloads/FormObjects-Models.svg",
    "unpack_groups": False
  }

class UmlRender(Scene):
  def construct(self):
    uml = Uml()
    uml.scale(5)

    self.play(DrawBorderThenFill(uml), run_time=5)
    self.wait(5)

Expected result : 2019-08-05-231334_433x377_scrot

Actual result :

2019-08-05-231318_916x851_scrot

Exemple file : https://filebin.net/vhs2w1zlwbqeadhv/FormObjects-Models__1_.svg?t=byk639bd

In hope you have any idea to help me.

Regards

alex-lairan avatar Aug 05 '19 21:08 alex-lairan

I try to download your file from https://srv-file2.gofile.io/download/ANL8aV/FormObjects-Models.svg but it said You are not authorized to download this file.

xy-23 avatar Aug 06 '19 03:08 xy-23

Oh, I change the provider : https://filebin.net/vhs2w1zlwbqeadhv/FormObjects-Models__1_.svg?t=byk639bd

alex-lairan avatar Aug 06 '19 06:08 alex-lairan

The best result I can get:

class Uml(SVGMobject):
  CONFIG = {
    "file_name": "/home/necros/Downloads/FormObjects-Models.svg",
    "fill_opacity":0,
    "stroke_color": WHITE,
    "stroke_width": 1,
  }

Test

I think there are multiple reasons caused this problem.

  1. Because manim uses a simple(handmade) svg parser. to translate svg into SVGMobject. Manim can't recognize the color and other settings of a svg.(It's not a bad thing)
  2. Because manim can't get those settings, so manim don't know where to stroke, where to fill.

I think this problem can't be solved very quickly, you can create those Graphics by using Mobject like Rectangle(), TextMobject(), Arrow(), line()

xy-23 avatar Aug 06 '19 11:08 xy-23

Did you find a solution? I am getting a similar issue. I am using the cicuitikz package to draw some circuits in Latex and then animate using manim. The SVG file created is correct and all components are shows correctly. But manim ommits some lines from the figure. I think its some issue with the parser.

shailvaidya avatar Sep 20 '20 05:09 shailvaidya

No sorry, I gave up this issue and tried to animate the block myself.

Each arrows are just a simple Arrow(block1, block2)

alex-lairan avatar Sep 21 '20 07:09 alex-lairan

The solution I found is to import into Adobe Illustrator, select all, and then go to Edit -> Compound Path -> Release

Sometimes Edit -> Compound Path -> Make also works

JacksonZ03 avatar Jul 19 '24 16:07 JacksonZ03