A method and device for extracting and vectorizing floor plan information based on DXF format

Through the DXF format floor plan information extraction and vectorization method, the problem of low design and construction efficiency in building decoration and decoration is solved, and the function of automatic extraction and vectorization of floor plan information is realized, improving the accuracy and efficiency of design and construction.

CN114092952BActive Publication Date: 2025-06-06SOUTH CHINA NORMAL UNIV +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111396607.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-23
Publication Date
2025-06-06
Estimated Expiration
2041-11-23

AI Technical Summary

Technical Problem

The existing technology has problems such as long design cycles and construction cycles, low work efficiency, large construction deviations, high costs and extended construction periods in building decoration and decoration, and computer-aided design tools have high thresholds for use and are difficult to popularize.

Method used

A method of extracting and vectorization of floor plan information based on DXF format is provided. By obtaining floor plan files in DXF format, pre-processing and removing axis, text and ruler, extracting entity coordinate information across layers, obtaining wall and door and window outlines, and outputting vectorized floor plan.

Benefits of technology

It realizes automatic extraction of floor structure and size information and converts it into JSON file format. After rendering, the vectorized floor plan can be presented on the platform, simplifying user operations and improving design efficiency and construction accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114092952B_ABST
    Figure CN114092952B_ABST
Patent Text Reader

Abstract

The present invention relates to a method and device for extracting and vectorizing floor plan information based on DXF format. The method and device for extracting and vectorizing floor plan information based on DXF format described in the present invention include: obtaining a floor plan file in DXF format to be processed; preprocessing the floor plan file in DXF format; extracting coordinate information of entities across layers for the preprocessed floor plan file in DXF format; obtaining the wall outline and door and window outline in the floor plan file according to the coordinate information of the entities; and outputting the vectorized floor plan according to the wall outline and the door and window outline. The method and device for extracting and vectorizing floor plan information based on DXF format described in the present invention can automatically extract floor plan structure and size information from a floor plan in DXF format, transfer this information into a specific JSON file format, and present the vectorized floor plan on the platform after rendering for users to carry out personalized decoration.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of image recognition and image processing, and in particular to a method and device for extracting and vectorizing floor plan information based on a DXF format. Background Art

[0002] Traditional building decoration construction requires drawing design before specific construction, and construction must be carried out according to the design concept of the designer. The design cycle and construction cycle are long, the design workload is large, and the work efficiency is low, which makes the overall building decoration slow. In addition, large deviations often occur in actual construction, and secondary rework is necessary, which not only increases construction costs, but also delays the construction period, which is not conducive to the rational allocation of resources. Therefore, the application of computer-aided design of floor plans is of great significance to the field of building decoration.

[0003] Although designing floor plans with computer-aided tools can help construction teams, the current computer-aided tools have a high threshold for use and are not easy for ordinary users to get started. Therefore, the home improvement market urgently needs an automatic / semi-automatic home improvement design system that is easy to operate. Users input the floor plan in DXF format into the system, and the system can automatically extract the structure and size information of the floor plan from the floor plan, and then reconstruct the floor plan and present it to the user, so that the user can independently choose different decoration plans.

[0004] Since the DWG format is a special format for AutoCAD and has a certain degree of confidentiality, AutoCAD introduced the DXF file to facilitate file calls by external programs. DXF is an open vector data format that can be divided into two categories: ASCII format and binary format; ASCII has the characteristics of good readability, but occupies a large space; the binary format occupies a small space and has a fast reading speed. DXF files are constructed by "data pairs" consisting of many "codes" and "values". The code here is called a "group code", which is a non-negative integer of no more than three digits, equivalent to the code of the specified data type, used to specify the type and purpose of the value that follows. Each group code and value must be a separate line. DXF files are organized into multiple "segments", each of which starts with group code "0" and string "SECTION", followed by group code "2" and a string representing the segment name (such as HEADER). In the middle of a segment, group codes and values ​​can be used to define the elements in the segment. The end of a segment is defined using group code "0" and string "ENDSEC". The structure of each segment of a DXF file is basically the same, but there are differences in specific functions.

