A community-maintained Python framework for creating mathematical animations.
Enable -n command on extract_scene.py to skip to a given animation in a scene
Grant Sanderson44f9954dbdc1
diff --git a/extract_scene.py b/extract_scene.pyindex 537884f76..455c7f256 100644--- a/extract_scene.py+++ b/extract_scene.py@@ -66,6 +66,7 @@ def get_configuration():for short_arg, long_arg in optional_args:parser.add_argument(short_arg, long_arg, action = "store_true")parser.add_argument("-o", "--output_name")+ parser.add_argument("-n", "--skip_to_animation_number")args = parser.parse_args()except argparse.ArgumentError as err:print(str(err))@@ -85,6 +86,7 @@ def get_configuration():"quiet" : args.quiet or args.write_all,"write_all" : args.write_all,"output_name" : args.output_name,+ "skip_to_animation_number" : args.skip_to_animation_number,}if args.low_quality or args.preview:config["camera_config"] = LOW_QUALITY_CAMERA_CONFIG@@ -96,12 +98,18 @@ def get_configuration():config["camera_config"] = PRODUCTION_QUALITY_CAMERA_CONFIGconfig["frame_duration"] = PRODUCTION_QUALITY_FRAME_DURATION+ stan = config["skip_to_animation_number"]+ if stan is not None:+ config["skip_to_animation_number"] = int(stan)+#By default, write to fileactions = ["write_to_movie", "preview", "show_last_frame"]if not any([config[key] for key in actions]):config["write_to_movie"] = True- config["skip_animations"] = config["show_last_frame"] and not config["write_to_movie"]-+ config["skip_animations"] = any([+ config["show_last_frame"] and not config["write_to_movie"],+ config["skip_to_animation_number"],+ ])return configdef handle_scene(scene, **config):@@ -203,7 +211,8 @@ def main():"write_to_movie","save_frames","output_directory",- "save_pngs"+ "save_pngs",+ "skip_to_animation_number",]])diff --git a/scene/scene.py b/scene/scene.pyindex eec090ead..84ea28c12 100644--- a/scene/scene.py+++ b/scene/scene.py@@ -36,6 +36,7 @@ class Scene(object):"name" : None,"always_continually_update" : False,"random_seed" : 0,+ "skip_to_animation_number" : None,}def __init__(self, **kwargs):digest_config(self, kwargs)@@ -59,6 +60,7 @@ class Scene(object):self.construct(*self.construct_args)if self.write_to_movie:self.close_movie_pipe()+ print("Played a total of %d animations"%self.num_plays)def setup(self):"""@@ -389,9 +391,13 @@ class Scene(object):if len(args) == 0:warnings.warn("Called Scene.play with no animations")return+ if self.skip_to_animation_number:+ if self.num_plays + 1 == self.skip_to_animation_number:+ self.skip_animations = Falseif self.skip_animations:kwargs["run_time"] = 0+animations = self.compile_play_args_to_animation_list(*args)self.num_plays += 1