3b1b / 3b1b/manim

AssertionError when attempting to use SVGMobject

未關閉
#1,668 2 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
bug
主要語言
Python
星號
93.9k
分支
7.7k
平均合併
2 天 13 小時
30 天內合併 PR
4

描述

### Describe the bug
Hi, I'm trying to insert a SVG file using the SVGMobject(), but I keep getting the same AssertionError.
I've tried to use different SVG files, but all of them have the same result.
I've put both regular imager(jpeg, png) and vector images(svg) in the same folder (".../my_manim_project/manim/images/")
I tried running ImageTest also which works fine for a regular jpeg, so the file path that I'm using should work fine.

**Code**:
main.py:
```sh
from manimlib import *

class VectorImageTest(Scene):
def construct(self):
self.play(FadeIn(SVGMobject("OverarmRight-Left.svg")))
#Also tried:
#self.play(DrawBorderThenFill(SVGMobject("OverarmRight-Left"), rate_func=linear))
self.wait()
# Vector image will be read by SVGMobject

class ImageTest(Scene):
def construct(self):
img = ImageMobject("Me.jpg")
self.wait()
self.play(FadeIn(img))
self.wait()
```
default_config.yml:
```sh
directories:
# Set this to true if you want the path to video files
# to match the directory structure of the path to the
# sourcecode generating that video
mirror_module_path: False
# Where should manim output video and image files?
output: ""
# If you want to use images, manim will look to these folders to find them
raster_images: "/Users/gjerm/PycharmProjects/my_manim_project/manim/images/"
vector_images: "/Users/gjerm/PycharmProjects/my_manim_project/manim/images/"
# If you want to use sounds, manim will look here to find it.
sounds: ""
# Manim often generates tex_files or other kinds of serialized data
# to keep from having to generate the same thing too many times. By
# default, these will be stored at tempfile.gettempdir(), e.g. this might
# return whatever is at to the TMPDIR environment variable. If you want to
# specify them elsewhere,
temporary_storage: ""
.
.
.

```
**Wrong display or Error traceback**:
```sh
PS C:\Users\gjerm\PycharmProjects\my_manim_project\manim> manimgl main.py Sample -f
ManimGL v1.2.0
[14:44:53] INFO Using the default configuration file, which you can modify in config.py:231
`c:\users\gjerm\pycharmprojects\my_manim_project\manim\manimlib\default_config.yml`
INFO If you want to create a local configuration file, you can create a file named `custom_config.yml`, or run `manimgl config.py:232
--config`
WARNING You may be using Windows platform and have not specified the path of `temporary_storage`, which may cause OSError. config.py:200
So it is recommended to specify the `temporary_storage` in the config file (.yml)
Traceback (most recent call last):
File "C:\Users\gjerm\OneDrive\Dokumenter\my_manim_project\Scripts\manimgl-script.py", line 33, in
sys.exit(load_entry_point('manimgl', 'console_scripts', 'manimgl')())
File "c:\users\gjerm\pycharmprojects\my_manim_project\manim\manimlib\__main__.py", line 25, in main
scene.run()
File "c:\users\gjerm\pycharmprojects\my_manim_project\manim\manimlib\scene\scene.py", line 76, in run
self.construct()
File "main.py", line 15, in construct
self.play(FadeIn(SVGMobject("manim-logo-sidebar.svg")))
File "c:\users\gjerm\pycharmprojects\my_manim_project\manim\manimlib\mobject\svg\svg_mobject.py", line 59, in __init__
super().__init__(**kwargs)
File "c:\users\gjerm\pycharmprojects\my_manim_project\manim\manimlib\mobject\types\vectorized_mobject.py", line 76, in __init__
super().__init__(**kwargs)
File "c:\users\gjerm\pycharmprojects\my_manim_project\manim\manimlib\mobject\mobject.py", line 75, in __init__
self.init_points()
File "c:\users\gjerm\pycharmprojects\my_manim_project\manim\manimlib\mobject\svg\svg_mobject.py", line 75, in init_points
mobjects = self.get_mobjects_from(svg)
File "c:\users\gjerm\pycharmprojects\my_manim_project\manim\manimlib\mobject\svg\svg_mobject.py", line 91, in get_mobjects_from
result += it.chain(*(
File "c:\users\gjerm\pycharmprojects\my_manim_project\manim\manimlib\mobject\svg\svg_mobject.py", line 92, in
self.get_mobjects_from(child)
File "c:\users\gjerm\pycharmprojects\my_manim_project\manim\manimlib\mobject\svg\svg_mobject.py", line 91, in get_mobjects_from
result += it.chain(*(
File "c:\users\gjerm\pycharmprojects\my_manim_project\manim\manimlib\mobject\svg\svg_mobject.py", line 92, in
self.get_mobjects_from(child)
File "c:\users\gjerm\pycharmprojects\my_manim_project\manim\manimlib\mobject\svg\svg_mobject.py", line 91, in get_mobjects_from
result += it.chain(*(
File "c:\users\gjerm\pycharmprojects\my_manim_project\manim\manimlib\mobject\svg\svg_mobject.py", line 92, in
self.get_mobjects_from(child)
File "c:\users\gjerm\pycharmprojects\my_manim_project\manim\manimlib\mobject\svg\svg_mobject.py", line 96, in get_mobjects_from
result.append(self.path_string_to_mobject(
File "c:\users\gjerm\pycharmprojects\my_manim_project\manim\manimlib\mobject\svg\svg_mobject.py", line 125, in path_string_to_mobject
return VMobjectFromSVGPathstring(
File "c:\users\gjerm\pycharmprojects\my_manim_project\manim\manimlib\mobject\svg\svg_mobject.py", line 332, in __init__
super().__init__(**kwargs)
File "c:\users\gjerm\pycharmprojects\my_manim_project\manim\manimlib\mobject\types\vectorized_mobject.py", line 76, in __init__
super().__init__(**kwargs)
File "c:\users\gjerm\pycharmprojects\my_manim_project\manim\manimlib\mobject\mobject.py", line 75, in __init__
self.init_points()
File "c:\users\gjerm\pycharmprojects\my_manim_project\manim\manimlib\mobject\svg\svg_mobject.py", line 348, in init_points
self.handle_commands()
File "c:\users\gjerm\pycharmprojects\my_manim_project\manim\manimlib\mobject\svg\svg_mobject.py", line 399, in handle_commands
func(*args)
File "c:\users\gjerm\pycharmprojects\my_manim_project\manim\manimlib\mobject\types\vectorized_mobject.py", line 315, in start_new_path
assert(self.get_num_points() % self.n_points_per_curve == 0)
AssertionError
```

### Additional context
I'm running my Code on Windows 10(21H1), using the Terminal in the Pycharm IDE(Version 2021.2.3 Community Edition).

貢獻指南

這個儲存庫沒有索引到貢獻指南

研究方向

此錯誤發生在 manimlib/mobject/svg/svg_mobject.py 的第399行,位於 start_new_path 中 assertion 失敗。先檢查 SVG 檔案的路徑資料,看看是否包含格式錯誤的指令。查看 VMobjectFromSVGPathstring 類別和 handle_commands 方法,以了解 SVG 路徑字串如何被解析。使用除錯器執行失敗的程式碼,查看是哪個指令觸發了 assertion,然後檢查 SVG 是否使用不受支援的路徑指令或點數是否為奇數。

由索引模型根據 Issue 內容生成。

評估

領域
computer-graphics
Issue 類型
缺陷
難度
4/5
預估耗時
3-5 天
活躍度
停滯
描述清晰度
描述清楚
新手友好度
30/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。