Aiming at evacuation path optimization in complex building fire environments, this study proposes a dynamic evacuation path optimization model that integrates digital twin and intelligent optimization algorithm. By constructing a digital twin of the building fire scene, the fire environment in the building is monitored and analyzed in real time. Combined with the improved particle swarm algorithm, the difficulty and distance of each evacuation section are dynamically calculated by obtaining the parameters of multiple influencing factors in the building. Using the updating ratio factor, the poorer paths are eliminated, and the accuracy of the planned paths is judged, and the optimal evacuation path is obtained by iterative updating. The results show that: the improved algorithm in this paper, with 16 iterations, obtains the shortest evacuation distance of 36.51 m. The algorithm solves the evacuation time after the fire spreads for 120, 240, and 360 s to be 25.67, 52.09, and 88.46 s, respectively. In the evacuation of medium-scale road networks, the optimal path of the improved particle swarm algorithm includes 15 nodes and 14 road sections, and the evacuation time is shorter than that of the comparison method. The method saves 18.2~24.4m of evacuation distance in the simulated 10-medium fire scenarios. The evacuation efficiency of this paper’s method in fire simulation is good, and it takes 326.2s to evacuate 2865 people. In conclusion, the method proposed in this paper can be used as a technical framework for intelligent emergency evacuation system.