[0005] As can be seen from the above, the structure of DXF files is quite complex, and reading DXF files completely is also an extremely tedious project. In practical applications, in order to extract the entity information of the graphics, many items in the DXF file can be omitted. As long as the layer table, block segment and entity segment in the table segment are obtained, the description of the corresponding geometric figure can be completed.

[0006] The color and line type of each layer are described in the layer table, the layer, attributes and position of the block in the drawing are described in the block segment, and the geometric information such as the starting point and end point of the straight line and the center and radius of the circle and the layer of each entity are described in the entity segment. According to the layer where the entity is located, the color and line type of each layer are searched in the layer table and added to the entity object. Moreover, the DXF file format fully considers the design needs of the interface program, so it is easy to skip unnecessary information and conveniently extract the information of interest. This provides conditions for extracting the geometric data of the model from the DXF file and reprocessing the data. Summary of the invention

[0007] Based on this, the purpose of the present invention is to provide a method and device for extracting and vectorizing floor plan information based on the DXF format, automatically extracting floor plan structure and size information from floor plans in the DXF format, transferring this information into a specific JSON file format, and presenting the vectorized floor plan on the platform after rendering for users to carry out personalized decoration.

[0008] In a first aspect, the present invention provides a method for extracting and vectorizing floor plan information based on a DXF format, the method comprising the following steps:

[0009] Get the floor plan file in DXF format to be processed;

[0010] Preprocessing the floor plan file in the DXF format to remove the axes, texts and rulers in the file;

[0011] For the pre-processed DXF format floor plan file, extracting coordinate information of entities across layers;

[0012] According to the coordinate information of the entity, obtain the wall outline in the floor plan file;

[0013] Obtaining the outlines of doors and windows in the floor plan file according to the insertion point coordinates of the insert entity in the floor plan file in the DXF format and the wall coordinates;

[0014] A vectorized floor plan is output according to the wall outline and the door and window outline.

[0015] Furthermore, the cross-layer extraction of entity coordinate information includes:

[0016] Traversing the entity segments of the pre-processed DXF format floor plan file to obtain the entity; wherein the entity includes LINE entity, POLYLINE entity and LWPOLYLINE;

[0017] For each entity, extract the coordinates of all points of the entity and store them in an entity list;

[0018] Deduplicating the entity list, and allocating nodes according to the length of the deduplicated list;

[0019] Number each node, establish a mapping relationship between the node number and the coordinates, and add the node to the drawing board;

[0020] Get the node number through the coordinate value, and store the numbers of the two points of each edge in the nested list edges;

[0021] Use draw_networkx_edges() to connect the points on the graph.

[0022] Further, according to the coordinate information of the entity, the wall outline in the floor plan file is obtained, including:

[0023] The extracted coordinate information of the entity is stored in the NetworkX drawing board;

[0024] Use the findcycle() function provided by the NetworkX library to find the closed area;

[0025] Every time a closed area is obtained, delete the points and edges of the closed area in the drawing board;

[0026] Repeat the process of searching for a closed area and deleting the points and edges of the closed area until there is no closed area in the drawing board;

[0027] The wall contour is obtained according to all the closed areas.

[0028] Further, according to the insertion point coordinates of the insert entity in the floor plan file in the DXF format and the wall coordinates, the outlines of doors and windows in the floor plan file are obtained, including:

[0029] Traverse all insert entities in the floor plan file in the DXF format, obtain the coordinates of the insertion point of each insert entity, and put the coordinates of all the insertion points in the door and window list;

[0030] Traversing the door and window list and the entity list, for each coordinate of the insertion point, calculating the Euclidean distance between the coordinate of the insertion point and each point in the entity list;

[0031] All distances are sorted by size, and the four points with the smallest distances are connected to obtain the door and window outline corresponding to the insertion point.

