From b9ef9f6fc0128a1a4b38c456b2a5d5a712c73a72 Mon Sep 17 00:00:00 2001 From: Grant Sanderson Date: Sat, 10 Feb 2018 22:34:39 -0800 Subject: [PATCH] Enabled adding end animation number with -n flag --- extract_scene.py | 9 ++++++++- scene/scene.py | 5 +++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/extract_scene.py b/extract_scene.py index 825f0ea1..ea34fa06 100644 --- a/extract_scene.py +++ b/extract_scene.py @@ -89,6 +89,7 @@ def get_configuration(): "write_all" : args.write_all, "output_name" : args.output_name, "skip_to_animation_number" : args.skip_to_animation_number, + "end_after_animation_number" : None, } if args.low_quality: config["camera_config"] = LOW_QUALITY_CAMERA_CONFIG @@ -102,7 +103,12 @@ def get_configuration(): stan = config["skip_to_animation_number"] if stan is not None: - config["skip_to_animation_number"] = int(stan) + if "," in stan: + start, end = stan.split(",") + config["skip_to_animation_number"] = int(start) + config["end_after_animation_number"] = int(end) + else: + config["skip_to_animation_number"] = int(stan) config["skip_animations"] = any([ config["show_last_frame"] and not config["write_to_movie"], @@ -221,6 +227,7 @@ def main(): "output_directory", "save_pngs", "skip_to_animation_number", + "end_after_animation_number", ] ]) diff --git a/scene/scene.py b/scene/scene.py index 4c72897c..625145f4 100644 --- a/scene/scene.py +++ b/scene/scene.py @@ -40,6 +40,7 @@ class Scene(Container): "always_continually_update" : False, "random_seed" : 0, "skip_to_animation_number" : None, + "end_after_animation_number" : None, } def __init__(self, **kwargs): Container.__init__(self, **kwargs) # Perhaps allow passing in a non-empty *mobjects parameter? @@ -409,6 +410,10 @@ class Scene(Container): if self.skip_to_animation_number: if self.num_plays + 1 == self.skip_to_animation_number: self.skip_animations = False + if self.end_after_animation_number: + if self.num_plays >= self.end_after_animation_number: + self.skip_animations = True + return self #Don't even both with the rest... if self.skip_animations: kwargs["run_time"] = 0