{"record":{"id":"00764dda13533c8a","repo":"3b1b/manim","slug":"object-anim-cannot-be-converted-to-an-animation","errorCode":null,"errorMessage":"Object {anim} cannot be converted to an animation","messagePattern":"Object (.+?) cannot be converted to an animation","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"manimlib/animation/animation.py","lineNumber":244,"sourceCode":"    def get_rate_func(self) -> Callable[[float], float]:\n        return self.rate_func\n\n    def set_name(self, name: str):\n        self.name = name\n        return self\n\n    def is_remover(self) -> bool:\n        return self.remover\n\n\ndef prepare_animation(anim: Animation | _AnimationBuilder):\n    if isinstance(anim, _AnimationBuilder):\n        return anim.build()\n\n    if isinstance(anim, Animation):\n        return anim\n\n    raise TypeError(f\"Object {anim} cannot be converted to an animation\")\n","sourceCodeStart":226,"sourceCodeEnd":245,"githubUrl":"https://github.com/3b1b/manim/blob/dee01804d47b9f94402d71472674710dcac125b8/manimlib/animation/animation.py#L226-L245","documentation":"prepare_animation normalizes arguments to scene.play(): it converts _AnimationBuilder objects (produced by mob.animate...) into real Animation instances and passes Animation instances through. Any other object raises TypeError with the object's repr, because the renderer has no way to animate it.","triggerScenarios":"self.play(circle) (a bare Mobject); self.play('fade') (a string); self.play(some_decorator_result); passing an _AnimationBuilder that was already built earlier (an Animation is fine, but e.g. a tuple of builders unpacked wrongly is not).","commonSituations":"Forgetting the animation class: play(FadeOut(mob)) not play(mob); expecting play() to implicitly add mobjects like play(ShowCreation) misremembered; passing the result of a helper that returns None.","solutions":["Wrap the mobject in an animation: self.play(FadeOut(circle)), self.play(Write(text))","Use the .animate builder: self.play(circle.animate.shift(RIGHT))","If you want to add without animating, call self.add(mobject) instead of self.play(mobject)"],"exampleFix":"# before\nself.play(circle)\n# after\nself.play(Create(circle))","handlingStrategy":"type-guard","validationCode":"from manimlib.animation.animation import Animation, prepare_animation\nanims = [prepare_animation(a) for a in my_list]  # raises TypeError early with full list context\nself.play(*anims)","typeGuard":"from manimlib.animation.animation import Animation\nfrom manimlib.animation.animation import _AnimationBuilder\ndef is_animatable(x) -> bool:\n    return isinstance(x, (Animation, _AnimationBuilder))","tryCatchPattern":null,"preventionTips":["Every element passed to play() must be an Animation, an _AnimationBuilder (from .animate), or an mobject.animate chain","To add without animating use self.add(mob), never self.play(mob)"],"tags":["animation","type-error","scene","type-guard"],"backgroundTag":null,"analyzedSha":"dee01804d47b9f94402d71472674710dcac125b8","analyzedAt":"2026-08-14T19:53:44.241Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}