[0032] Furthermore, four points with the smallest distance are connected, including:

[0033] A connection condition is set, wherein the connection condition is: between two points, one of the horizontal coordinate or the vertical coordinate is the same.

[0034] Furthermore, the floor plan file in the DXF format is preprocessed to remove the axes, texts and rulers in the file, including:

[0035] Traversing the floor plan file in the DXF format, deleting the lines whose line type is not the default line type BYLAYER, and obtaining the floor plan file with the axis removed;

[0036] Delete the TEXT entity and MTEXT entity to obtain the floor plan file without text;

[0037] Delete the DIMENSION entity to obtain the floor plan file without the ruler.

[0038] Furthermore, the method further comprises the following steps:

[0039] Use the method provided by ezdxf to traverse the DXFATTRIBS dictionary of LINE entities, POLYLINE entities and LWPOLYLINE entities in the floor plan file in the DXF format;

[0040] Adjust the values ​​of const_width, thickness, and lineweight to the preset uniform values.

[0041] In a second aspect, the present invention further provides a device for extracting and vectorizing floor plan information based on a DXF format, comprising:

[0042] A floor plan file acquisition module is used to acquire the floor plan file in DXF format to be processed;

[0043] A preprocessing module is used to preprocess the floor plan file in the DXF format to remove the axis, text and ruler in the file;

[0044] An entity coordinate information extraction module is used to extract entity coordinate information across layers for the pre-processed DXF format floor plan file;

[0045] A wall outline acquisition module, used to obtain the wall outline in the floor plan file according to the coordinate information of the entity;

[0046] A door and window outline acquisition module, used to obtain the door and window outlines in the floor plan file according to the insertion point coordinates of the insert entity in the floor plan file in the DXF format and the wall coordinates;

[0047] The floor plan output module is used to output the vectorized floor plan according to the wall outline and the door and window outline.

[0048] In a third aspect, the present invention provides a smart device, comprising:

[0049] at least one memory and at least one processor;

[0050] The memory is used to store one or more programs;

[0051] When the one or more programs are executed by the at least one processor, the at least one processor implements the steps of any one of the floor plan information extraction and vectorization methods based on the DXF format as described in the first aspect of the present invention.

[0052] In a fourth aspect, the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of any one of the floor plan information extraction and vectorization methods based on the DXF format as described in the first aspect of the present invention are implemented.

[0053] The present invention provides a method and device for extracting and vectorizing floor plan information based on DXF format, which automatically extracts floor plan structure and size information from floor plans in DXF format, transfers this information into a specific JSON file format, and presents the vectorized floor plan on the platform after rendering, so that users can carry out personalized decoration.

[0054] For better understanding and implementation, the present invention is described in detail below with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0055] Figure 1 A schematic diagram of a flow chart of a method for extracting and vectorizing floor plan information based on DXF format provided by the present invention;

[0056] Figure 2 A schematic diagram of the presentation effect of an original floor plan used in an embodiment in CAD software;

[0057] Figure 3 A schematic diagram of a wall outline extracted from a house type diagram in an embodiment;

[0058] Figure 4 A schematic diagram of wall outlines and door and window insertion points extracted from a floor plan in one embodiment;

[0059] Figure 5 A schematic diagram of a wall outline and a door and window outline extracted from a house type diagram in one embodiment;

[0060] Figure 6 A schematic diagram of the structure of a device for extracting and vectorizing floor plan information based on DXF format provided by the present invention;

[0061] Figure 7 A schematic diagram of the structure of an intelligent device provided by the present invention. DETAILED DESCRIPTION

[0062] In order to make the objectives, technical solutions and advantages of the present application more clear, the embodiments of the present application will be further described in detail below with reference to the accompanying drawings.

[0063] It should be clear that the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the embodiments of the present application.

