{"record":{"id":"c5d031ee860e1889","repo":"3b1b/manim","slug":"at-least-2-mobjects-needed-for-intersection","errorCode":null,"errorMessage":"At least 2 mobjects needed for Intersection.","messagePattern":"At least 2 mobjects needed for Intersection\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"manimlib/mobject/boolean_ops.py","lineNumber":81,"sourceCode":"        _convert_skia_path_to_vmobject(outpen, self)\r\n\r\n\r\nclass Difference(VMobject):\r\n    def __init__(self, subject: VMobject, clip: VMobject, **kwargs):\r\n        super().__init__(**kwargs)\r\n        outpen = pathops.Path()\r\n        pathops.difference(\r\n            [_convert_vmobject_to_skia_path(subject)],\r\n            [_convert_vmobject_to_skia_path(clip)],\r\n            outpen.getPen(),\r\n        )\r\n        _convert_skia_path_to_vmobject(outpen, self)\r\n\r\n\r\nclass Intersection(VMobject):\r\n    def __init__(self, *vmobjects: VMobject, **kwargs):\r\n        if len(vmobjects) < 2:\r\n            raise ValueError(\"At least 2 mobjects needed for Intersection.\")\r\n        super().__init__(**kwargs)\r\n        outpen = pathops.Path()\r\n        pathops.intersection(\r\n            [_convert_vmobject_to_skia_path(vmobjects[0])],\r\n            [_convert_vmobject_to_skia_path(vmobjects[1])],\r\n            outpen.getPen(),\r\n        )\r\n        new_outpen = outpen\r\n        for _i in range(2, len(vmobjects)):\r\n            new_outpen = pathops.Path()\r\n            pathops.intersection(\r\n                [outpen],\r\n                [_convert_vmobject_to_skia_path(vmobjects[_i])],\r\n                new_outpen.getPen(),\r\n            )\r\n            outpen = new_outpen\r\n        _convert_skia_path_to_vmobject(outpen, self)\r\n\r","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/3b1b/manim/blob/dee01804d47b9f94402d71472674710dcac125b8/manimlib/mobject/boolean_ops.py#L63-L99","documentation":"ValueError raised in Intersection.__init__ (manimlib/mobject/boolean_ops.py:81). Intersection folds pairwise skia-pathops intersection over the operand list starting from vmobjects[0] and vmobjects[1], so at least two mobjects are structurally required; with fewer than two there is nothing to intersect.","triggerScenarios":"Intersection(one_mob), Intersection(), or Intersection(*groups) where the splat yields fewer than two mobjects (e.g. an empty VGroup spread).","commonSituations":"Calling Intersection(*vg) where vg was filtered or sliced to <2 elements; animations where one operand is conditionally removed; copy-paste from Union example with a single argument.","solutions":["Pass at least two VMobjects: Intersection(mob_a, mob_b, mob_c)","Pre-check the splatted collection length before calling","For a single shape use the shape itself; for zero shapes decide on an Empty/VGroup fallback"],"exampleFix":"# before\noverlap = Intersection(*regions)  # raises if len(regions) < 2\n\n# after\nassert len(regions) >= 2, \"Intersection needs >= 2 mobjects\"\noverlap = Intersection(*regions)","handlingStrategy":"validation","validationCode":"if len(regions) < 2:\n    raise ValueError(f\"Intersection needs >= 2 mobjects, got {len(regions)}\")\noverlap = Intersection(*regions)","typeGuard":"def is_intersection_ready(mobs: list) -> bool:\n    return len(mobs) >= 2","tryCatchPattern":null,"preventionTips":["Validate operand-list length before Intersection(*list)","Watch for filters/slices that shrink a VGroup list below two elements"],"tags":["manim","boolean-ops","validation"],"backgroundTag":null,"analyzedSha":"dee01804d47b9f94402d71472674710dcac125b8","analyzedAt":"2026-08-14T19:53:44.241Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}