In the traditional architecture industry, architects often need to convert CAD drawings into BIM in order to express the final effect of the building more concretely and to understand whether the design of each profession is reasonable after the drawings are completed. The whole modeling process is boring and tedious, and due to human fatigue, the final result is prone to problems, which eventually leads to failure to meet expectations. In order to free architects from the tedious task of model transformation, companies have designed software for automatic model transformation using computers. The core of the software design is related to computational geometry. Line segment clustering is one of the elements of computational geometry and a frequent problem in programming. Appropriate clustering of line segments can often bring convenience to the problem. This paper combines the basic idea of the DBSCAN algorithm, improves the shortcomings of DBSCAN algorithm in dealing with line segment clustering, and proposes a density-based line clustering algorithm with shapely library as a tool. The algorithm is highly interpretable, and the method performs well and efficiently in the test of actual drawings, whether to group the line segments or to find the target line segments that meet the conditions, which provides convenience for the subsequent calculation.