[0064] The terms used in the embodiments of the present application are only for the purpose of describing specific embodiments, and are not intended to limit the embodiments of the present application. The singular forms of "a", "said" and "the" used in the embodiments of the present application and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more associated listed items.

[0065] When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. On the contrary, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the attached claims. In the description of the present application, it should be understood that the terms "first", "second", "third", etc. are only used to distinguish similar objects, and do not have to be used to describe a specific order or sequence, nor can they be understood as indicating or implying relative importance. For those of ordinary skill in the art, the specific meanings of the above terms in the present application can be understood according to the specific circumstances.

[0066] In addition, in the description of this application, unless otherwise specified, "plurality" means two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the associated objects are in an "or" relationship.

[0067] In a specific embodiment, the programming language used in the DXF format-based floor plan information extraction and vectorization method provided by the present invention is Python, the integrated development environment (IDE) is PyCharm, and the development environment (SDE) is python3.8.

[0068] The main python libraries involved are ezdxf and NetworkX:

[0069] ezdxf is a Python interface for the DXF (Drawing Exchange File) format developed by Autodesk. ezdxf allows developers to read and modify existing DXF drawings or create new DXF drawings. The main goal of ezdxf development is to hide the complex DXF details from programmers, but still support programmers to access most of the DXF file content by calling the library, but this also requires programmers to have a basic understanding of the DXF format and understand what tasks and goals can be accomplished using the DXF format.

[0070] NetworkX is a python package for creating, manipulating and studying the structure, dynamics and function of complex networks. NetworkX is a tool for studying the structure and dynamics of social, biological and infrastructure networks, a tool with a standard programming interface and graphical implementation suitable for a variety of applications and a rapid development environment for collaborative, multidisciplinary projects; using NetworkX, you can load and store networks in standard and non-standard data formats, generate various types of random and classical networks, analyze network structures, build network models, design new network algorithms, draw networks, etc.

[0071] In view of the problems in the background technology, in the first aspect, the present invention provides a method for extracting and vectorizing floor plan information based on DXF format, such as Figure 1 As shown, the method comprises the following steps:

[0072] S01: Obtain a floor plan file in DXF format to be processed.

[0073] DXF is an open vector data format, which can be divided into two categories: ASCII format and binary format; ASCII has the characteristics of good readability, but occupies a large space; binary format occupies less space and has a fast reading speed. DXF files are constructed by "data pairs" consisting of many "codes" and "values". The code here is called "group code", which is a non-negative integer of no more than three digits, equivalent to the code of the specified data type, used to specify the type and purpose of the value that follows. Each group code and value must be a separate line. DXF files are organized into multiple "segments", each of which starts with group code "0" and string "SECTION", followed by group code "2" and string representing the segment name (such as HEADER). In the middle of a segment, group codes and values ​​can be used to define the elements in the segment. The end of a segment is defined using group code "0" and string "ENDSEC". Each segment of a DXF file is basically the same in structure, but there are differences in specific functions.

[0074] S02: Preprocessing the floor plan file in the DXF format to remove axes, texts and rulers in the file.

[0075] like Figure 2 As shown, Figure 2 In an exemplary embodiment, a floor plan file in DXF format is viewed in CAD software, which includes original axes, text, rulers and other contents.

[0076] Through the observation of a large number of DXF files, it is found that the line type that constitutes the axis is generally not the default line type BYLAYER, and the line type that constitutes the required walls, doors and windows is generally BYLAYER, so the method in ezdxf can be called to delete the axis in the DXF file. Removing text and rulers is also to find the corresponding entity type and use the function in ezdxf to achieve. Among them, there are two types of text: TEXT and MTEXT. The ruler is not composed of LINE entities, but is saved as a DIMENSION entity.

[0077] In a preferred embodiment, step S02 includes:

[0078] S021: traverse the floor plan file in the DXF format, delete the lines whose line type is not the default line type BYLAYER, and obtain the floor plan file with the axis removed;

[0079] S022: Delete the TEXT entity and the MTEXT entity to obtain a floor plan file with text removed;

