Method for rapidly extracting AutoCAD drawing table data by using intersection point array
The intersection array method is used to filter and process the intersection points of vertical and horizontal lines in AutoCAD to form an intersection array, which solves the problems of data extraction speed and accuracy of AutoCAD tables, and realizes fast and regularized data extraction and transfer.
Patent Information
- Application Number
- CN202411256912.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-09
- Publication Date
- 2024-12-27
AI Technical Summary
The existing technology is difficult to quickly and standardize the extraction of table data in AutoCAD, resulting in difficulties in data sharing and standardized inventory entry.
The intersection array method is adopted to filter the line elements within the table range, calculate the intersection points of vertical and horizontal lines, form grouping and intersection arrays, obtain the minimum content unit information one by one, and perform data extraction and transfer, ensuring the rapid and regular extraction of data.
It realizes the fast and accurate extraction of AutoCAD table data, avoids missed and missed selection, improves the speed and integrity of data extraction, and meets most data extraction needs.
Smart Images

Figure CN119203949A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the field of computer data extraction, and in particular to a method for quickly extracting AutoCAD drawing table data by using an intersection array. Background Art
[0002] AutoCAD, as an automatic computer-aided design software, is used for two-dimensional drawing, detailed drawing, design documentation and basic three-dimensional design. It has now become an internationally popular drawing tool.
[0003] However, extracting and sharing data in AutoCAD requires certain technical methods, and it is even more difficult to extract table data in AutoCAD quickly and regularly. This also causes considerable trouble for data standardization and storage.
[0004] Therefore, it is particularly important to solve the problem of fast and standardized extraction of table data in AutoCAD. This method uses the intersection array approach to cleverly solve this problem. Summary of the invention
[0005] The purpose of the present invention is to overcome the deficiencies of the prior art and provide a method for quickly extracting AutoCAD drawn table data using an intersection array, so as to solve the problem of fast and standardized extraction of table data in AutoCAD.
[0006] The present invention is achieved through the following technical solutions:
[0007] In order to achieve the above object, the present invention provides a method for quickly extracting AutoCAD drawing table data using an intersection array, comprising the following steps:
[0008] S2: Filter and extract entities with the name *line in the table range, and establish a line entity selection set L; where *line means that the entity name in AutoCAD is line, including polylines and straight lines;
[0009] S3: Based on the line element selection set L, the vertical and horizontal lines are cyclically screened to establish the vertical and horizontal line element set S;
[0010] S4: Based on the vertical and horizontal line primitive set S, all intersection points of the vertical and horizontal lines are calculated to establish an intersection point set J;
[0011] S5: Based on the intersection set J, merge them to form group Gx and group Gy;
[0012] S6: Based on the data sequence lengths Lx and Ly of the groups Gx and Gy, define an empty two-dimensional sequence list, i.e., an empty intersection array;
[0013] S7: Generate an intersection point array A based on the groups Gx and Gy, and the intersection point set J;
[0014] S8: Based on the intersection point array A, obtain the information in the smallest content unit one by one to establish an information list;
[0015] S9: Based on the information list B, perform data extraction and transfer.
[0016] Preferably, in step S3, if the x - coordinates of the two endpoints of a line are the same or the difference is within a certain threshold k, it is a vertical line; if the y - coordinates of the two endpoints of a line are the same or the difference is within a certain threshold k, it is a horizontal line; all the horizontal and vertical lines form a set S of horizontal - vertical line primitives.
[0017] Preferably, in step S5, arrange the x - coordinate values of each intersection point in the intersection point set J in ascending order, and merge the x - coordinate values with a difference within a certain threshold k into one value by the averaging method to form the group Gx, where Gx includes the merged x - coordinate values arranged in ascending order;
[0018] Arrange the y - coordinate values of each intersection point in the intersection point set J in ascending order, and merge the y - coordinate values with a difference within a certain threshold k into one value by the averaging method to form the group Gy, where Gy includes the merged y - coordinate values arranged in ascending order.
[0019] Preferably, in step S7, generating the intersection point array A based on the groups Gx and Gy, and the intersection point set J includes: loop through Gx and Gy, when the distance between the coordinate [Gxi, Gyj] and a certain coordinate in the intersection point set J is less than the threshold k * √2, it is considered the same point position and write it to the [i, j] position of the intersection point array A; after the loop ends, obtain a complete intersection point array A; where Gxi represents the i - th x - coordinate value in the group Gx, Gyj represents the j - th y - coordinate value in the group Gy, i < Lx, j < Ly, and both i and j start from 0.
[0020] Preferably, in step S8, obtaining the information in the smallest content unit one by one based on the intersection point array A to establish the information list B includes:
[0021] Retrieve the intersection point array A by row and column to obtain the smallest - range rectangle with non - nil (no coordinate) coordinates at all four corners, that is, the smallest content unit, and obtain the primitive attributes in the smallest content unit;
[0022] Save the row and column numbers of the upper - left corner of the smallest content unit and the obtained primitive attributes to form the information list B.
[0023] Preferably, in step S9, performing data extraction and transfer based on the information list B includes:
[0024] According to different output requirements, the loop uses the row and column numbers in the upper left corner of the sub-item in the information list B as the write address of the unit; writes the primitive attributes into the unit; when the loop ends, the data in this table can be extracted and transferred; among them, the sub-item refers to one of the data information.
[0025] Preferably, before step S2, the method further includes:
[0026] S1: Open the AutoCAD file containing the table, enter the program start command, and select the table range to be extracted.
[0027] Preferably, the threshold k is to avoid the phenomenon that individual vertical and horizontal lines are not drawn absolutely horizontally or absolutely vertically, and is generally set to 0.005m.
[0028] A computer program product includes a computer program / instruction, which, when executed by a processor, implements a method for quickly extracting AutoCAD drawing table data using an intersection array.
[0029] A readable storage medium stores a computer program, which, when executed, implements a method for quickly extracting AutoCAD drawing table data using an intersection array.
[0030] Compared with the prior art, the present invention has the following advantages:
[0031] (1) The present invention realizes an algorithm for quickly extracting user tables in AutoCAD into rows, columns and information according to information units. Rows, columns and information are a common data address representation method, which can be easily written into Excel or rule controls and can meet most data extraction needs.
[0032] (2) The present invention establishes a line element selection set by filtering entities with *line within a table range, cyclically filters vertical and horizontal lines, obtains all intersections of the vertical and horizontal lines, establishes an intersection set, and then groups the intersections according to their horizontal and vertical coordinates, defines an empty two-dimensional sequence table, writes the intersections, forms a complete intersection array A, obtains information in the smallest content unit one by one, establishes an information list B, and extracts and transfers data based on the information list B, thereby improving the speed of data extraction and promoting the regularization of data extraction.
[0033] (3) The present invention defines an empty two-dimensional sequence list through grouping Gx and grouping Gy, and then loops through grouping Gx and grouping Gy. When the distance between the coordinate [Gxi, Gyj] and a certain coordinate in the intersection set J is less than a threshold value k*√2, it is considered to be the same point and written into the [i, j] position of the intersection array A. After the loop is completed, a complete intersection array A is obtained. The intersection array A is searched according to rows and columns to obtain the minimum range rectangle whose coordinates of all four corners are not nil (no coordinates), that is, the minimum content unit, and obtain the primitive attributes in the minimum content unit; the row and column number of the upper left corner of the minimum content unit and the obtained primitive attributes are saved to form an information list B, so that the row and column number and attribute content of the virtual cell can be effectively obtained. By making a one-to-one correspondence between the data coordinate space unit and the row and column address, defects such as missed selection and wrong selection are avoided, thereby improving the accuracy and completeness of data extraction. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] Figure 1 is a sample drawing to be extracted in the CAD of an embodiment of the present invention;
[0035] Figure 2 A schematic diagram of an example of generating an intersection point in an embodiment of the present invention;
[0036] Figure 3 This is a schematic diagram of a data structure example of an empty two-dimensional sequence table in an embodiment of the present invention;
[0037] Figure 4 This is a sample diagram of intersection array data in an embodiment of the present invention;
[0038] Figure 5 This is a sample diagram of the information list extracted in the embodiment of the present invention;
[0039] Figure 6 This is a sample diagram of data after transfer according to an embodiment of the present invention;
[0040] Figure 7 The figure is a flow chart of the steps of the method of the present invention. DETAILED DESCRIPTION
[0041] The technical solution of the present invention will be clearly and completely described below in conjunction with the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0042] See also Figures 1 to 7 The first embodiment of the present invention provides a method for quickly extracting AutoCAD drawing table data using an intersection array, comprising the following steps:
[0043] S1: Open the AutoCAD file containing the table, enter the program start command, and select the table range to be extracted, such as Figure 1 shown.
[0044] S2: Filter and extract entities with *line in the table range, and establish a line element selection set L;
[0045] Among them, *line means that the entity name in AutoCAD is line, including polyline and straight line.
[0046] S3: Based on the line element selection set L, the vertical and horizontal lines are cyclically screened to establish the vertical and horizontal line element set S;
[0047] If the x-coordinates of the two endpoints of a line are the same or the difference is within a certain threshold k, it is a vertical line; if the y-coordinates of the two endpoints of a line are the same or the difference is within a certain threshold k, it is a horizontal line; all horizontal and vertical lines constitute a vertical and horizontal line primitive set S;
[0048] The threshold k is used to avoid the phenomenon that some vertical and horizontal lines are not drawn absolutely horizontally or absolutely vertically, and is generally taken as 0.005m.
[0049] S4: Based on the vertical and horizontal line primitive set S, all the intersection points of the vertical and horizontal lines are calculated to establish the intersection point set J; Figure 2 As shown (red dots indicate intersection points).
[0050] S5: Based on the intersection set J, merge them to form group Gx and group Gy;
[0051] Arrange the x-coordinate values of each intersection point in the intersection point set J in ascending order, merge the x-coordinate values whose differences are within a certain threshold k into one value by averaging, and form a group Gx, which includes the merged x-coordinate values arranged in ascending order;
[0052] Arrange the y coordinate values of each intersection point in the intersection point set J in ascending order, merge the y coordinate values whose differences are within a certain threshold k into one value by averaging, and form a group Gy, which includes the merged y coordinate values arranged in ascending order;
[0053] S6: Based on the group Gx and the group Gy, define an empty two-dimensional sequence table;
[0054] That is, according to the lengths Lx and Ly of the Gx and Gy data sequences, an empty two-dimensional sequence table, i.e., an empty intersection array, is defined, such as Figure 3 shown.
[0055] S7: Generate an intersection array A based on the group Gx and the group Gy, and the intersection set J;
[0056] That is, loop Gx and Gy. When the distance between the coordinate [Gxi, Gyj] (where i < Lx, j < Ly, and both i and j start from 0) and a certain coordinate in the intersection point set J is less than the threshold k * √2, it is considered the same point position and is written to the [i, j] position of the intersection point array A. After the loop ends, a complete intersection point array A is obtained. Example data is as Figure 4 shown.
[0057] S8: Based on the intersection point array A, obtain the information in the minimum content unit one by one and establish an information list B;
[0058] Retrieve the intersection point array A by rows and columns to obtain the smallest range rectangle with the coordinates of all four corners not being nil (no coordinates), that is, the minimum content unit, and obtain the primitive attributes in the minimum content unit; save the row and column numbers of the upper left corner of the minimum content unit and the obtained primitive attributes to form the information list B;
[0059] The primitive attributes obtained in this embodiment include text content and block name information. Examples are as Figure 5 shown.
[0060] S9: Based on the information list B, perform data extraction and transfer;
[0061] According to different output requirements, loop and use the row and column numbers of the upper left corner of the sub-item in the information list B as the write address of the cell, and write the primitive attributes to this cell. After the loop ends, the extraction and transfer of this table data can be realized. Among them, the sub-item refers to one piece of data information, such as Figure 6 shown;
[0062] The above are only some embodiments of the present invention and are not intended to limit the present invention. Any modifications, equivalent replacements, and improvements made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method for quickly extracting AutoCAD drawing table data using an intersection array, characterized in that: Including: S2: Screen and extract the entities with *line within the table range, and establish a line graphic element selection set L; where, *line means that the graphic element name in AutoCAD is a line, including polyline and straight line; S3: Based on the line graphic element selection set L, loop to screen the vertical and horizontal lines, and establish a vertical and horizontal line graphic element set S; S4: Calculate all the intersection points of the vertical lines and horizontal lines in the vertical and horizontal line graphic element set S, and establish an intersection point set J; S5: Based on the intersection point set J, merge it to form grouping Gx and grouping Gy; S6: Based on the data sequence lengths Lx and Ly of grouping Gx and grouping Gy, define an empty two-dimensional sequence table, that is, an empty intersection point array; S7: Based on grouping Gx and grouping Gy, and the intersection point set J, generate an intersection point array A; S8: Based on the intersection point array A, obtain the information in the smallest content unit one by one, and establish an information list B; S9: Based on the information list B, perform data extraction and transfer.
2. The method of quickly extracting AutoCAD drawing table data using intersection array according to claim 1, characterized in that: In step S3, if the x coordinates of the two endpoints of the line are the same or the difference is within a certain threshold k, it is a vertical line. If the y coordinates of the two endpoints of the line are the same or the difference is within a certain threshold k, it is a horizontal line; all the horizontal lines and vertical lines constitute the vertical and horizontal line graphic element set S.
3. The method of quickly extracting AutoCAD drawing table data using intersection array according to claim 1, characterized in that: In step S5, arrange the x coordinate values of each intersection point in the intersection point set J in ascending order, and merge the x coordinate values with a difference within a certain threshold k into one value by the average method to form grouping Gx, and Gx includes the merged x coordinate values arranged in ascending order; Arrange the y coordinate values of each intersection point in the intersection point set J in ascending order, and merge the y coordinate values with a difference within a certain threshold k into one value by the average method to form grouping Gy, and Gy includes the merged y coordinate values arranged in ascending order.
4. The method of quickly extracting AutoCAD drawing table data using intersection array according to claim 3, characterized in that: In step S7, based on grouping Gx and grouping Gy, and the intersection point set J, generate an intersection point array A, including: loop Gx and Gy. When the distance between the coordinate [Gxi, Gyj] and a certain coordinate in the intersection point set J is less than the threshold k*√2, it is considered the same point position and written into the [i, j] position of the intersection point array A; after the loop ends, a complete intersection point array A is obtained; where, Gxi represents the i-th x coordinate value in grouping Gx, Gyj represents the j-th y coordinate value in grouping Gy, i < Lx, j < Ly, and both i and j start from 0.
5. The method of quickly extracting AutoCAD drawing table data using intersection array according to claim 1, characterized in that: In step S8, based on the intersection point array A, obtain the information in the smallest content unit one by one, and establish an information list B, including: Retrieve the intersection point array A by row and column, obtain the smallest range rectangle with the coordinates of the four corners not being nil, that is, the smallest content unit, and obtain the graphic element attributes in the smallest content unit; nil means no coordinates; Save the row and column numbers of the upper left corner of the smallest content unit and the obtained graphic element attributes to form the information list B.
6. The method of quickly extracting AutoCAD drawing table data using intersection array according to claim 1, characterized in that: In step S9, based on the information list B, perform data extraction and transfer, including: According to different output requirements, loop to use the row and column numbers of the upper left corner of the sub-items in the information list B as the write address of the unit; write the graphic element attributes into this unit; after the loop ends, the extraction and transfer of this table data can be realized; where, the sub-item refers to one piece of data information.
7. The method of quickly extracting AutoCAD drawing table data using intersection array according to claim 1, characterized in that: Before step S2, it also includes: S1: Open the AutoCAD file containing the table, enter the program start command, and select the table range to be extracted.
8. A method for quickly extracting AutoCAD drawing table data using an intersection array according to claim 2, 3 or 4, characterized in that: The threshold k is used to avoid the phenomenon that some vertical and horizontal lines are not drawn absolutely horizontally or absolutely vertically, and is generally set to 0.005m.
9. A computer program product, characterized in that It includes a computer program / instruction, which, when executed by a processor, implements a method for quickly extracting AutoCAD drawing table data using an intersection array as described in any one of claims 1 to 8.
10. A readable storage medium, characterized in that: A computer program is stored thereon, and when the computer program is executed, the method for quickly extracting AutoCAD drawing table data using an intersection array as described in any one of claims 1 to 8 is implemented.
Citation Information
Cited By
CAD coordinate table data extraction method and device
CN122049928A
