Interaction between dipolar forces, such as permanent magnets, generally leads to the formation of one-dimensional chains and rings. We investigated whether it was possible to let dipoles self-assemble into three-dimensional structures by encapsulating them in a shell with a specific shape. We found that the condition for self-assembly of a three-dimensional crystal is satisfied when the energies of dipoles in the parallel and antiparallel states are equal. Our experiments show that the most regular structures are formed using cylinders and cuboids and not by spheroids. This simple design rule will help the self-assembly community to realize three-dimensional crystals from objects in the micrometer range, which opens up the way toward previously unknown metamaterials.