[0080] S023: Delete the DIMENSION entity to obtain the floor plan file without the ruler

[0081] S03: For the pre-processed DXF format floor plan file, extract the coordinate information of the entity across layers.

[0082] In CAD drawings, each component has its own layer. However, in actual applications, different designers have their own methods of naming layers. For example, some designers will name the layer that stores wall information as Wall, while others will name it as Wall. Therefore, this method uses a cross-layer extraction strategy when extracting information from DXF.

[0083] Many existing algorithms are based on the concept of layers to vectorize DXF floor plans. The present invention adopts the concept of cross-layers, and the difficulty of vectorization rises sharply, because the present invention mainly adopts the concept of cross-layers for wall recognition. According to research, the line segments of the wall are mainly composed of three entities: LINE, POLYLINE and LWPOLYLINE, and they will form a closed area. Therefore, ezdxf can be used to extract the coordinate information of the corresponding entity and store it in the format required by NetworkX, and the findcycle() function is called to find the coordinate information of each point that constitutes the closed area, that is, the coordinate information of each point on the wall. In a specific embodiment, the extraction process of the LINE entity includes:

[0084] S0311: Traverse the entity segments of the pre-processed DXF format floor plan file to obtain LINE entities. In another step, obtain POLYLINE entities and LWPOLYLINE.

[0085] S0312: For each entity, extract the coordinates of the starting point and the end point of the entity and store them in the entity list.

[0086] S0313: De-duplicate the entity list, and allocate nodes according to the length of the de-duplicate list.

[0087] S0314: Number each node, establish a mapping relationship between the node number and the coordinates, and add the node to the drawing board.

[0088] S0315: Get the node number through the coordinate value, and store the numbers of the two points of each edge in the nested list edges.

[0089] S0316: Use draw_networkx_edges() to connect points on a graph.

[0090] In another specific embodiment, the extraction process of LWPOLYLINE entity (similar to polyline) includes:

[0091] S0321: Traverse the entity segment of the DXF file and find the LWPOLYLINE entity;

[0092] S0322: Use the ezdxf library to extract the coordinates of all points that make up LWPOLYLINE and store them in a list;

[0093] S0323: Calculate the length of the list, assign nodes according to the length of the list, and add the points to the drawing board;

[0094] S0324: number each point and establish a mapping relationship between the node number and the coordinate;

[0095] S0325: Set a for loop to traverse the list of node numbers, combine the node numbers in pairs, decompose the LWPOLYLINE entity into edges, and store the node numbers that make up each edge in the nested list edges. (For example, if the node number list is (0, 1, 2, 3), then the combination of the two before and after means (0, 1)(1, 2)(2, 3)).

[0096] S0326: Use draw_networkx_edges() to connect points on a graph.

[0097] In another specific embodiment, the extraction process of the POLYLINE entity includes:

[0098] S0331: Traverse the entity segment of the DXF file and find the POLYLINE entity;

[0099] S0332: Use the ezdxf library to extract the coordinates of all points that make up the POLYLINE and store them in a list;

[0100] S0333: Calculate the length of the list, assign nodes according to the length of the list, and add the points to the drawing board;

[0101] S0334: number each point and establish a mapping relationship between the node number and the coordinate;

[0102] S0335: Set a for loop to traverse the list of node numbers, combine the node numbers in pairs, decompose the POLYLINE entity into edges, and store the node numbers that make up each edge in the nested list edges. (For example, if the node number list is (0, 1, 2, 3), then the combination of the two before and after means (0, 1)(1, 2)(2, 3)).

[0103] S0336: Use draw_networkx_edges() to connect points into lines on the drawing board.

[0104] S04: Obtaining the wall outline in the floor plan file according to the coordinate information of the entity.

[0105] The drawing methods of building components are specifically stipulated in the "Architectural Drawing Standards", among which walls have the following characteristics: any section of the wall is a closed area. Therefore, an algorithm can be used to find the closed area in the figure and regard it as a wall.

