kilacoda / chanim

Animation engine for explanatory chemistry videos

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Issue with Arrows

Popular-Matter opened this issue · comments

When I try to use ChemArrow class, I'm noticing that the arrow isn't showing up once the video is successfully created. I was wondering if this is a known issue with this class.

I've also been playing around with the chem_objects.py and constants.py file to see if I can fix this. On MiXTeX I'm able to see the arrow just fine, but when creating the video again, the arrow is just messing with things.

I was wondering if you have further insight on this. Thanks!

Edit: So I realized what the issue may be. Whenever I try to use the Write function within self.play, apparently the arrow (and everything after it) cannot be written. Hope this makes sense. If you need clarification do let me know.

Curious to know why it's having that issue.

I was having such problems with Reaction as well earlier but it somehow automatically worked after a few days. I have no idea whatsoever why.

My guess is that it could be a rendering issue of some sort. I was digging deeper into other issues that could appear with using chemfig through manim and found this: malhotra5/Manim-Tutorial#10

I'm assuming that you hadn't modified the code in any way and that's why you're unsure as to why it suddenly works now haha.

Haha. Though that should be fixed because everything in chanim is with stroke_width=2. That's why this thing works in the first place.

Gotcha.

Well I'll still keep this issue open. I'll give you the code that I made and a video showing the issues:

from manimlib.imports import *
from chanimlib.imports import *

class ReactionScheme(Scene):
    def construct(self):
        molecule1 = ['O*3(---)']
        molecule2 = ['O*4(----)']
        reaction1 = Reaction(molecule1, molecule2, 'forward', 1, 0, 'white', 'heat', 'neat')
        reaction1.set_stroke(WHITE, 1)
        self.play(reaction1.shift, LEFT*1)
        self.play(Write(reaction1))

Link to video: https://vimeo.com/413870747

Let me know if you spot anything that's off. I'm also reusing the default chem_objects.py and constants.py (your version).

Also I'm curious to know if this issue happens if you were to reinstall manim/chanim.

Thanks!

I guess I can rule out the possibility of this being an issue specific to my system then. And for some reason, this problem's occurring again for me.

@kilacoda I was facing an issue with ChemArrow, like

CArrow(text_up="Upper text",length=2)

give me,

AttributeError: ChemArrow object has no attribute 'template_tex_file_body'

I was guessing the problem was there wasn't defined what template_tex_file_body is inside the ChemArrow class,

class ChemArrow(MathTex):
    ...
        self.template_tex_file_body = self.template_tex_file_body.replace(
            "\\setchemfig{atom sep=2em}", f"{set_chemfig}"
        )

        arrow = "\\arrow{%s[%s][%s]}" % (self.arrows[_type], text_up, text_down)
        MathTex.__init__(self, arrow, stroke_width=stroke_width, **kwargs)

Ah yeah, guess I missed that when I was moving to the TexTemplates. Will push a fix soon.