This study aims to optimize the length partitioning of modular MEP systems in building construction using a genetic algorithm, addressing challenges such as avoiding fittings (e.g., tees and crosses) and achieving standardized module lengths. To this end, this paper proposes an optimization method utilizing the customization of Revit 2021. The method comprehensively considers factors such as the location of pipe fittings, module length, production, transportation, and installation, achieving a more systematic partitioning of modules. The results show that the optimized partitioning scheme effectively avoids critical pipe fittings, and the optimized module lengths are comparable to those created manually. However, the optimized scheme includes more standardized segments, which is conducive to factory-standardized production. Additionally, cost analysis reveals that production and transportation costs account for a significant proportion of total costs, while lifting costs are relatively low. Furthermore, the presence of modules with non-standard lengths introduces corresponding penalty costs. This paper discusses the advantages and limitations of the proposed method and suggests future directions for further optimizing the algorithm and improving module partitioning. The novelty of this research lies in the integration of a genetic algorithm with BIM software to optimize MEP module partitioning, offering a more efficient and systematic approach to the modular construction process.