[0106] In a specific embodiment, obtaining the wall profile includes the following steps:

[0107] S041: storing the extracted coordinate information of the entity into the NetworkX drawing board.

[0108] S042: Use the findcycle() function provided by the NetworkX library to find the closed region.

[0109] S043: Whenever a closed area is obtained, the points and edges of the closed area are deleted from the drawing board.

[0110] S044: Repeatedly searching for closed areas and deleting points and edges of the closed areas until there are no closed areas in the drawing board.

[0111] S045: Obtain the wall outline according to all the closed areas.

[0112] After the extracted LINE, POLYLINE and LWPOLYLINE coordinate information is stored in the NetworkX drawing board, the closed area is found using the findcycle() function provided by the NetworkX library. Because the findcycle() function only returns one closed area each time, each time a closed area is obtained, the points and edges of the closed area need to be deleted from the drawing board until there is no closed area in the drawing board.

[0113] All closed areas are combined according to the coordinate positions in the original image to obtain the wall outline in the original floor plan.

[0114] In an exemplary embodiment, after searching for closed areas, the wall contour is obtained as follows: Figure 3 shown.

[0115] S05: Obtaining the outlines of doors and windows in the floor plan file according to the insertion point coordinates of the insert entity in the floor plan file in the DXF format and the wall coordinates.

[0116] Because doors and windows are commonly used components in apartment design, the method currently used by designers to draw doors and windows is to draw the shapes of doors and windows in advance and export them into a block. The next time you need to draw doors and windows, you can directly insert this block. This operation will save the doors and windows as an insert entity in the DXF file. Therefore, the strategy of identifying doors and windows in the present invention is to use the ezdxf library to obtain the insertion point of the insert, then traverse the point coordinates of all wall lines, calculate the Euclidean distance between the insertion point and these points, record the four points closest to the insertion point, and connect them in a non-intersecting way.

[0117] In a specific embodiment, obtaining the door and window profiles includes the following steps:

[0118] S051: traverse all insert entities in the floor plan file in the DXF format, obtain the coordinates of the insertion point of each insert entity, and put the coordinates of all the insertion points in the door and window list.

[0119] S052: traverse the door and window list and the entity list, and for each coordinate of the insertion point, calculate the Euclidean distance between the coordinate of the insertion point and each point in the entity list.

[0120] In an exemplary embodiment, the positional relationship between the insertion point coordinates and the wall contour is as follows: Figure 4 shown.

[0121] S053: Sort all distances by size, connect the four points with the smallest distances, and obtain the door and window outline corresponding to the insertion point.

[0122] Preferably, when four points are connected, a connection condition is preset, and the connection condition is: between two points, one of the horizontal coordinate or the vertical coordinate is the same. Under the limitation of this condition, it can be ensured that the four points can be connected into a closed rectangle without the situation of diagonal connection.

[0123] S06: Outputting a vectorized floor plan according to the wall outline and the door and window outline.

[0124] Preferably, the house structure and size information extracted in the above steps are transferred to a specific JSON file format, and after subsequent rendering, the vectorized house plan can be presented on the platform for users to carry out personalized decoration.

[0125] like Figure 5 As shown, Figure 5 In an exemplary embodiment, the vectorized floor plan is obtained by combining the extracted wall outlines and door and window outlines.

[0126] In order to unify the line width when converting DXF format files into picture output, after studying DXF files, the present invention also provides a method for adjusting the BYLAYER default line type and line width. In a preferred embodiment, the present invention provides a method for extracting and vectorizing floor plan information based on DXF format, which also includes:

[0127] S07: using the method provided by ezdxf to traverse the DXFATTRIBS dictionary of the LINE entity, the POLYLINE entity and the LWPOLYLINE entity in the floor plan file in the DXF format;

[0128] S08: Adjust the values ​​of const_width, thickness, and lineweight to the preset uniform values.

