0

I'm trying to learn how to use manim. I've been looking at what I believe is the standard tutorial. I'm now taking some code from the documentation of manim (not the tutorial).

The code I'm running is this (taken from the first example, but with the import command added):

from manimlib.imports import *

class SquareToCircle(Scene):
    def construct(self):
        circle = Circle()
        square = Square()
        square.flip(RIGHT)
        square.rotate(-3 * TAU / 8)
        circle.set_fill(PINK, opacity=0.5)

        self.play(ShowCreation(square))
        self.play(Transform(square, circle))
        self.play(FadeOut(square))

and I'm running it from the command line

$ manim SquareToCircle.py

Media will be stored in ./media/. You can change this behavior by writing a different directory to media_dir.txt.

1: Banner

2: ComplexTransformationScene

3: CountInBinaryTo256

4: CountInDecimal

5: CountInTernary

6: CountingScene

7: DiscreteGraphScene

8: ExternallyAnimatedScene

9: FactorialBase

10: GraphScene

etc

25: SquareToCircle

etc

Choose number corresponding to desired scene/arguments.

(Use comma separated list for multiple entries)

Choice(s):

When I select 25, it runs and produces the output expected. But where are all of those other options coming from? Is there a way to avoid having them show up?

Joel
  • 22,598
  • 6
  • 69
  • 93

2 Answers2

0

I think the menu shows up because you do not specify which scene you want to render in the command line. You can make multiple scenes in a python file and the name of the scene is what you call your class. Try $ manim SquareToCircle.py SquareToCircle. The menu are scenes in some example file I think.

Stumpp
  • 279
  • 4
  • 7
  • 16
  • I agree they probably come from 'some example file', but why are they showing up here? For example, nowhere in my code do I have `Banner`, but it's the first option. What about the code I provided causes `manim` to look up some example file (and what is that file)? – Joel Jul 23 '19 at 01:12
  • All these scenes are spread throughout the manim source code, for example, Banner's is in *manimlib/for_3b1b_videos/common_scenes.py*, so you should look for the others. – TheoremOfBeethoven Jul 24 '19 at 18:02
0

To see only the scenes that are inside a file, do the following:

  1. Open the manimlib/extract_scene.py file
  2. Replace the is_child_scene method, this is the one you should have:
def is_child_scene(obj, module):
    if not inspect.isclass(obj):
        return False
    if not issubclass(obj, Scene):
        return False
    if obj == Scene:
        return False
    return True

With this:

def is_child_scene(obj, module):
    if not inspect.isclass(obj):
        return False
    if not issubclass(obj, Scene):
        return False
    if obj == Scene:
        return False
    # Add this conditional
    # |
    # v
    if not obj.__module__.startswith(module.__name__):
        return False
    return True
  1. Save the changes and try again.

More information about this issue here.

TheoremOfBeethoven
  • 1,864
  • 6
  • 15