{"record":{"id":"2f1a44641dcc3a28","repo":"3b1b/manim","slug":"animation-arguments-can-only-be-passed-by-calling","errorCode":null,"errorMessage":"Animation arguments can only be passed by calling ``animate`` or ``set_anim_args`` and can only be passed once","messagePattern":"Animation arguments can only be passed by calling ``animate`` or ``set_anim_args`` and can only be passed once","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"manimlib/mobject/mobject.py","lineNumber":2204,"sourceCode":"        ]\n        return sorted(set(methods+mobject_methods))\n\n    def set_anim_args(self, **kwargs):\n        '''\n        You can change the args of :class:`~manimlib.animation.transform.Transform`, such as\n\n        - ``run_time``\n        - ``time_span``\n        - ``rate_func``\n        - ``lag_ratio``\n        - ``path_arc``\n        - ``path_func``\n\n        and so on.\n        '''\n\n        if not self.can_pass_args:\n            raise ValueError(\n                \"Animation arguments can only be passed by calling ``animate`` \" + \\\n                \"or ``set_anim_args`` and can only be passed once\",\n            )\n\n        self.anim_args = kwargs\n        self.can_pass_args = False\n        return self\n\n    def build(self):\n        from manimlib.animation.transform import _MethodAnimation\n\n        if self.overridden_animation:\n            return self.overridden_animation\n\n        return _MethodAnimation(self.mobject, self.methods, **self.anim_args)\n\n\ndef override_animate(method):","sourceCodeStart":2186,"sourceCodeEnd":2222,"githubUrl":"https://github.com/3b1b/manim/blob/dee01804d47b9f94402d71472674710dcac125b8/manimlib/mobject/mobject.py#L2186-L2222","documentation":"ValueError from _AnimBuilder.set_anim_args (manimlib/mobject/mobject.py:2204). Animation keyword arguments (run_time, rate_func, time_span, lag_ratio, path_arc, path_func...) may be attached to an animate expression exactly once, via either the immediate mob.animate(...) call or a later .set_anim_args(...); the can_pass_args flag flips False after the first pass, and a second attempt raises this.","triggerScenarios":"mob.animate(run_time=2).shift(RIGHT).set_anim_args(run_time=3); calling .set_anim_args(...) twice in one chain; passing run_time both to animate(...) and again via set_anim_args in the same expression.","commonSituations":"Refactoring code that used to pass run_time at play() level into the animate builder, leaving a duplicate; copy-pasting chains that already contain set_anim_args and appending another; helper functions that add anim args to an externally-built builder.","solutions":["Pass animation args exactly once: either mob.animate(run_time=2).shift(RIGHT) or mob.animate.shift(RIGHT).set_anim_args(run_time=2), not both","Remove the second set_anim_args call from the chain","Move timing arguments to self.play(..., run_time=2) instead of the builder if the builder already carries args"],"exampleFix":"# before\nself.play(mob.animate(run_time=2).shift(RIGHT).set_anim_args(rate_func=smooth))  # ok\nself.play(mob.animate(run_time=2).shift(RIGHT).set_anim_args(run_time=3))  # raises\n\n# after\nself.play(mob.animate(run_time=3).shift(RIGHT).set_anim_args(rate_func=smooth))","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pass animation kwargs exactly once per animate expression — in animate(...) or set_anim_args(...), never both","Prefer moving timing args to self.play(...) to keep builders arg-free","When refactoring, grep for duplicate set_anim_args/run_time in the same chain"],"tags":["manim","animate-syntax","animation","validation"],"backgroundTag":null,"analyzedSha":"dee01804d47b9f94402d71472674710dcac125b8","analyzedAt":"2026-08-14T19:53:44.241Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}