[0129] Corresponding to the aforementioned method for extracting and vectorizing floor plan information based on DXF format, the present invention also provides a device for extracting and vectorizing floor plan information based on DXF format, such as Figure 6 As shown, the device 400 includes:

[0130] The floor plan file acquisition module 401 is used to acquire the floor plan file in DXF format to be processed;

[0131] A preprocessing module 402 is used to preprocess the floor plan file in the DXF format to remove the axes, texts and rulers in the file;

[0132] The entity coordinate information extraction module 403 is used to extract the coordinate information of the entity across layers for the pre-processed DXF format floor plan file;

[0133] A wall outline acquisition module 404 is used to obtain the wall outline in the floor plan file according to the coordinate information of the entity;

[0134] The door and window outline acquisition module 405 is used to obtain the door and window outlines in the floor plan file according to the insertion point coordinates of the insert entity in the floor plan file in the DXF format and the wall coordinates;

[0135] The floor plan output module 406 is used to output a vectorized floor plan according to the wall outline and the door and window outline.

[0136] In other embodiments, the present invention also provides a smart device, such as Figure 7 As shown, including:

[0137] at least one memory and at least one processor;

[0138] The memory 920 is used to store one or more programs;

[0139] When the one or more programs are executed by the at least one processor 910, the at least one processor implements the steps of any one of the floor plan information extraction and vectorization methods based on the DXF format as described above.

[0140] In other embodiments, the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of any one of the floor plan information extraction and vectorization methods based on the DXF format as described above are implemented.

[0141] Compared with the prior art, the present invention provides a method and device for extracting and vectorizing floor plan information based on DXF format, which automatically extracts floor plan structure and size information from floor plan in DXF format, transfers this information into a specific JSON file format, and renders the vectorized floor plan on the platform for users to carry out personalized decoration. At the same time, the problem of layer confusion in real design is solved, a method of extracting DXF files across layers is adopted, the coordinate information required for vectorization in DXF files is extracted using the ezdxf library provided by Python, and NetworkX is used to save the extracted information and redraw the floor plan structure in the drawing board to complete the vectorization of DXF floor plan.

[0142] The above-mentioned embodiments only express several implementation methods of the present invention, and the description is relatively specific and detailed, but it cannot be understood as limiting the scope of the invention patent. It should be pointed out that for ordinary technicians in this field, several modifications and improvements can be made without departing from the concept of the present invention, which all belong to the protection scope of the present invention.

Claims

1. A method for extracting and vectorizing floor plan information based on DXF format. It is characterized in that The following steps are involved: Get the floor plan file in DXF format to be processed; Preprocessing the floor plan file in the DXF format to remove the axes, texts and rulers in the file; For the pre-processed DXF format floor plan file, extracting coordinate information of entities across layers; According to the coordinate information of the entity, obtain the wall outline in the floor plan file; Obtaining the outlines of doors and windows in the floor plan file according to the insertion point coordinates of the insert entity in the floor plan file in the DXF format and the coordinate information of each point on the wall; Outputting a vectorized floor plan according to the wall outline and the door and window outline; The cross-layer extraction of entity coordinate information includes: Traversing the entity segments of the pre-processed DXF format floor plan file to obtain the entity; wherein the entity includes LINE entity, POLYLINE entity and LWPOLYLINE; For each entity, extract the coordinates of all points of the entity and store them in an entity list; Deduplicating the entity list, and allocating nodes according to the length of the deduplicated list; Number each node, establish a mapping relationship between the node number and the coordinates, and add the node to the drawing board; Get the node number through the coordinate value, and store the numbers of the two points of each edge in the nested list edges; Use draw_networkx_edges() to connect the points on the graph.

