Modular robots adapt to complex tasks through self-reconfiguration but often lack global geometric knowledge for efficient shape analysis. We propose a fully distributed message-passing algorithm for border tracing in lattice-based modular robots that requires no centralized memory. The algorithm has two phases: first, it identifies all internal and external borders and builds communication bridges via shortest-path spanning trees; second, it enables any module to traverse the robot’s boundaries using these bridges. Simulations on different configurations demonstrate that the algorithm is scalable, with linear time complexity, and supports efficient border traversal for distributed geometric reasoning.