Method for extracting CAD (Computer Aided Design) format measurement data
By parsing CAD files and performing layer semantic matching and deduplication correction, the problem of low CAD data extraction efficiency in water conservancy and hydropower projects has been solved, achieving efficient and accurate data processing.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-11
- Publication Date
- 2026-04-07
AI Technical Summary
In the design of water conservancy and hydropower projects, existing technologies cannot efficiently and accurately extract and classify CAD format measurement data, resulting in long processing times and failure to meet design accuracy and schedule requirements.
By parsing CAD files, identifying layer semantics and performing adaptive matching, determining dynamic layer priorities, performing deduplication and hierarchical error correction, and generating reports.
It improved data processing efficiency, ensured the accuracy and precision of extraction, reduced resource waste, and met the precision and schedule requirements of engineering design.
Smart Images

Figure CN121809478A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of engineering surveying, and more specifically to a method for extracting measurement data in CAD format. Background Technology
[0002] In the design process of water conservancy and hydropower projects, the use of CAD format measurement data is indispensable, especially in the early stages of design refinement. When assessing the impact of land acquisition for construction, CAD format measurement data such as land area, building area, roads, and power lines are frequently categorized and statistically analyzed. Because CAD format measurement data involves many types and large quantities, manual extraction and classification are time-consuming and lack good data verification capabilities, failing to meet the accuracy and schedule requirements of water conservancy and hydropower project design. Summary of the Invention
[0003] The main objective of this invention is to provide a method for extracting measurement data in CAD format, thereby solving the problems mentioned in the background art.
[0004] To solve the above-mentioned technical problems, the technical solution adopted by the present invention is: a method for extracting measurement data in CAD format, comprising the following steps: S1. Parse CAD files; S2. Identify layer semantics and perform adaptive matching; S3. Determine the priority of dynamic layers and resolve conflicts; S4. Perform deduplication operation; S5. Perform parameter configuration and partition extraction operations; S6. Perform error source tracing and hierarchical correction operations; S7. Perform data validation and generate a report.
[0005] Furthermore, the detailed process of step S1 is as follows: Parse DWG and DXF format CAD files, traverse all entities in the model space, and extract the layer name, geometry type, creation time, and coordinates of each entity.
[0006] Furthermore, the detailed process of step S2 is as follows: S201. Construct a semantic library for layer names in water conservancy and hydropower projects, sort out synonyms for layer names in the industry, and establish a relational library of "core semantics - synonyms - weight values". S202. Perform semantic similarity matching, using the following formula: (1); Where A is the feature vector of the CAD layer name, and B is the feature vector of the core semantics of the semantic library. Let n be the similarity between A and B, and n be the feature dimension. Determine the matching threshold When there is When A and B are determined to be matching target semantic layers; S203. Record the layer naming rules for different projects, and iteratively optimize the semantic library based on user confirmation results.
[0007] Furthermore, the detailed process of step S3 is as follows: S301. Calculate the comprehensive score through the layer priority evaluation dimensions, which include: entity type matching degree T, entity quantity ratio N, creation time C, and user historical annotation frequency H. For T, T is 1 if the entity matches, and 0 if it does not match. For C, if the entity is the most recently created, C is 1, and it decays linearly to 0 over time. For H, if the entity is a high-frequency annotation, H is 1, and it decreases linearly to 0 according to the number of annotations. The expression for the overall score S is: (2); in, , , , These are the weights corresponding to T, N, C, and H, respectively. S302. When multiple layers are detected to match the same core semantics, calculate the comprehensive score of each layer and take the layer with the highest score as the target layer. S303. Set a comprehensive score threshold. When the difference between the scores of multiple layers is less than the preset threshold, the system records them as high-conflict layers and pushes them to the user, who then determines the target layer.
[0008] Furthermore, the detailed process of step S4 is as follows: S401. Generate unique feature codes according to entity type, and identify duplicate entities by feature code matching. (This refers to the feature codes of point entities.) The form is: (3); in, A one-way hash function in a hash algorithm. As a separator, The layer name; Characteristic code of line entity The form is: (4); Where N is the set of inflection point coordinates, and L is the overall length of the line entity; Feature code of face entity The form is: (5); Where M is the set of vertex coordinates, The total area of the solid surface; S402. Traverse all entities in the target layer, generate feature codes and store them in a temporary library. When duplicate feature codes are detected, retain the entity with the newest creation time or the fewest modifications, and delete the remaining duplicate entities. When the feature codes of line and surface entities are inconsistent but have a high overlap rate, mark them as suspected duplicates and confirm them manually. High overlap rate requires the following conditions to be met: line entity overlap rate greater than or equal to 95%, and surface entity overlap rate greater than or equal to 90%.
[0009] Furthermore, the detailed process of step S5 is as follows: Input the core parameters; Add extended data annotations to the matched target layer entities and mark them as collected. Entities are extracted hierarchically according to geometric type and associated with engineering scene parameters; the set types include: points, lines, and surfaces.
[0010] Furthermore, the detailed process of step S6 is as follows: S601. Calculate the degree of influence of the error, the expression is: (6); in, To determine the degree of influence of error, , These are the measured values with errors and the actual values from the CAD data, respectively. S602. Calculate the corrected value based on the degree of error impact. The expression is: (7); in, This is the corrected error. To correct the strength coefficient; S603, Perform hierarchical correction.
[0011] Furthermore, in step S7, the data types being verified include: coordinate validity, numerical sign, and error threshold compliance. The generated JSON / Excel report includes: deduplicated records, incremental extraction information, and error source tracing.
[0012] Furthermore, step S4 also includes an incremental extraction operation, specifically: S403. When extracting data from the first CAD file of a project, establish a "Project-File-Entity Feature Code" database to store the feature codes, extraction time, and geometric parameters of all entities. S404. When extracting new version CAD files for the same project, iterate through the entities in the new version files, generate feature codes, and compare them with the historical database. The comparison results are as follows: Feature code matching: If the entity is determined to be "unmodified", the calculated geometric parameters and error correction results in the historical database are directly retrieved. Feature code mismatch: If determined to be a "new or modified entity", execute the complete extraction, calculation, and correction process, and update the feature code library; If an entity exists in the historical database but not in the new version, it is determined as an "entity to be deleted," removed from the results, and the reason for deletion is recorded.
[0013] Furthermore, in step S603, the process of hierarchical correction is as follows: when When the error is first level, the correction strength coefficient for all entities is set to 1. when When the error is second-order, the correction strength coefficient for the core entity is 1, and the correction strength coefficient for the non-core entity is 0.5. when When the strength coefficient of the solid is 0, the corrected strength coefficient is taken as 0.
[0014] Beneficial effects: (1) Use the weighted summation method to calculate the comprehensive score to determine the target layer. At the same time, combined with manual processing, we can ensure accuracy while improving processing efficiency. (2) The deduplication and incremental extraction operations avoid performing a complete extraction operation on the content of each CAD in the same project, which greatly reduces the waste of resources and improves efficiency; (3) Graded error correction reduces error processing time while ensuring correction accuracy. Attached Figure Description
[0015] The present invention will be further described below with reference to the accompanying drawings and embodiments: Figure 1 This is a flowchart of the steps of the present invention; Figure 2 This is a flowchart of step S2 of the present invention; Figure 3 This is a flowchart of step S3 of the present invention. Detailed Implementation
[0016] Example 1 like Figures 1-3 As shown, a method for extracting measurement data in CAD format includes the following steps: S1. Parse CAD files, including DWG and DXF format CAD files, traverse all entities in the model space, and extract basic attributes such as layer name, geometry type, creation time, and coordinates of the entities. S2. Identify layer semantics and perform adaptive matching. The detailed process is as follows: S201. Construct a semantic library for layer names in water conservancy and hydropower projects, sort out synonymous expressions for layer names in the industry, such as "land area", "LandArea", "plot area", "reservoir area", "inundation area", etc., which are synonymous expressions, and establish an association library of "core semantics - synonym expression - weight value". The core semantics are classified according to the engineering scenario, specifically into: area, length and elevation. S202. Perform semantic similarity matching, that is, use the cosine similarity algorithm to calculate the similarity between the CAD layer name and the core semantics of the semantic library. The formula is: (1); Where A is the feature vector of the CAD layer name, and B is the feature vector of the core semantics of the semantic library. Let n be the similarity between A and B, and n be the feature dimension. Determine the matching threshold When there is When A and B are determined to be matching target semantic layers; S203. Record the layer naming rules for different projects, and iteratively optimize the semantic library based on user confirmation results to improve the accuracy of cross-project matching; S3. Determine the priority of dynamic layers and resolve conflicts. The detailed process is as follows: S301. Calculate the comprehensive score through the layer priority evaluation dimensions, which include: entity type matching degree T, entity quantity ratio N, creation time C, and user historical annotation frequency H. For T, T is 1 if the entity matches, and 0 if it does not match. For C, if the entity is the most recently created, C is 1, and it decays linearly to 0 over time. For H, if the entity is a high-frequency annotation, H is 1, and it decreases linearly to 0 according to the number of annotations. The expression for the overall score S is: (2); in, , , , These are the weights corresponding to T, N, C, and H, respectively. The weights, arranged from largest to smallest, are: entity type matching degree T, entity quantity ratio N, creation time, and user historical annotation frequency H. In the preferred scheme, these weights are 0.6, 0.2, 0.1, and 0.1, respectively. S302. When multiple layers are detected to match the same core semantics, calculate the comprehensive score of each layer and take the layer with the highest score as the target layer. S303. Set a comprehensive score threshold. When the difference between the scores of multiple layers is less than the preset threshold, the system records them as high-conflict layers and pushes them to the user, who then determines the target layer.
[0017] S4. Perform the deduplication operation. The detailed process is as follows: S401. Generate unique feature codes according to entity type, and identify duplicate entities by feature code matching. (This refers to the feature codes of point entities.) The form is: (3); in, This is a one-way hash function in hash algorithms, whose function is to convert text or data of arbitrary length into a unique 32-bit hexadecimal string. As a separator, The layer name; Characteristic code of line entity The form is: (4); Where N is the set of inflection point coordinates, and L is the overall length of the line entity; Feature code of face entity The form is: (5); Where M is the set of vertex coordinates, The total area of the solid surface; S402. Traverse all entities in the target layer, generate feature codes and store them in a temporary library. When duplicate feature codes are detected, retain the entity with the newest creation time or the fewest modifications, and delete the remaining duplicate entities. If the feature codes of line and surface entities are inconsistent but have a high overlap rate, mark them as suspected duplicates and perform manual confirmation. High overlap rate requires the following conditions to be met: line entity overlap rate greater than or equal to 95%, and surface entity overlap rate greater than or equal to 90%.
[0018] S5. Perform parameter configuration and partition extraction operations, and input core parameters, including: engineering scenario type, such as reservoir area measurement, dam body measurement, etc.; accuracy requirement level, such as preliminary design, construction drawing design, etc.; and output field requirements. Add extended data annotations to the matched target layer entities and mark them as collected to avoid duplicate extraction; Entities are extracted hierarchically according to geometric type and associated with engineering scene parameters, such as elevation data that needs to be associated for reservoir area measurement; set types include: points, lines, and surfaces; For point entities, the coordinate values are directly read from the entity's position attribute; For line entities, if it is a straight line, the Euclidean distance formula is used to calculate the length; if it is a polyline, the length of each segment is calculated and summed; if it is a spline curve, the arc length integral formula combined with Simpson's numerical integration method is used to calculate the length. For surface entities, if it is a simple closed polygon, the Shoelace formula is used to calculate the area; if it is a self-intersecting polygon, the triangulation method is used to decompose it into non-intersecting triangles and then sum them.
[0019] S6. Perform error source tracing and hierarchical correction operations. The detailed process is as follows: S601. Calculate the degree of influence of the error, the expression is: (6); in, To determine the degree of influence of error, , These are the measured values with errors and the actual values from the CAD data, respectively. S602. Calculate the corrected value based on the degree of error impact. The expression is: (7); in, This is the corrected error. To correct the strength coefficient; S603, Perform hierarchical correction, when When the error is first level, the correction strength coefficient for all entities is set to 1. when When the error is second-order, the correction strength coefficient for the core entity is 1, and the correction strength coefficient for the non-core entity is 0.5. when When the correction strength coefficient of the solid is 0, the error is ignored.
[0020] S7. Perform data validation and generate a report. The data types to be validated include: coordinate validity, numerical sign, and error threshold compliance. The generated JSON / Excel report includes: deduplicated records, incremental extraction information, and error source tracing.
[0021] Furthermore, step S4 also includes: S403. When extracting data from the first CAD file of a project, establish a "Project-File-Entity Feature Code" database to store the feature codes, extraction time, and geometric parameters of all entities. S404. When extracting new version CAD files for the same project, iterate through the entities in the new version files, generate feature codes, and compare them with the historical database. The comparison results are as follows: Feature code matching: If the entity is determined to be "unmodified", the calculated geometric parameters and error correction results in the historical database are directly called, without the need for repeated calculation; Feature code mismatch: If determined to be a "new or modified entity", execute the complete extraction, calculation, and correction process, and update the feature code library; If an entity exists in the historical database but not in the new version, it is determined as an "entity to be deleted," removed from the results, and the reason for deletion is recorded.
[0022] The above embodiments are merely preferred technical solutions of the present invention and should not be considered as limitations on the present invention. The scope of protection of the present invention should be limited to the technical solutions described in the claims, including equivalent substitutions of the technical features described in the claims. That is, equivalent substitutions and improvements within this scope are also within the scope of protection of the present invention.
Claims
1. A method for extracting measurement data in CAD format, characterized in that, Includes the following steps: S1. Parse CAD files; S2. Identify layer semantics and perform adaptive matching; S3. Determine the priority of dynamic layers and resolve conflicts; S4. Perform deduplication operation; S5. Perform parameter configuration and partition extraction operations; S6. Perform error source tracing and hierarchical correction operations; S7. Perform data validation and generate a report.
2. The method for extracting CAD format measurement data according to claim 1, characterized in that, The detailed process of step S1 is as follows: Parse DWG and DXF format CAD files, traverse all entities in the model space, and extract the layer name, geometry type, creation time, and coordinates of each entity.
3. The method for extracting CAD format measurement data according to claim 1, characterized in that, The detailed process of step S2 is as follows: S201. Construct a semantic library for layer names in water conservancy and hydropower projects, sort out synonyms for layer naming in the industry, and establish a relational library of "core semantics - synonyms - weight values". S202. Perform semantic similarity matching, using the following formula: (1); Where A is the feature vector of the CAD layer name, and B is the feature vector of the core semantics of the semantic library. Let n be the similarity between A and B, and n be the feature dimension. Determine the matching threshold When there is When A and B are determined to be matching target semantic layers; S203. Record the layer naming rules for different projects, and iteratively optimize the semantic library based on user confirmation results.
4. The method for extracting CAD format measurement data according to claim 1, characterized in that, The detailed process of step S3 is as follows: S301. Calculate the comprehensive score through the layer priority evaluation dimensions, which include: entity type matching degree T, entity quantity ratio N, creation time C, and user historical annotation frequency H. For T, T is 1 if the entity matches, and 0 if it does not match. For C, if the entity is the most recently created, C is 1, and it decays linearly to 0 over time. For H, if the entity is a high-frequency annotation, H is 1, and it decreases linearly to 0 according to the number of annotations. The expression for the overall score S is: (2); in, , , , These are the weights corresponding to T, N, C, and H, respectively. S302. When multiple layers are detected to match the same core semantics, calculate the comprehensive score of each layer and take the layer with the highest score as the target layer. S303. Set a comprehensive score threshold. When the difference between the scores of multiple layers is less than the preset threshold, the system records them as high-conflict layers and pushes them to the user, who then determines the target layer.
5. The method for extracting CAD format measurement data according to claim 1, characterized in that, The detailed process of step S4 is as follows: S401. Generate unique feature codes according to entity type, and identify duplicate entities by feature code matching. (This refers to the feature codes of point entities.) The form is: (3); in, A one-way hash function in a hash algorithm. As a separator, The layer name; Characteristic code of line entity The form is: (4); Where N is the set of inflection point coordinates, and L is the overall length of the line entity; Feature code of face entity The form is: (5); Where M is the set of vertex coordinates, The total area of the solid surface; S402. Traverse all entities in the target layer, generate feature codes and store them in a temporary library. When duplicate feature codes are detected, retain the entity with the newest creation time or the fewest modifications, and delete the remaining duplicate entities. When the feature codes of line and surface entities are inconsistent but have a high overlap rate, mark them as suspected duplicates and confirm them manually. High overlap rate requires the following conditions to be met: line entity overlap rate greater than or equal to 95%, and surface entity overlap rate greater than or equal to 90%.
6. The method for extracting CAD format measurement data according to claim 1, characterized in that, The detailed process of step S5 is as follows: Input the core parameters; Add extended data annotations to the matched target layer entities and mark them as collected. Extract entities by geometric type and associate them with engineering scene parameters; Collection types include: points, lines, and surfaces.
7. The method for extracting CAD format measurement data according to claim 1, characterized in that, The detailed process of step S6 is as follows: S601. Calculate the degree of influence of the error, the expression is: (6); in, To determine the degree of influence of error, , These are the measured values with errors and the actual values from the CAD data, respectively. S602. Calculate the corrected value based on the degree of error impact. The expression is: (7); in, This is the corrected error. To correct the strength coefficient; S603, Perform hierarchical correction.
8. The method for extracting CAD format measurement data according to claim 1, characterized in that, In step S7, the data types being verified include: coordinate validity, numerical sign, and error threshold compliance. The generated JSON / Excel report includes: deduplicated records, incremental extraction information, and error source tracing.
9. The method for extracting CAD format measurement data according to claim 5, characterized in that, Step S4 also includes an incremental extraction operation, specifically: S403. When extracting data from the first CAD file of a project, establish a "Project-File-Entity Feature Code" database to store the feature codes, extraction time, and geometric parameters of all entities. S404. When extracting new version CAD files for the same project, iterate through the entities in the new version files, generate feature codes, and compare them with the historical database. The comparison results are as follows: Feature code matching: If the entity is determined to be "unmodified", the calculated geometric parameters and error correction results in the historical database are directly retrieved. Feature code mismatch: If determined as "new or modified entity", execute the complete extraction, calculation, and correction process, and update the feature code library; If an entity exists in the historical database but not in the new version, it is determined as an "entity to be deleted," removed from the results, and the reason for deletion is recorded.
10. The method for extracting CAD format measurement data according to claim 7, characterized in that, In step S603, the graded correction process is as follows: when When the error is first level, the correction strength coefficient for all entities is set to 1. when When the error is second-order, the correction strength coefficient for the core entity is 1, and the correction strength coefficient for the non-core entity is 0.
5. when When the strength coefficient of the solid is 0, the corrected strength coefficient is taken as 0.