2. A method for extracting and vectorizing floor plan information based on DXF format according to claim 1, It is characterized in that Obtaining the wall outline in the floor plan file according to the coordinate information of the entity, including: The extracted coordinate information of the entity is stored in the NetworkX drawing board; Use the findcycle() function provided by the NetworkX library to find the closed area; Every time a closed area is obtained, delete the points and edges of the closed area in the drawing board; Repeat the process of searching for a closed area and deleting the points and edges of the closed area until there is no closed area in the drawing board; The wall contour is obtained according to all the closed areas.

3. The method for extracting and vectorizing floor plan information based on DXF format according to claim 1, It is characterized in that According to the insertion point coordinates of the insert entity in the floor plan file in the DXF format and the wall coordinates, the outlines of doors and windows in the floor plan file are obtained, including: Traverse all insert entities in the floor plan file in the DXF format, obtain the coordinates of the insertion point of each insert entity, and put the coordinates of all the insertion points in the door and window list; Traversing the door and window list and the entity list, for each coordinate of the insertion point, calculating the Euclidean distance between the coordinate of the insertion point and each point in the entity list; All distances are sorted by size, and the four points with the smallest distances are connected to obtain the door and window outline corresponding to the insertion point.

4. The method for extracting and vectorizing floor plan information based on DXF format according to claim 3, It is characterized in that Connect the four points with the smallest distance, including: A connection condition is set, wherein the connection condition is: between two points, one of the horizontal coordinate or the vertical coordinate is the same.

5. The method for extracting and vectorizing floor plan information based on DXF format according to claim 1, It is characterized in that Preprocess the floor plan file in DXF format to remove the axis, text and ruler in the file, including: Traversing the floor plan file in the DXF format, deleting the lines whose line type is not the default line type BYLAYER, and obtaining the floor plan file with the axis removed; Delete the TEXT entity and MTEXT entity to obtain the floor plan file without text; Delete the DIMENSION entity to obtain the floor plan file without the ruler.

6. The method for extracting and vectorizing floor plan information based on DXF format according to claim 1, It is characterized in that The following steps are also included: Use the method provided by ezdxf to traverse the DXFATTRIBS dictionary of LINE entities, POLYLINE entities and LWPOLYLINE entities in the floor plan file in the DXF format; Adjust the values ​​of const_width, thickness, and lineweight to the preset uniform values.

7. A device for extracting and vectorizing floor plan information based on DXF format, It is characterized in that include: A floor plan file acquisition module is used to acquire the floor plan file in DXF format to be processed; A preprocessing module is used to preprocess the floor plan file in the DXF format to remove the axis, text and ruler in the file; An entity coordinate information extraction module is used to extract entity coordinate information across layers for the pre-processed DXF format floor plan file; A wall outline acquisition module, used to obtain the wall outline in the floor plan file according to the coordinate information of the entity; A door and window outline acquisition module, used to obtain the door and window outlines in the floor plan file according to the insertion point coordinates of the insert entity in the floor plan file in the DXF format and the coordinate information of each point on the wall; A floor plan output module, used to output a vectorized floor plan according to the wall outline and the door and window outline; The entity coordinate information extraction module is specifically used for: Traversing the entity segments of the pre-processed DXF format floor plan file to obtain the entity; wherein the entity includes LINE entity, POLYLINE entity and LWPOLYLINE; For each entity, extract the coordinates of all points of the entity and store them in an entity list; Deduplicating the entity list, and allocating nodes according to the length of the deduplicated list; Number each node, establish a mapping relationship between the node number and the coordinates, and add the node to the drawing board; Get the node number through the coordinate value, and store the numbers of the two points of each edge in the nested list edges; Use draw_networkx_edges() to connect the points on the graph.

8. A smart device, It is characterized in that include: at least one memory and at least one processor; The memory is used to store one or more programs; When the one or more programs are executed by the at least one processor, the at least one processor implements the steps of a floor plan information extraction and vectorization method based on DXF format as described in any one of claims 1-6.

9. A computer-readable storage medium, Features: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of a method for extracting and vectorizing floor plan information based on DXF format as described in any one of claims 1 to 6 are implemented.