3b1b / 3b1b/manim

Not able to generate mobject based on circuitikz

Đang mở
#1,577 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
bug
Ngôn ngữ chính
Python
Star
93.8k
Fork
7.7k
Chỉ số merge pull request
Chỉ số pull request đang chờ

Mô tả

### Describe the bug

I have tried to generate a very simple circuitikz circuit, but it seems that after processing the mobject fails an assertion.

**Code**:

Here is the code I am attempting to run:

```py
class TestResistor(Scene):
def construct(self):
res = Tex(r"\begin{circuitikz} \draw (0,0) to[R] (2,0); \end{circuitikz}")
self.play(Write(res), run_time=3)
```

I have added the packages to `tex_template.tex`:

```tex
\usepackage{tikz}
\usepackage{circuitikz}
```

I have also edited the `dvi_to_svg()` function in `manimlib/utils/tex_file_writing.py` to have access to the ghostscript path:

```py
def dvi_to_svg(dvi_file, regen_if_exists=False):
"""
Converts a dvi, which potentially has multiple slides, into a
directory full of enumerated pngs corresponding with these slides.
Returns a list of PIL Image objects for these images sorted as they
where in the dvi
"""
file_type = get_tex_config()["intermediate_filetype"]
result = dvi_file.replace("." + file_type, ".svg")
if not os.path.exists(result):
commands = [
"dvisvgm",
"\"{}\"".format(dvi_file),
"-n",
"-v",
"0",
"-o",
"\"{}\"".format(result),
"--libgs='/opt/homebrew/Cellar/ghostscript/9.54.0/lib/libgs.dylib'", # this line edited
">",
os.devnull
]
os.system(" ".join(commands))
return result
```

**Wrong display or Error traceback**:

Here is the traceback:

```
Traceback (most recent call last):
File "/opt/homebrew/anaconda3/bin/manimgl", line 8, in
sys.exit(main())
File "/opt/homebrew/anaconda3/lib/python3.8/site-packages/manimlib/__main__.py", line 17, in main
scene.run()
File "/opt/homebrew/anaconda3/lib/python3.8/site-packages/manimlib/scene/scene.py", line 75, in run
self.construct()
File "presentation.py", line 88, in construct
res = Tex(r"\begin{circuitikz} \draw (0,0) to[R] (2,0); \end{circuitikz}")
File "/opt/homebrew/anaconda3/lib/python3.8/site-packages/manimlib/mobject/svg/tex_mobject.py", line 167, in __init__
super().__init__(full_string, **kwargs)
File "/opt/homebrew/anaconda3/lib/python3.8/site-packages/manimlib/mobject/svg/tex_mobject.py", line 43, in __init__
svg_mob = SVGMobject(
File "/opt/homebrew/anaconda3/lib/python3.8/site-packages/manimlib/mobject/svg/svg_mobject.py", line 57, in __init__
super().__init__(**kwargs)
File "/opt/homebrew/anaconda3/lib/python3.8/site-packages/manimlib/mobject/types/vectorized_mobject.py", line 77, in __init__
super().__init__(**kwargs)
File "/opt/homebrew/anaconda3/lib/python3.8/site-packages/manimlib/mobject/mobject.py", line 76, in __init__
self.init_points()
File "/opt/homebrew/anaconda3/lib/python3.8/site-packages/manimlib/mobject/svg/svg_mobject.py", line 73, in init_points
mobjects = self.get_mobjects_from(svg)
File "/opt/homebrew/anaconda3/lib/python3.8/site-packages/manimlib/mobject/svg/svg_mobject.py", line 89, in get_mobjects_from
result += it.chain(*[
File "/opt/homebrew/anaconda3/lib/python3.8/site-packages/manimlib/mobject/svg/svg_mobject.py", line 90, in
self.get_mobjects_from(child)
File "/opt/homebrew/anaconda3/lib/python3.8/site-packages/manimlib/mobject/svg/svg_mobject.py", line 89, in get_mobjects_from
result += it.chain(*[
File "/opt/homebrew/anaconda3/lib/python3.8/site-packages/manimlib/mobject/svg/svg_mobject.py", line 90, in
self.get_mobjects_from(child)
File "/opt/homebrew/anaconda3/lib/python3.8/site-packages/manimlib/mobject/svg/svg_mobject.py", line 89, in get_mobjects_from
result += it.chain(*[
File "/opt/homebrew/anaconda3/lib/python3.8/site-packages/manimlib/mobject/svg/svg_mobject.py", line 90, in
self.get_mobjects_from(child)
File "/opt/homebrew/anaconda3/lib/python3.8/site-packages/manimlib/mobject/svg/svg_mobject.py", line 89, in get_mobjects_from
result += it.chain(*[
File "/opt/homebrew/anaconda3/lib/python3.8/site-packages/manimlib/mobject/svg/svg_mobject.py", line 90, in
self.get_mobjects_from(child)
File "/opt/homebrew/anaconda3/lib/python3.8/site-packages/manimlib/mobject/svg/svg_mobject.py", line 89, in get_mobjects_from
result += it.chain(*[
File "/opt/homebrew/anaconda3/lib/python3.8/site-packages/manimlib/mobject/svg/svg_mobject.py", line 90, in
self.get_mobjects_from(child)
File "/opt/homebrew/anaconda3/lib/python3.8/site-packages/manimlib/mobject/svg/svg_mobject.py", line 94, in get_mobjects_from
result.append(self.path_string_to_mobject(
File "/opt/homebrew/anaconda3/lib/python3.8/site-packages/manimlib/mobject/svg/svg_mobject.py", line 123, in path_string_to_mobject
return VMobjectFromSVGPathstring(
File "/opt/homebrew/anaconda3/lib/python3.8/site-packages/manimlib/mobject/svg/svg_mobject.py", line 325, in __init__
super().__init__(**kwargs)
File "/opt/homebrew/anaconda3/lib/python3.8/site-packages/manimlib/mobject/types/vectorized_mobject.py", line 77, in __init__
super().__init__(**kwargs)
File "/opt/homebrew/anaconda3/lib/python3.8/site-packages/manimlib/mobject/mobject.py", line 76, in __init__
self.init_points()
File "/opt/homebrew/anaconda3/lib/python3.8/site-packages/manimlib/mobject/svg/svg_mobject.py", line 342, in init_points
self.handle_command(command, new_points)
File "/opt/homebrew/anaconda3/lib/python3.8/site-packages/manimlib/mobject/svg/svg_mobject.py", line 369, in handle_command
func(*new_points[:n_points])
File "/opt/homebrew/anaconda3/lib/python3.8/site-packages/manimlib/mobject/types/vectorized_mobject.py", line 292, in start_new_path
assert(self.get_num_points() % self.n_points_per_curve == 0)
AssertionError
```

### Additional context

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.