An AI agent-based construction CAD drawing credible correction method and system
By constructing a group of construction object entities and a globally corresponding cost matrix, and combining confidence level and three-state gating mechanism, the problems of omission, error and lack of traceability in the correction of CAD drawings on the construction site are solved, and the accurate modification and traceability of construction drawings are realized.
Patent Information
- Application Number
- CN202611572865.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-10-12
- Publication Date
- 2026-11-06
AI Technical Summary
Existing technologies for correcting CAD drawings at construction sites suffer from several problems, including omissions or errors due to the identification of single graphic elements, inability to directly correspond between different numbering systems, unreproducible visual model outputs, differences in the execution behavior of commercial CAD software, and a lack of automated verification mechanisms. These issues lead to inaccurate and untraceable modifications to construction drawings.
By constructing a group of construction objects and using AI agents to generate a set of entity groups, a candidate cost matrix is constructed for global one-to-one correspondence. Combined with confidence grading and three-state gating mechanisms, it is ensured that all constituent entities of the same construction object are identified and modified synchronously, and the modification results are verified through independent processes, forming a traceable chain of evidence.
It effectively avoids omissions or errors in the modification of construction drawings, ensures that all entities of the construction object are identified and modified simultaneously, prevents multiple records from repeatedly occupying the same object, reduces the risk of accidental modification, and forms a complete chain of evidence through independent verification, thus solving the problems of inaccurate modification and lack of traceability in existing technologies.
Smart Images

Figure CN123049684A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of reliable drawing correction, and in particular relates to a reliable correction method and system for construction CAD drawings based on AI intelligent agents. Background Technology
[0002] During engineering construction, design drawings, existing condition survey maps, on-site survey data, and as-built documentation are often generated by different units, at different stages, and using different software. After construction is completed or during on-site re-surveying, data on wellheads, valves, structures, pipeline nodes, and elevations need to be backfilled into existing CAD drawings to create deliverables consistent with the actual site conditions. In existing technologies, some solutions attempt to utilize large-scale artificial intelligence language models to directly convert natural language requirements into CAD modeling commands or scripts, enabling generation from scratch or parametric modeling. Other solutions are based on vision or multi-agent collaborative frameworks, driving the CAD environment to execute instructions through task decomposition and code generation. Furthermore, CAD software itself provides basic automated tools such as searching, attribute extraction, and script recording, which can be used to assist in drawing modification.
[0003] However, the existing technologies still have the following problems: First, construction site objects in CAD drawings are usually not single elements, but are composed of multiple entities such as wellhead symbols, numbered text, elevation frames, elevation text, and associated pipelines. If existing methods only identify a single block name or a single type of entity, it is very easy to cause misselection, omission, or only moving some of the entities. Second, the field surveying tables and existing CAD drawings often use different numbering systems, making it impossible to directly establish a one-to-one correspondence using the CAD's built-in search function. Furthermore, matching nearest neighbors one by one may lead to multiple new records incorrectly occupying the same old object. Third, large language models or visual models are suitable for assisting understanding, but their output has the risk of illusion and non-reproducibility, and should not be used as the sole source of precise coordinates, CAD entity handles, or modification ranges. Fourth, the GUI commands, COM interfaces, Core Console, and script environments provided by commercial CAD software have different execution behaviors. Layer locking, text alignment, or command lines may lead to pseudo-success situations where "the log shows completion but the entity has not actually changed." Existing methods lack a detection mechanism for such situations. Fifth, most automated processes only check for script errors, failing to reopen the modified drawings and verify each object individually, nor do they verify the total number of entities, drawing audit results, and original document hash values, making it difficult to form a traceable chain of evidence. Sixth, when there are ambiguous or low-confidence matches, existing batch processing methods tend to expand the scope of modifications to increase automation rates, lacking a three-state risk gating mechanism of automatic approval, manual review, and prohibition of modifications. Summary of the Invention
[0004] To address the aforementioned technical problems, this invention provides a reliable correction method for construction CAD drawings based on an AI agent, comprising: Acquire natural language tasks, authoritative data records, and existing CAD drawings; A standard record set is generated based on the authoritative data records; Identify multiple entities that constitute the same construction object in the existing CAD drawings and generate a set of entity groups; Construct a candidate cost matrix based on the standard record set and the entity group set, solve the global one-to-one correspondence, select the candidate entity group with the smallest comprehensive matching cost as the optimal candidate, select the candidate entity group with the second smallest comprehensive matching cost as the suboptimal candidate, and use the difference between the comprehensive matching costs of the two as the candidate gap. Confidence levels are determined based on the absolute cost, candidate gap, and entity group integrity of the optimal candidate, and a decision is output that allows automatic approval, manual review, or prohibition of modification. An immutable operation plan is generated only for objects that pass automatically. The plan includes a set of handles to the entities to be modified, a pre-execution state, and a target state. According to the operation plan, modifications are made to the copy of the drawing, and the success criterion is that the actual state reaches the target state. Verify the modified drawings in an independent process and output the verification results.
[0005] Optionally, the generation of the entity group set includes: Based on the entity index, using the wellhead block or elevation frame as the anchor point, the wellhead symbol, numbered text, elevation frame, well bottom elevation text and ground elevation text are combined according to the layer, entity type, text semantics and geometric position. Entities in each group are identified by a unique handle and maintain a fixed offset relative to the anchor point. If a key role is missing, a handle is duplicated, or the relative position deviates from the template, it is marked as an incomplete entity group.
[0006] Optionally, the construction of the candidate cost matrix includes: For each combination of a standard record and an entity group, calculate the planar coordinate distance cost, elevation difference cost, semantic inconsistency penalty, topological inconsistency penalty, and group incompleteness penalty respectively. After weighted summation, add hard rule penalties and output cost matrix elements that can be traced back to the CAD semantic source.
[0007] Optionally, the solution for the global one-to-one correspondence includes: adding unmatched virtual nodes and unmatched penalties to each standard record and each entity group; solving the global minimum cost allocation under the constraint that each record corresponds to at most one entity group and each entity group is occupied by at most one record; and outputting the optimal correspondence, unmatched records and unmatched entity groups, and the suboptimal candidate entity group corresponding to each record.
[0008] Optionally, the confidence level includes: Continuous confidence scores are calculated based on optimal cost, candidate gap, group integrity, and rule risk, and then superimposed with hard conditions such as absolute cost threshold, maximum displacement limit, handle uniqueness, key role integrity, and drawing writability. Automatic passage is determined when the optimal cost is lower than the safety threshold, the candidate gap reaches the threshold, the displacement does not exceed the limit, and the group is complete. Candidates exist but are only missing gaps or incomplete groups, and are judged to be subject to manual review; if the coordinates are abnormal, the displacement exceeds the limit, the key anchor points are missing, or the drawing cannot be written, it is judged to be prohibited from modification.
[0009] Optionally, the generation of the immutable operation plan includes: For each object that passes automatically, a unique translation vector is calculated based on the difference between the authoritative target anchor point and the current anchor point. This vector is then applied to all handles within the entity group that need to be moved synchronously. The target number, target elevation, relative position invariants within the group, and state before execution are recorded. The original image summary, preconditions, and postconditions are then frozen and a plan summary is calculated. The plan is generated once before execution, and the target object cannot be guessed again during execution.
[0010] Optionally, the step of verifying the modified drawing in an independent process and outputting the verification results includes: reopening the modified drawing in an independent process, reading the entity status one handle at a time according to the operation plan, verifying whether the anchor point coordinate error, number and elevation attribute error and relative position error within the group are within the tolerance, and checking the change in the number of prohibited modification categories, the number of CAD audit errors and the original hash; If all conditions are met, mark the result as passed; otherwise, output the failure handle, expected value, measured value, and failure stage.
[0011] To address the aforementioned technical problems, this invention also provides a reliable correction system for construction CAD drawings based on AI agents, comprising: The task orchestration and access control module is used to acquire natural language tasks, authoritative data records, and existing CAD drawings; The data standardization module is used to generate a standard record set based on the authoritative data records; The CAD perception and indexing module is used to identify multiple entities that constitute the same construction object in the existing CAD drawings and generate a set of entity groups. The matching and risk classification module is used to construct a candidate cost matrix based on the standard record set and the entity group set, solve the global one-to-one correspondence, select the candidate entity group with the smallest comprehensive matching cost as the optimal candidate, select the candidate entity group with the second smallest comprehensive matching cost as the suboptimal candidate, use the difference between the two comprehensive matching costs as the candidate gap, and perform confidence classification based on the absolute cost of the optimal candidate, the candidate gap and the integrity of the entity group, and output the judgment of automatic approval, manual review or prohibition of modification. The execution planning module is used to generate immutable operation plans only for objects that pass automatically. The plan includes a set of handles to the entities to be modified, the pre-execution state, and the target state. The deterministic execution module is used to perform modifications on the drawing copy according to the operation plan, with the success criterion being that the actual state reaches the target state. The Independent Verification and Reporting module is used to verify modified drawings in an independent process and output the verification results.
[0012] On the other hand, the present invention also provides an electronic device including a memory, a processor, and a computing program stored in the memory and executable on the processor, wherein the processor implements the method when executing the computing program.
[0013] On the other hand, the present invention also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the method.
[0014] Compared with the prior art, the present invention has the following advantages and technical effects: This invention constructs a group of construction object entities consisting of wellhead symbols, numbered text, elevation frames, and elevation text, using CAD handles as stable identifiers. This ensures that all constituent entities of the same construction object are synchronously identified and modified, effectively avoiding omissions or errors caused by identifying only a single element in existing technologies. By fusing coordinates, elevations, semantics, topology, and group integrity into a candidate cost matrix and employing global one-to-one optimization with mismatch penalties, the correspondence problem when old and new numbers are inconsistent is resolved, while preventing conflicts caused by multiple records repeatedly occupying the same object. Through confidence grading and a three-state gating mechanism, automatic execution is only allowed when the absolute cost, candidate gap, displacement upper limit, and group integrity all meet the hard conditions, leaving low-confidence and ambiguous objects for manual review, reducing the risk of erroneous drawing modifications in pursuit of automation rates. By using the actual entity state reread after execution rather than the command return value as the success criterion, and supporting automatic switching to the entity-level execution backend when false success is observed, the shortcomings of existing solutions where logs are inconsistent with the actual state are overcome. By independently reopening the drawing, six levels of verification are performed: object level, group level, attribute level, drawing level, file level, and CAD health. The results are compared with the original document hash, forming a complete and traceable chain of evidence from the data source to the output file. Attached Figure Description
[0015] The accompanying drawings, which form part of this application, are used to provide a further understanding of this application. The illustrative embodiments and descriptions of this application are used to explain this application and do not constitute an undue limitation of this application. In the drawings: Figure 1 This is a schematic diagram of the method flow according to an embodiment of the present invention; Figure 2 This is a schematic diagram of the system structure according to an embodiment of the present invention. Detailed Implementation
[0016] It should be noted that, unless otherwise specified, the embodiments and features described in this application can be combined with each other. This application will now be described in detail with reference to the accompanying drawings and embodiments.
[0017] It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases the steps shown or described may be executed in a different order than that shown here.
[0018] Example 1 like Figure 1 As shown, this embodiment provides a reliable correction method for construction CAD drawings based on AI agents, including: Acquire natural language tasks, authoritative data records, and existing CAD drawings; A standard record set is generated based on the authoritative data records; Identify multiple entities that constitute the same construction object in the existing CAD drawings and generate a set of entity groups; Construct a candidate cost matrix based on the standard record set and the entity group set, solve the global one-to-one correspondence, select the candidate entity group with the smallest comprehensive matching cost as the optimal candidate, select the candidate entity group with the second smallest comprehensive matching cost as the suboptimal candidate, and use the difference between the comprehensive matching costs of the two as the candidate gap. Confidence levels are determined based on the absolute cost, candidate gap, and entity group integrity of the optimal candidate, and a decision is output that allows automatic approval, manual review, or prohibition of modification. An immutable operation plan is generated only for objects that pass automatically. The plan includes a set of handles to the entities to be modified, a pre-execution state, and a target state. According to the operation plan, modifications are made to the copy of the drawing, and the success criterion is that the actual state reaches the target state. Verify the modified drawings in an independent process and output the verification results.
[0019] In one specific implementation, the method is performed according to the following procedure.
[0020] First, it receives natural language tasks and multiple source files from user input, while clearly defining the authoritative data source, target object category, allowed modification range of attributes, and prohibited modification items.
[0021] Next, the authoritative data source is parsed to identify its header, worksheet, object type, number, coordinate and elevation fields, and to check for missing values, duplicate values and outliers in the data.
[0022] Then, based on the known coordinate range or selected control points, determine the coordinate axis mapping relationship, unit scale, and translation or rotation parameters, and record the corresponding transformation parameters.
[0023] Subsequently, the handles, types, layers, text content, insertion points, vertices, and topological relationships of entities in the CAD drawings are read, and a spatial semantic index is built accordingly.
[0024] Based on this, the entity group corresponding to the construction object is constructed according to the layer, block name, text mode, geometric anchor point and relative position template.
[0025] Subsequently, a local candidate set is generated for each authoritative record, and a cost matrix is constructed that includes factors such as spatial distance, attribute differences, semantic consistency, topological relationships, and entity group integrity.
[0026] Next, solve the one-to-one assignment problem with unmatched penalty terms, and perform confidence grading based on absolute cost, candidate gap, conflict situation and entity group integrity.
[0027] Next, immutable operation plans are generated only for objects with high confidence levels, while manual verification materials are generated for objects that require review, and automatic processing of low-confidence objects is prohibited.
[0028] Then, handle-based modification operations are performed on the original image copy, and the entity status is read in real time; when the preferred execution backend has not undergone any actual changes, the system automatically switches to the entity-level backend to continue execution.
[0029] Afterwards, the modified drawing is saved as a new file, and the drawing is reopened through a separate process to verify the target coordinates, relative relationships, text values, number of entities, drawing audit information, and file hash value.
[0030] Finally, output the revised drawings, approved list, pending list, before-and-after comparison chart, and complete audit trail.
[0031] In this embodiment, the identification of the construction object entity group is achieved in the following manner.
[0032] First, using existing CAD drawings in DWG or DXF format as input, the handle, entity type, layer, text content, block insertion point, polyline vertex, and pipeline connection relationship of each entity are read to establish a CAD semantic index that can be searched by spatial range, text pattern, and topological relationship.
[0033] Then, select the wellhead block or elevation frame from the index as the anchor point, and combine the wellhead symbol, well number text, elevation frame, well bottom elevation text, ground elevation text, and optional associated pipelines into a construction object entity group according to layer affiliation, entity type, text mode, fixed relative offset, and pipeline adjacency rules. Output entity group G with a unique set of handles. j .
[0034] For the j-th construction object, its corresponding entity group can be represented as: (1) Among them, e symbol Symbol for wellhead or structure, e label The numbered text, e frame e represents the elevation box bottom and e ground These represent the bottom elevation text and the surface elevation text, respectively. pipe* This represents an optional set of associated pipelines.
[0035] If, during the grouping process, a key role is missing, the same handle is used repeatedly, or local candidates are not unique, the entity group will be marked as an incomplete entity group and transferred to the manual review stage, without being forced into grouping.
[0036] The identification of the entity group does not rely on a single block name, but rather uses a combination of the following pieces of evidence for determination: First, layer evidence, which is to determine whether the entity is located on the target professional layer or its allowed synonym layer; Secondly, type evidence, which is determined based on the combination of entity types such as INSERT, TEXT / MTEXT, LWPOLYLINE, CIRCLE; Third, semantic evidence, which is determined based on the regular expression pattern of the hash symbol, the format of the elevation number, the block name, or extended attributes; Fourth, geometric evidence, namely, the determination is based on the coincidence or fixed offset relationship between the symbol insertion point and the base point of the elevation frame, and the fixed position of the text relative to the base point of the frame; Fifth, topological evidence, which is determined based on pipeline endpoints, nearest connection points, upstream and downstream adjacency relationships, and the same arrangement sequence; Sixth, stable identity evidence, that is, each entity is ultimately recorded with a CAD handle to avoid reselection based on fuzzy conditions during execution.
[0037] Furthermore, when the CAD's built-in search function can locate the number, the search result is used as a high-weight semantic candidate in the judgment; when the old number and the new number are inconsistent, the search function is only used to locate the old object or verify the entity group, and does not directly establish a correspondence between the old and new numbers. The visual API is only used to assist in identifying the object type or drawing frame in the screenshot, and is not the sole source for obtaining precise coordinates and entity handles.
[0038] In this embodiment, the structural composition of the CAD semantic graph is implemented in the following manner.
[0039] First, each CAD entity with a unique handle is constructed as a node v in the diagram, and the adjacency relationships, anchor point colocation relationships, fixed relative offset relationships, text subordination relationships, and pipeline endpoint connection relationships between entities are constructed as relationships with type r. uv The edges are used to form a heterogeneous semantic graph H.
[0040] Then, within the local neighborhood of the heterogeneous semantic graph H, a role-constrained subgraph search is performed using wellhead blocks or elevation frames as anchor points. This search requires key roles such as numbered text, bottom elevation text, and surface elevation text to satisfy both quantity uniqueness constraints and relative position template constraints, ultimately outputting entity group G. j And its completeness.
[0041] Specifically, CAD drawings are represented as a heterogeneous semantic graph H=(V,E,R). Each node v in V corresponds to a CAD entity with a unique handle; E represents the spatial or topological relationship between entities; and R represents the relationship type. The entity types of the nodes include at least INSERT, TEXT / MTEXT, LWPOLYLINE, CIRCLE, and LINE. The relationship types include at least proximity relationships, anchor point colocation relationships, text belonging to elevation frames, pipeline endpoint connection relationships, same-layer relationships, and fixed relative offset relationships.
[0042] The initial feature vector x of each node v v Construct according to the following formula: (2) Among them, t v Indicates the CAD entity type, l v Represents a layer, s v Represents text content, block names, or attribute strings, g v =[x,y,w,h,φ,n vert ] represents the coordinates, bounding box size, rotation angle, and number of vertices, τ v =[deg,d in ,d out ,d anchor ] represents connectivity, inflow, outflow, and distance from the anchor point. onehot() represents sparse coding, and emb() represents dense vector.
[0043] The edges E in the heterogeneous semantic graph H are constructed according to the following formula: (3) Where dbbox represents the spatial distance between the bounding boxes of two entities, Topo represents the connection relationship between CAD entities, RelTemplate represents whether two entities satisfy the relative position template between numbered text, elevation box and elevation text, and r0 is the local search radius set according to the drawing scale.
[0044] In the preferred implementation that does not require training data, the system directly utilizes entity type, layer affiliation, text mode, anchor point position, and fixed offset rules to perform subgraph search on the semantic graph: first, a wellhead block or elevation frame is selected as the anchor point; then, the unique corresponding numbered text, well bottom elevation text, and ground elevation text are searched in the local neighborhood; finally, entity group G is formed by the handle set. j When the above rules fail to meet the uniqueness requirement, the system will not force the group to be combined, but will instead mark it as an incomplete entity group.
[0045] In this embodiment, as an optional enhancement, the system can employ a CAD entity graph attention network to assist in entity group recognition. The specific implementation is as follows.
[0046] The system encodes the entity types, layer affiliations, text or block names, geometric quantities, and topological quantities read in the preceding steps into node features, and constructs a relationship graph based on the actual adjacency relationships between CAD entities. This graph is processed by a multi-head graph attention layer, outputting node role probabilities and entity association probabilities. Based on this, the aforementioned entity group construction steps use these probabilities as candidate ranking evidence, which, together with handle uniqueness constraints, key role integrity constraints, and relative position templates, determine the final composition of the entity groups. It should be clearly noted that this network does not directly output coordinate modification commands, and no probability output result may override any hard CAD constraints.
[0047] When the source of drawings is complex, layer naming is not standardized, or symbol templates change significantly, the graph attention network can be configured on top of the rule candidate schemes. This network is not directly used to modify the drawings, but rather outputs node role probabilities and entity association probabilities for use by deterministic group rules. The network consists of a feature encoder, a relationship graph builder, a multi-head graph attention layer, a node role classification head, an entity association prediction head, and a constraint fusion layer.
[0048] The attention coefficient is calculated as follows. For adjacent CAD entity nodes, h is represented as follows. v and h u Its attention score e vu Calculate according to the following formula: (4) Among them, h v and h u r represents the features of adjacent CAD entity nodes. vu The encoding entities represent proximity, co-location, connectivity, and relative positional relationships; || denotes vector concatenation; W is a learnable shared linear transformation matrix (weight matrix); a T Let be the transpose of the learnable attention weight vector 'a'.
[0049] Attention weight α of adjacent entity u to target entity v vu Calculate according to the following formula: (5) Where N(v) represents the local neighborhood of the target entity v in the CAD semantic graph, e vk Let be the unnormalized attention coefficient between the target entity v and some entity k in its neighborhood, where k is the index of any adjacent entity in the local neighborhood N(v) of the target entity v.
[0050] The next level of a node is updated according to the following formula: (6) Among them, W s and W n σ represents the transformation matrices for the self node and the neighbor node, respectively, and σ is the non-linear activation function. The results of multi-head attention are used to obtain the next layer representation through concatenation or average pooling. This is the updated representation of node v at level l+1. This represents the node v at level l itself. Let represent the adjacent node u at the l-th layer.
[0051] The node role probability and entity association probability are calculated according to the following formulas: (7) Where, p v Give the probability that an entity belongs to the categories of wellhead symbol, number text, elevation frame, well bottom elevation text, surface elevation text, pipeline, and others; p vu Give the association probability that two entities belong to the same construction object. For node v, the feature representation h v The transpose of W c W is the learnable weight matrix for the node role classification head. r h is the learnable weight matrix of the entity association prediction head. u Let u be the feature representation of another CAD entity node. sigmoid() is the sigmoid activation function and softmax() is the softmax normalization function.
[0052] As a concrete example of implementation, the network is configured as follows: discrete features are embedded and then concatenated with continuous features to form a 96-dimensional node feature vector x. v The first layer uses a 4-head graph attention mechanism, with each head having 32 dimensions, resulting in a 128-dimensional output after concatenation. The second layer outputs a 64-dimensional node representation h. v The classification header outputs the probabilities of 7 types of roles, and the association header outputs the binary association probabilities. It should be noted that the above dimensional parameters are merely exemplary configurations and do not constitute a limitation on the scope of protection of this invention.
[0053] In this embodiment, the construction and use of the optional graph attention network model are implemented in the following manner.
[0054] The construction and use of this network model are divided into offline and online phases. In the offline phase, training, validation, and test sets are divided according to projects. Engineers label node roles and entity relationships, and complete feature normalization, multi-task training, and project-level security metric evaluation. In the online phase, only models that pass the test are loaded and used to generate or rank entity group candidates. Their output is fused with spatial cost, attribute cost, semantic cost, and topological cost, and is subject to handle conflict constraints, group integrity constraints, and maximum displacement constraints. It should be clearly stated that the output of this model is still a candidate probability or ranking score, not a CAD execution action.
[0055] Specifically, the offline construction of this network model includes the following operations.
[0056] First, the historical CAD drawings are divided into training, validation, and test sets according to the project to avoid similar elements of the same project from entering the training and test sets at the same time; each entity sample saves its handle, entity type, layer affiliation, text content, geometric quantity, and adjacency relationship.
[0057] Secondly, engineers will label each node with a role tag y. v And assign related labels y to entities to indicate whether they belong to the same construction object. vu Unconfirmed or ambiguous samples will not be used as positive labels.
[0058] Then, the coordinates and bounding box dimensions are normalized according to the local scale of the drawing; entity types and layers are encoded using embedded encoding; text semantics can use existing Chinese text encoders, or deterministic encoding using hash symbols and numerical formats.
[0059] Next, after constructing the relationship graph according to the aforementioned formula (3), the graph data is input into the multi-head graph attention network to jointly train the node role classification task and the entity association prediction task; the model output is only used for candidate ranking.
[0060] Then, the probability of the network output is fused with the hard constraints of CAD. The constraint rule is: when the key anchor point is missing, the handle is repeated, the relative position exceeds the limit, or the maximum displacement exceeds the limit, no matter how high the probability of the network output is, it shall not be judged as automatic pass.
[0061] Finally, the F1 score of each node, the entity group integrity rate, and the automatic error pass rate are statistically analyzed according to the project-level test set; among them, the automatic error pass rate must be lower than the project's pre-set safety limit.
[0062] The loss function for the above training process is constructed as follows: (8) Among them, L role Cross-entropy loss for node role classification, Llink For the binary cross-entropy loss of entity association prediction, L rank To ensure that the score of the correct entity group is higher than the ranking loss of the incorrect group, L con The constraint loss is applied to handle conflict, role missing and relative position violation. λ1-λ4 are the weighting coefficients (hyperparameters) of each loss component, used to balance the relative importance of the four loss terms.
[0063] The constraint loss L con The specific calculation is as follows: (9) Among them, I dup Indicates whether there are duplicate handles within the entity group, I miss Indicates whether a key role is missing, E rel ε represents the relative positional error of entities within a group. rel The preset allowable deviation is μ1-μ3, which are the weight coefficients of the three constraint penalties.
[0064] It should be noted that the above graph attention network is an optional implementation, and the essential technology chain of the present invention does not depend on any specific network structure.
[0065] In this embodiment, coordinate semantic recognition and coordinate transformation are implemented in the following manner.
[0066] First, read the worksheet, header, and data rows of the authoritative table, and map the object number, X coordinate, Y coordinate, ground elevation, well bottom elevation, and object type to a standardized record R. i It also performs null value checks, duplicate value checks, abnormal order of magnitude checks, and elevation logic rationality checks on each record.
[0067] Then, using the confirmed control points or the boundary range of the CAD drawings, calculate the coordinate axis exchange, scale, rotation, and translation parameters A and b, and then set the field coordinates p... i Transformed into target coordinates q in CAD coordinate system i When the number of control points is insufficient or the candidate transformations are not unique, the system generates a limited number of candidate transformations for engineers to confirm. Only after confirmation can the transformation parameters be frozen and the subsequent entity matching stage begin.
[0068] Specifically, let the two-dimensional coordinates in the i-th on-site record be... Its corresponding coordinates in the CAD coordinate system are ,in, The horizontal axis is two-dimensional. The vertical axis is two-dimensional. This represents the corresponding x-coordinate in the CAD coordinate system. Here, 's' represents the corresponding ordinate in the CAD coordinate system, and 's' represents the actual coordinate system. The system first estimates the two-dimensional affine transformation matrix A and the offset vector b based on the field's numerical magnitude, control points, or confirmed corresponding objects, and then transforms all field records to the CAD coordinate domain. (10) Where A∈R^ (2×2) Used to describe X / Y coordinate axis swapping, scaling, and rotation, b∈R^ 2 Used to describe the translation amount; the transformed q i This refers to the target CAD anchor point used in the subsequent matching process.
[0069] The above transformation parameters are estimated by the following formula: (11) in, and These are control point pairs in the field coordinate system and the CAD coordinate system, respectively. ρ is the Huber function or RANSAC interior point loss function, used to reduce the impact of erroneous control points on the estimation results. As an example, in this embodiment, only the X / Y coordinate semantics are interchanged, where A=[[0,1],[1,0]], b=[0,0]^ T .
[0070] When a sufficient number of control points are lacking, the system does not automatically estimate the free rotation and scaling parameters. Instead, it generates a finite number of candidate transformation schemes by comparing the magnitudes and spatial ranges of the X and Y fields with the boundary frames of the CAD drawings. These schemes are then confirmed and frozen by engineers. This limitation is designed to prevent the coordinate transformation model from absorbing actual construction deviations that should be retained in order to improve fitting accuracy.
[0071] In this embodiment, the candidate distance function directly related to CAD semantics is constructed as follows.
[0072] For each standard authoritative record R i and each legal CAD entity group G j The system reads the following corresponding information: target CAD coordinates q i anchor point a of entity group j The system considers the authoritative elevation values and CAD elevation textual analysis values, object categories and CAD layers, block names and numbers, on-site upstream and downstream relationships and CAD pipeline adjacency relationships, and entity group role completeness. Based on this, the normalized distance d for each item is calculated. p d h d s d t and d g And penalize P according to the weights and hard rules configured for the project. ruleThe combination is the total cost C ij The final output is a cost matrix that can be traced back to the specific source of CAD semantics.
[0073] Specifically, let authoritative record R be established. i Includes target CAD coordinates q i Ground elevation Bottom elevation Object type c i and optional upstream and downstream relationships; CAD entity group G j Includes anchor point a j The resolution values of the two elevation texts and Character completeness Q j and the set of adjacent pipelines N j The system calculates the normalized distance for each of the following items.
[0074] Planar distance d p (i,j) is calculated according to the following formula: (12) Where, q i For the target CAD coordinates in the record, a j σ is the anchor point for the CAD entity group. p The preset location error scale for the project.
[0075] Elevation distance d h (i,j) is calculated according to the following formula: d h (i,j)=(| - |+| - |) / σ h (13) in, and These are the recorded ground elevation and well bottom elevation, respectively. and These are the ground elevation and well bottom elevation obtained from CAD elevation text analysis, respectively, σ h This is the preset elevation error scale.
[0076] Semantic distance d s (i,j) is calculated according to the following formula: (14) Where e(·) is an existing text encoder or deterministic semantic encoding function, whose input comes directly from well-type information, old and new numbering, CAD layers, text content, and block names, c i For object type, id iFor authoritative records The object number in the layer j For CAD entity groups The layer it belongs to, text j For CAD entity groups The text content in the block j For CAD entity groups The block name.
[0077] Topological distance d t (i,j) is calculated according to the following formula: (15) Where, N i It consists of the upstream and downstream relationships in the dotted line table, N j It consists of the connection relationships of CAD pipeline endpoints; when no topology data exists, the weight of this item is reset to zero.
[0078] Entity group integrity penalty d g (j) Calculated according to the following formula: (16) Here, Roles represents the set of roles consisting of wellhead symbols, numbered text, elevation frames, bottom elevation text, and surface elevation text; key roles are given greater weight ω r , r∈Roles is the role index variable for traversing the role set Roles, I[r∈G j ] is the indicator function (0 / 1 variable), Σ(r∈Roles)ω r ·I[r∈G j ] is entity group G j The actual weighted score includes the character's score, Σrω r The sum of the weights of all roles is used as the normalized denominator.
[0079] Overall Cost C ij The above distances and hard rule penalties are weighted and combined according to the following formula: C ij =w p ·d p +w h ·d h +w s ·d s +w t ·d t +w g ·d g +w r ·P rule (17) Among them, C ij Indicates authoritative record Ri With CAD entity group G j The overall matching cost between the two; the smaller the value, the more matched they are. d p For the cost of planar distance, d h To account for the cost of elevation difference, d s As the cost of semantic inconsistency, d t For the cost of topological inconsistency, d g For incomplete entity sets, P rule As a hard rule penalty item, w p The weighting coefficient for planar distance cost; w h w is the weighting coefficient for the elevation difference cost. s w represents the weighting coefficient for the semantic inconsistency cost. t w is the weighting coefficient for the cost of topological inconsistency. g The weighting coefficient for the incomplete entity group penalty; w r This represents the weighting coefficient for hard rule penalty items.
[0080] In this embodiment, global one-to-one optimization with unmatched states is implemented as follows.
[0081] Using the cost matrix C output from the preceding steps as input, the system adds an unmatched variable and its corresponding unmatched penalty to each authoritative record and each CAD entity group. Under the constraint that "each record corresponds to at most one entity group, and each entity group is occupied by at most one record," the system solves for the globally minimum cost allocation. This solution process outputs the optimal correspondence, unmatched records, unmatched entity groups, and suboptimal candidates for each record. This global optimization method avoids the duplicate occupation problem that may be caused by nearest-neighbor matching and provides a unified candidate space for subsequent candidate gap calculations.
[0082] Specifically, let x ij ∈{0,1} represents the authoritative record R i Is it related to CAD entity group G? j Establish a correspondence, u i and v j These represent records or entity groups that remain unmatched. The above assignment does not involve taking the nearest neighbor for each record, but rather performs a global solution simultaneously across the entire candidate graph.
[0083] The objective function is as follows: (18) Among them, C ij For authoritative record R i With CAD entity group G jThe overall matching cost between them (calculated by Equation 17) reflects the degree of overall difference between the two in terms of space, elevation, semantics, topology and integrity; x ij For a binary decision variable, x ij ∈{0,1} represents the authoritative record R. i Is it related to CAD entity group G? j Establish a correspondence (1 for establishing, 0 for not establishing); u i Let R be a binary variable representing the authoritative record. i Whether to maintain the unmatched state (1 for unmatched, 0 for matched); v j It is a binary variable representing the CAD entity group G. j Whether to maintain the unmatched state (1 for unmatched, 0 for matched); λ u To record the penalty for mismatches, the system controls the tolerance of authoritative records for which no corresponding relationship can be found; its value is lower than the cost of high-risk mismatches, so that the system would rather retain unresolved objects than force a match. λ v For entities that are not matched, this is the control system's tolerance for CAD entity groups that cannot find a corresponding relationship; The constraints are as follows: (19) Where, x ij For a binary decision variable, x ij ∈{0,1} represents the authoritative record R. i Is it related to CAD entity group G? j Establish a correspondence (1 indicates establishing a correspondence, 0 indicates not establishing a correspondence); u i Let R be a binary variable representing the authoritative record. i Whether to maintain the unmatched state (1 indicates unmatched, 0 indicates matched); v j It is a binary variable representing the CAD entity group G. j Whether to maintain the unmatched state (1 indicates unmatched, 0 indicates matched); The first set of constraints ensures that each field record corresponds to at most one CAD entity group, and the second set of constraints ensures that each CAD entity group is occupied by at most one record.
[0084] The optimization problem described by the above formulas (18) to (19) can be solved using the Hungarian algorithm, the minimum cost flow algorithm, or the integer programming algorithm. It should be noted that the above-mentioned solution algorithms are existing technologies. The present invention uses the output results of the above algorithms as input for subsequent candidate gap calculation, handle-level operation plan generation, and closed-loop verification.
[0085] In this embodiment, confidence grading and risk gating are implemented in the following manner.
[0086] For each pair of optimal candidates obtained in the aforementioned steps, the system simultaneously performs checks on the following hard conditions: the absolute cost of the optimal candidate, the candidate gap between the optimal and second-best candidates, the maximum allowable displacement, the integrity of the key roles in the entity group, whether there are handle conflicts, and whether the magnitude of the coordinate values is normal.
[0087] For each pair of optimal candidates obtained in the aforementioned steps, the system simultaneously performs checks on the following hard conditions: the absolute cost of the optimal candidate, the candidate gap between the optimal and second-best candidates, the maximum allowable displacement, the integrity of the key roles in the entity group, whether there are handle conflicts, and whether the magnitude of the coordinate values is normal.
[0088] Based on the inspection results, the system outputs three judgment statuses.
[0089] The first state is "automatic passage". When the optimal cost is lower than the preset safety threshold, the planar displacement does not exceed the maximum allowable value, the gap between the optimal and suboptimal candidates reaches the set threshold, the entity group is complete and there is no one-to-many conflict, the system determines the object to pass automatically, generates an operation plan accordingly, and allows it to enter the batch execution stage.
[0090] The second status is "manual review". When the candidate gap is insufficient, the objects are densely distributed in a local area, the entity group is missing a non-critical role entity, or there are interpretable ambiguities in the coordinate transformation and numbering, the system will determine the object to be manually reviewed and generate a local screenshot, candidate list and difference description, waiting for engineer confirmation.
[0091] The third state is "Modification Prohibited". When the displacement exceeds the maximum allowable value, the coordinate order of magnitude is abnormal, there are no valid candidates, the key anchor points of the entity group are missing, or the drawing and file status is unsafe, the system will determine that the object is prohibited from modification, and will not generate any modification action, but will only record the reason for prohibition.
[0092] The above three-state determination results constitute the direct input for the subsequent generation of the operation plan.
[0093] Specifically, let j be the authoritative record R. i If j1 is the optimal candidate entity group and j2 is the second-best candidate entity group, then the candidate gap Δi = C. i,j2 -C i,j Where Δi represents the authoritative record R i The candidate gap, C i,j2 Indicates authoritative record R i With the second-best candidate entity group G j2 The overall matching cost between them, Ci,j Indicates authoritative record R i With the optimal candidate entity group G j The overall matching cost between them. Let Q be... j R represents the completeness of an entity group. ij This represents the risk level of the rule. The system first calculates the continuous confidence score using the following formula: (20) In the formula, S i Indicates authoritative record R i The continuous confidence score between the best candidate entity group and the optimal candidate entity group, where β0 is the bias term, β c C represents the weighting coefficients for the optimal cost. i,j* Indicates authoritative record R i With the optimal candidate entity group G j The overall matching cost between them, β Δ Δi represents the weighting coefficient for the candidate gap. A larger Δi (a more significant difference between the optimal and second-best) results in a higher confidence score, indicating a stronger exclusiveness of the match. β g Q is the weighting coefficient for the completeness of the entity group. j The higher the score (the more complete the entity group), the higher the confidence score. Q j G represents the optimal candidate entity group. j Completeness measures the extent to which key elements (wellhead symbol, number text, elevation frame, bottom elevation text, surface elevation text) are present in the entity group. β r R is the weighting coefficient for the rule risk quantity. i,j* The larger the value (the higher the risk), the lower the confidence score; therefore, a negative sign is used before this term. R i,j* Indicates authoritative record R i With the optimal candidate entity group G j The risk level of the rules reflects the degree of risk of violating hard rules such as coordinate anomalies, well-shaped conflicts, layer prohibitions, or handle duplication.
[0094] Among them, S i The larger the value, the more sufficient the comprehensive matching evidence between the authoritative record and the entity group; the parameter β can be calibrated by historical confirmed samples or directly set by engineering rules.
[0095] The system then determines whether automatic execution is allowed using the following formula: (twenty one) Auto i For authoritative record R i The result of the determination of whether automatic execution is allowed (1 for allowed, 0 for disallowed); T s C is the confidence score threshold; i,j For authoritative record R i With the optimal candidate entity group Gj The overall matching cost (calculated according to Formula 17); T abs The absolute cost safety threshold; T gap q is the candidate gap threshold; i For authoritative record R i The target CAD anchor point is obtained after transforming the on-site coordinates; a j For the optimal candidate entity group G j The current CAD anchor point; ||q i -a j* || represents the planar displacement distance between the authoritative target anchor point and the current CAD anchor point; T move Q represents the maximum allowable displacement. j* For the optimal candidate entity group G j The completeness of the condition (1 for complete, 0 for incomplete); I[·] is an indicator function, which takes the value of 1 if all conditions within the parentheses are met, otherwise it takes the value of 0; ∧ is the logical AND operator.
[0096] Only when Auto i The automatic execution process can only begin when the value is 1; if any of the above hard conditions are not met, the continuous confidence score must not cover or bypass the security constraints.
[0097] Based on the above judgment logic, when Auto i When =1, the correspondence enters the automatic pass state; when a candidate relationship exists but only the candidate gap is insufficient or the group completeness is insufficient, the correspondence enters the manual review state; when the coordinate order of magnitude is abnormal, the displacement exceeds the upper limit, the key anchor point is missing, or the drawing cannot be written, the correspondence enters the prohibited modification state.
[0098] The above thresholds can be calibrated using historical manually verified samples, but any adjustment of the thresholds based on the learning results must not bypass or exceed the user's pre-set hard safety limit.
[0099] In this embodiment, the generation of an immutable operation plan is implemented in the following manner.
[0100] The system only generates operation plans for correspondences that have been determined to be of high confidence and are allowed to be automatically processed through risk gating. For each construction object that passes the determination, the system reads the handle set of its entity group and the actual state before execution, calculates the target anchor point, overall translation amount, target number, and target elevation based on authoritative records, and freezes the preconditions, post-verification conditions, rollback basis, and evidence summary to form an immutable operation plan P and outputs it.
[0101] For objects that are determined to require manual review or are prohibited from modification, the system only outputs the corresponding evidence materials and does not generate any CAD modification actions.
[0102] The operation plan is generated and frozen once before execution, and the executor must not re-guess or change the target object during operation. Each operation plan must contain at least the following information: The first piece of information is the record identifier and entity group identifier, used to identify the corresponding authoritative record and CAD entity group.
[0103] The second piece of information is a set of handles, which is a set of handles for precise CAD entities such as wellhead symbols, numbered text, elevation frames, and elevation text.
[0104] The third piece of information is the pre-execution state, namely the coordinates, text content, relative position, layer status, and entity type of each entity before execution.
[0105] The fourth piece of information is the target status, namely the target coordinates, target elevation, and the relative geometric relationship that should be maintained after modification.
[0106] The fifth piece of information is the translation vector and attribute modification amount, that is, the overall translation amount of the entity group and the specific modification value of each attribute.
[0107] The sixth piece of information is the prerequisite, that is, the conditions that must be met before execution, including the availability of a copy of the drawing, the consistency of the original hash, the existence of the target handle, the absence of drift in the original state, and the ability to temporarily unlock the layer.
[0108] The seventh piece of information is the post-verification condition, which is the condition that must be met after execution, including that each entity reaches the target state, the total number of entities is not abnormal, and the prohibited modification items have not been changed.
[0109] The eighth piece of information serves as the basis for rollback, that is, the basis used to restore the copy or revoke the transaction when execution fails.
[0110] The ninth piece of information is an evidence summary, namely the matching cost, candidate gap, data source used, and approval records.
[0111] For each matching pair (i,j) determined to be automatically approved, the system uses the target anchor point q in the authoritative record. i Subtract the current anchor point a of the CAD entity group j This yields a unique translation vector, which is then applied to the entity group G. j All entities within the group that need to be moved synchronously. Simultaneously, the system records the target number, target elevation, relative position invariants within the group, pre-execution state, and verification tolerance.
[0112] Specifically, let entity group G j Any entity e in the array has a position p e Text attributes s e and layer status l e The translation vector is calculated according to the following formula: (twenty two) δ ij For authoritative record R i With CAD entity group G j Translation vector between; q i For authoritative record R i Target CAD anchor point after coordinate transformation; a j For CAD entity group G j The current anchor point; p e' The modified position of entity e; p e The position of entity e before modification; e is entity group G. j Any CAD entity in G; j Let j be the j-th CAD entity group.
[0113] The relative positional error within a group is measured by the following formula: (twenty three) E rel (G j ) is entity group G j The relative position error within the group; e is the entity group G j Any CAD entity in G; j For the j-th CAD entity group; p e' The modified position of entity e; a j' For entity group G j Modified anchor point position (equal to target anchor point q) i ); p e The position of entity e before modification; a j For entity group G j The anchor point position before modification; ||·||2 is the Euclidean norm, used to calculate the change in relative position within the group before and after the move.
[0114] The summary of the operation plan is calculated using the following formula: P k =Hash(D0,H k B k ,T k C k )(twenty four) Where D0 is the original image summary, H k B is a set of handles. k For the state before execution, T k For the target state, C k These are preconditions; the hash value is used to identify whether the plan has been modified or whether the drawing version has drifted.
[0115] In this embodiment, deterministic execution and backend failure switching are implemented in the following manner.
[0116] The executor takes an immutable operation plan P and a copy of the original image as input, locates each entity according to the handles frozen in the plan, and performs coordinate transformations or text attribute modifications based on entity types such as INSERT, TEXT / MTEXT, and LWPOLYLINE. After each operation, the actual state of the target entity is immediately reread to determine whether it meets the observation postconditions set in the plan.
[0117] If the high-level command returns success but the actual entity state does not reach the target state, this situation is recorded as "false success," subsequent operations on the current object are stopped, and the process switches to the lower-level backend that can directly modify entity attributes or DXF group codes. When all available backends fail, the current drawing copy is rolled back and manual review is initiated. The executor ultimately outputs the candidate modified drawing D' and the execution status of each object.
[0118] The executor performs operations only on the drawing copy and selects the preferred backend based on the current operating environment and the type of entity to be modified. For example, interactive commands or COM interfaces can be used in a graphical interface environment, while CoreConsole and AutoLISP interfaces can be used in a batch processing environment. When the preferred backend returns success but the observed postconditions are not met, the system considers it a false success and switches to a lower-level entity-level backend.
[0119] The entity-level backend modifies the corresponding DXF group code according to the specific type of the CAD entity: for INSERT entities, it modifies the insertion point represented by group code 10; for TEXT entities, it maintains both group code 10 and group code 11 under different alignment methods; for LWPOLYLINE entities, it translates all repeating vertices of group code 10; for text content, it modifies group code 1. The target layer can be temporarily unlocked or unfrozen before execution, and the original layer marker is restored after execution. It should be noted that the above group code modification method is only an embodiment under the AutoCAD / DXF platform; other CAD platforms can use object attribute interfaces with equivalent determinism to achieve the same function.
[0120] The final criterion for successful execution is not "no errors reported in the script" or "completion message displayed in the command line," but rather confirming that the coordinates, text content, and relative relationships of the target entity have all reached the target state after rereading the target entity. If any critical entity has not undergone actual change, the system will abort the current batch operation or perform a rollback, and record the backend used, error type, and state differences.
[0121] Specifically, the actuator establishes a state transition function F based on the entity type. type The state transition process is represented by the following formula: (25) X e' The coordinates, text, and layer status of entity e after modification; F type (e) is the state transition function selected based on the entity type; X e The coordinates, text, and layer status of entity e before modification; δ ij For authoritative record R i With CAD entity group G j Translation vectors between them; For authoritative record R i The target number or target elevation in the diagram. Where F... type (e) Perform different transformations based on entity type: For INSERT entities, transform their insertion point; for TEXT entities, simultaneously transform the master point and alignment point under non-default alignment; for LWPOLYLINE entities, transform all their vertices; the content attributes of the elevation text are overridden by the authoritative record.
[0122] The backend selection is performed according to the following formula: (26) b* represents the optimal execution backend selected by the system; b represents the candidate execution backend currently being evaluated; B cap This is a collection of CAD execution backends available in the current environment, including CAD command interfaces, COM interfaces, CoreConsole interfaces, and entity data interfaces; λ R λ represents the weighting coefficient of the risk term; Risk(b,e) is the risk function corresponding to the modification of entity e using backend b; T Here, represents the weighting coefficient for the time term; Time(b) is the estimated time required to complete the execution operation using backend b. The system prioritizes execution backends with lower risk and shorter execution time.
[0123] The postcondition verification is performed according to the following formula: (27) Obs k (b) represents the observation result of whether the postcondition for the k-th operation plan is met using backend b; I(·) is an indicator function that takes the value 1 when the condition in parentheses is met, otherwise it takes the value 0; Read(D',H k ) is the set of handles H k Reread the actual state of entities in the output graph D'; D' is the modified candidate output graph; H k T represents the set of CAD entity handles in the k-th operation plan; k The target state in the k-th operation plan; ||·|| C The comprehensive norm for calculating the error based on coordinates, text, and relative relationships; ε Cis the preset tolerance threshold; ∧ is the logical AND operator, indicating that all conditions within the parentheses must be met.
[0124] When the high-level command returns completion but Obs k When the value is 0, the system determines it as a false success, stops processing the next group of objects, records the failure level, and switches to the entity attribute level backend; if it still fails, the current copy is rolled back and transferred to manual review.
[0125] In this embodiment, independent verification is implemented in the following manner.
[0126] The verification module reopens the candidate modification drawing D′ in a separate CAD process from the execution module. Based on the immutable operation plan, it reads the wellhead anchor points, numbered text, elevation frames, two elevation texts, and associated entities handle by handle, calculating the target coordinate error, intra-group relative position error, and attribute consistency. Furthermore, it verifies the change in the number of prohibited modification entities, performs a CAD audit, and compares the original hash value with the output file hash value.
[0127] The system only outputs verification evidence for the entire batch when all six levels of conditions—object-level, group-level, attribute-level, drawing-level, file-level, and CAD health—are met. If any condition is not met, the system outputs the handle, expected value, measured value, and failure stage of the failed entity.
[0128] Specifically, in object-level verification, it verifies whether the coordinates of the wellhead or structure anchor point are consistent with the target coordinates within the preset tolerance; in group-level verification, it verifies whether the offset of the number text, elevation frame, and elevation text relative to the anchor point maintains the template relationship; in attribute-level verification, it verifies whether the text content of the number, ground elevation, and well bottom elevation is consistent with the authoritative record, and whether the numerical accuracy meets the rules; in drawing-level verification, it verifies whether there are any unexpected increases or decreases in the total number of key entities, and whether prohibited modification objects such as pipelines have changed; in file-level verification, it verifies whether the original hash value remains unchanged and whether the output file is uniquely traceable; in CAD health verification, it confirms through AUDIT or equivalent auditing methods that there are no new database errors in the drawings.
[0129] Only after all the above necessary postconditions are met will the corresponding modification be marked as passed. Any item marked as failed should include the handle, expected value, measured value, and failure stage, and will be transferred to the manual review stage.
[0130] The independent verification process reopens the modified output drawing and calculates the anchor point position error E for each object in the operation plan. pos Number and two types of elevation attribute errors E attr and the relative position error within the group E relSimultaneously check the changes in the number of entities prohibited from modification, the number of CAD audit errors, and the consistency of the original document hash value. When all individual conditions are met, Γ k =1; when all Γ in the plan k When the product is 1 and the original hash value remains unchanged, Γ all =1. Based on this, the system outputs a complete list of passes and failures, and submits the failure handle, expected value, measured value, and evidence file to the subsequent output stage.
[0131] The anchor point position error is calculated according to the following formula: (28) in, The anchor point position read after the output graph is reopened by an independent process, q i The target CAD coordinates are in the authoritative record.
[0132] The attribute error is calculated according to the following formula: (29) Among them, s label' h g' and h b' These are the numbers, ground elevations, and well bottom elevations read from the output diagram, respectively; the numerical precision is standardized according to the project settings when making comparisons.
[0133] The acceptance criteria for a single item shall be determined according to the following formula: (30) Γ k This represents the single-item acceptance judgment result of the k-th operation plan; I[·] is an indicator function, which takes the value 1 when all conditions within the parentheses are met, and 0 otherwise; E pos For anchor point position error; ε p Allowable tolerance for anchor point location; E rel ε represents the relative positional error within the group. rel Tolerances are allowed for relative positions; E attr For the number and the number of errors in the two types of elevation attributes; ΔN forbid To prevent changes in the number of entity categories that cannot be modified; AuditErr represents the number of new errors added in the CAD audit; ∧ is the logical AND operator. When the anchor point position error and the relative position error within the group are both within the tolerance range, the attributes have no error, the number of entities that cannot be modified has not changed, and there are no new errors in the CAD audit, Γ... k A value of 1 indicates that the item has passed the verification.
[0134] The overall acceptance criteria are determined according to the following formula: (31) Γ allThe overall acceptance and judgment result for the entire batch of operation plans; ∏(k∈Plan)Γ k For all individual acceptance results in the plan Γ k The product of Γ, only if each term Γ k When both are 1, the product is 1; Γ k This represents the single-item acceptance judgment result of the k-th operation plan; I[·] is an indicator function, which takes the value 1 when the condition within the parentheses is met, and 0 otherwise; Hash( ) is the hash value of the original drawing after modification (the original state before the modifications were saved); Hash( ) represents the hash value of the original drawing before execution; ∧ represents the logical AND operator, which is applied only when all individual items have passed acceptance and the hash values of the original drawings before and after modification are consistent. all A value of 1 indicates that the entire batch passes.
[0135] The system only outputs a batch pass if all objects in the plan pass verification and the hash value of the original drawing remains unchanged; otherwise, it outputs a failure list and a rollback copy.
[0136] The system achieves human-machine collaboration and interpretable output in the following ways.
[0137] For objects determined to require manual review after confidence level assessment, the system outputs the corresponding authoritative record, optimal and second-best CAD candidates, partial screenshots, various cost components, candidate gaps, and specific reasons for prohibiting automatic processing, for engineers to confirm, reject, or replace candidates. When the engineer's confirmation results in a change in the corresponding relationship, the operation plan must be regenerated and frozen.
[0138] Based on this, the system summarizes the verification results and outputs the modified drawings, the automatic approval list, the pending list, the before-and-after comparison chart, and the complete audit trail, so that every modification can be traced back to the authoritative data source, CAD entity handle, execution backend, and verification conclusion.
[0139] The system provides engineers with task contracts, automatic approval lists, pending review lists, reasons for prohibiting modifications, before-and-after comparison charts, and complete operation audit information. Engineers can confirm, reject, or replace individual candidate relationships. Their confirmation results can be used for threshold calibration in subsequent similar projects, but do not change the frozen operation plan for the current batch; if changes are required, the plan should be regenerated and the approval process should be repeated.
[0140] The specific implementation for generating structured constraints in natural language tasks is as follows.
[0141] The system receives a natural language task T, optional on-site images V, user-submitted CAD files and authoritative data files, and project rules K. It then generates structured task candidates z using a general large language model or a multimodal model. Subsequently, the system performs type validation, enumeration range validation, file existence validation, and security boundary validation on these candidates to clarify the authoritative data source, target object category, allowed modification attributes, prohibited modification items, maximum displacement, and approval requirements. Finally, it outputs a validated task contract. The model can only generate candidate constraints and cannot directly generate CAD modification results with execution permissions.
[0142] The natural language task input by the user is not directly converted into CAD commands, but is first converted into a task contract. Let the natural language text be T, the optional site image be V, the project rules and historical knowledge be K, and the task contract be z. The task contract contains at least the object category C. obj Authoritative data source D auth The set of attributes that can be modified, A allow The set of attributes that cannot be modified, A forbid Maximum displacement threshold T move Candidate gap threshold T gap Coordinate tolerance ε p And whether manual approval is required (marked H) review .
[0143] The above process can be represented as: (32) z hat The structured task candidates are output after verification; z is the structured task candidate variable generated by the model; P θ (z|T,V,K) represents the probability distribution of model parameters θ given a natural language task T, a scene image V, and item rules K; T is the user-input natural language task text; V is the optional scene image; K represents item rules and historical knowledge; argmax z To find the probability P θ The largest possible value of the variable z; | represents the conditional probability symbol. hat Only structured task candidates are generated, and they can only take effect after passing the validation of field type, enumeration range, and security constraints.
[0144] In this embodiment, GPT or Qianwen Vision API are existing general models used to identify user intent, wellhead candidates in screenshots, and field names. The model's output does not directly provide precise CAD coordinates and entity handles; coordinates must originate from authoritative surveying records, and handles must be read from CAD entity indexes. Thus, the uncertainty of the probabilistic model is limited to the candidate generation stage, preventing it from spreading to the deterministic modification stage.
[0145] The technical contribution of this invention lies in: using the construction authority record as the target state and the CAD handle entity group as the modification object; constructing a global one-to-one correspondence using CAD semantic distance; forming an unbypassable three-state gating system using candidate gaps, group integrity, and maximum displacement; freezing the handle, pre-execution state, target state, and verification rules into an operation plan; detecting false success of high-level commands and switching the backend using the real entity state; and finally closing the evidence chain through independent reopening, relative position, attributes, entity counting, CAD auditing, and original hash.
[0146] On the other hand, this embodiment also provides an electronic device, including a memory, a processor, and a computing program stored in the memory and executable on the processor, wherein the processor implements the method when executing the computing program.
[0147] On the other hand, this embodiment also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the method.
[0148] Example 2 This embodiment provides a reliable correction method for construction CAD drawings based on AI agents, including: Taking the update of the sewage well locations and elevations on a school's existing pipeline survey map as an example. The input includes the on-site point and line table "Sewage Point and Line Table 1.xlsx of a Certain Middle School" and the existing drawing "01 Existing Pipeline Survey Map of a Certain First Middle School.dwg". The user explicitly requires that only the sewage well openings and their numbers, elevation frames, and elevation text that can establish a reliable correspondence be modified, without adding or deleting wells or modifying pipelines.
[0149] The valid area for the point table is A1:AA278, and for the line table it is A1:AC195. The system filters non-empty points by wastewater category, identifies structures and straight lines, and then excludes septic tanks based on user objectives. By comparing the data magnitude and spatial distribution, the system determines that the CAD x-axis corresponds to the Excel field "Y" (approximately 500,000 data points), and the CAD y-axis corresponds to the Excel field "X" (approximately 3,090,000 data points). This mapping is written into the task contract as an explicit transformation parameter to avoid relying on the intuitiveness of field names.
[0150] In CAD, old well numbers use the format A22W..., while in Excel, new well numbers use the format 1WS..., making direct lookup impossible. The system still uses CAD lookup / text indexing to locate all old well numbers, then constructs entity groups using the wellhead block and elevation frame base points as anchor points. In this embodiment, each elevation frame base point is the same as the wellhead block insertion point; the expected positions of the two elevation texts relative to the base points are (x+1.57095, y+0.6) and (x+1.57095, y+1.160335), respectively. These relative relationships are used to identify group members and verify whether overall consistency is maintained after movement.
[0151] The system uses planar distance as the primary feature, superimposed with ground elevation difference, wellbore elevation difference, and entity group integrity to construct a cost matrix, and completes the allocation one-to-one using the Hungarian algorithm. Safety gates are set with a planar movement distance not exceeding 5m, a gap between local optimal and suboptimal candidates not less than 0.3, and require handle group integrity. Ultimately, 51 out of 72 target wellheads entered and passed automatically, while the rest remained pending.
[0152] For example, 1WS152 establishes a correspondence with the old object A22W471, with the old anchor point being (501441.193, 3095607.700) and the target anchor point being (501443.850, 3095603.707), a displacement of approximately 4.796m; the ground elevation is updated from 4.178 to 3.995, and the bottom elevation is updated from 2.818 to 2.675. 1WS143 establishes a correspondence with A22W400, with the old anchor point being (501414.471, 3095635.040) and the target anchor point being (501418.463, 3095636.688), a displacement of approximately 4.319m; the ground elevation is updated from 4.370 to 4.357, and the bottom elevation is updated from 3.170 to 2.937.
[0153] Each plan for an object precisely lists the wellhead block handle, old well number text handle, elevation frame handle, bottom elevation text handle, and surface elevation text handle. The system executes from a clean copy of the original drawings and remains unchanged before and after processing.
[0154] During execution, the target layer's WST status flag is 5 (frozen and locked). The system temporarily sets it to editable within the transaction, modifies the coordinates and text according to entity type, and then restores it to its original state. When moving, the wellhead block, old well number, elevation frame, and two elevation texts use the same translation vector; text values are updated according to authoritative records; and pipeline entities are not in the handle set.
[0155] The modified file was reopened by an independent verification script, and the block coordinates, relative positions of the numbers, elevation frame base points, and positions and values of the two elevation text lines for each of the 51 entity groups were checked one by one. All 51 object groups passed the independent verification. There were a total of 6874 TEXT / MTEXT / INSERT files and 2797 LWPOLYLINE files. The counts were normal before and after the modification. The CAD AUDIT reported 0 errors.
[0156] The results show that all 51 high-confidence objects achieved their planned objectives, objects that failed to pass the risk gate were not forcibly modified, and the original drawings were not overwritten, forming a complete chain of evidence from data source, correspondence, execution plan to output documents.
[0157] Example 3 like Figure 2 As shown, this embodiment provides a reliable correction system for construction CAD drawings based on AI agents, including: The task orchestration and access control module receives user-input natural language tasks and multiple source files (including authoritative data tables, existing CAD drawings, and optional site images). It converts the natural language tasks into structured task candidates using a general large language model or a multimodal model. The module then performs field type validation, enumeration range validation, file existence validation, and security boundary validation on these candidates to clarify the authoritative data source, target object category, allowed modification attributes, prohibited modification items, maximum displacement, and approval requirements. Finally, it outputs a validated task contract. The task contract must contain at least object category C. obj Authoritative data source D auth The set of attributes that can be modified, A allow The set of attributes that cannot be modified, A forbid Maximum displacement threshold T move Candidate gap threshold T gap Coordinate tolerance ε p And whether manual approval is required (marked H) review The output of this module is connected to the data standardization module and the matching and risk classification module.
[0158] The data standardization module receives instructions from the authoritative data source from the task orchestration and access control module, reads the worksheet, header, and data rows of the authoritative table, and maps object number, X coordinate, Y coordinate, ground elevation, well bottom elevation, and object type to standardized records R. i The module performs null value checks, duplicate value checks, anomaly magnitude checks, and elevation logic rationality checks on each record. It also calculates coordinate axis exchange, scaling, rotation, and translation parameters A and b using confirmed control points or the boundary range of CAD drawings, and adjusts the field coordinates p... i Transformed into target coordinates q in CAD coordinate systemi When the number of control points is insufficient or the candidate transformations are not unique, a limited number of candidate transformations are generated for engineer confirmation. The transformation parameters can only be frozen after confirmation. The output of this module is connected to the matching and risk classification module.
[0159] The CAD Perception and Indexing module takes existing CAD drawings in DWG or DXF format as input and reads the handles, entity types, layers, text content, block insertion points, polyline vertices, and pipeline connection relationships of each entity to build a CAD semantic index that can be retrieved by spatial range, text pattern, and topological relationship. This module also constructs each CAD entity with a unique handle as a node v in a heterogeneous semantic graph H=(V,E,R), and constructs the proximity relationships, anchor point colocation relationships, fixed relative offset relationships, text dependency relationships, and pipeline endpoint connection relationships between entities as edges with relationship type ruv. The output of this module connects to the entity group construction module.
[0160] The entity group construction module receives the CAD semantic index from the CAD perception and indexing module, selects wellhead blocks or elevation frames as anchor points from the index, and combines the wellhead symbol, well number text, elevation frame, well bottom elevation text, ground elevation text, and optional associated pipelines into a construction object entity group according to layer affiliation, entity type, text mode, fixed relative offset, and pipeline adjacency rules. It outputs an entity group G with a unique set of handles. j For the j-th construction object, its corresponding entity group can be represented as Gⱼ={e symbol , e label , e frame , e bottom , e ground , e pipe* This module comprehensively utilizes layer evidence, type evidence, semantic evidence, geometric evidence, topological evidence, and stable identity evidence for judgment during the combination process. When a key role is missing, the same handle is repeatedly used, or local candidates are not unique, the entity group is marked as an incomplete entity group and transferred to manual review. The output of this module is connected to the matching and risk classification module.
[0161] As an optional enhancement, the entity group construction module can also be configured with a CAD entity drawing attention network to assist in entity group identification when the drawing source is complex, the layer naming is not standardized, or the symbol template changes significantly. This network consists of a feature encoder, a relationship graph builder, a multi-head graph attention layer, a node role classification head, an entity association prediction head, and a constraint fusion layer. It outputs node role probabilities and entity association probabilities, which, together with handle uniqueness constraints, key role integrity constraints, and relative position templates, determine the final composition of the entity group. The network's output does not directly provide coordinate modification commands, and no probability output result may override CAD hard constraints.
[0162] The matching and risk classification module receives a standard record set R from the data standardization module and an entity group set G from the entity group construction module. It filters out invalid record-entity group combinations according to preset maximum search radius, object type filtering conditions, and prohibition of modifying layers. For each valid combination retained, it calculates the comprehensive matching cost C. ij This forms a candidate cost matrix C. The comprehensive matching cost C... ij Construct according to the following formula: ; Where, d p For the cost of planar distance, d h To account for the cost of elevation difference, d s As the cost of semantic inconsistency, d t For the cost of topological inconsistency, d g For incomplete entity sets, P rule This module is used for hard rule penalty items. It also adds virtual objects representing "temporarily unmatched" and unmatched penalties to the cost matrix, solves the one-to-one correspondence between records and entity groups using the Hungarian algorithm, minimum cost flow algorithm, or other global optimization algorithms, and outputs a correspondence table M, suboptimal candidates for each record, candidate gaps, and unmatched records and unmatched entity groups. Furthermore, for each pair of optimal candidates, it simultaneously checks the absolute cost, candidate gap between the optimal and suboptimal candidates, maximum allowable displacement, integrity of key roles in the entity group, handle conflicts, and coordinate magnitude. Based on the check results, it outputs a three-state decision: "automatic pass," "manual review," or "modification prohibited." The output of this module connects to the execution planning module.
[0163] The execution planning module receives only correspondences deemed "automatically approved" from the matching and risk grading module. It reads the handle set of the corresponding entity group and the actual state before execution, calculates the target anchor point, overall translation amount, target number, and target elevation based on authoritative records, and freezes the preconditions, post-verification conditions, rollback basis, and evidence summary to form an immutable operation plan P, which is then output. The operation plan is generated and frozen once before execution, and each operation plan includes at least: record identifier and entity group identifier, handle set, pre-execution state, target state, translation vector and attribute modification amount, preconditions, post-verification conditions, rollback basis, and evidence summary. For objects deemed "manually reviewed" or "prohibited from modification," this module only outputs the corresponding evidence materials and does not generate any CAD modification actions. The output of this module connects to the deterministic execution module.
[0164] The deterministic execution module receives the immutable operation plan P and a copy of the original drawing from the execution planning module. It locates each entity according to the handles frozen in the plan and performs coordinate transformations or text attribute modifications based on entity types such as INSERT, TEXT / MTEXT, and LWPOLYLINE. This module interacts with the underlying CAD environment through the CAD execution adaptation layer. After each operation, the module immediately rereads the actual state of the target entity to determine if it meets the observation postconditions set in the plan. When a high-level command returns success but the actual entity state does not reach the target state, this situation is recorded as "false success," and the system switches to the underlying backend that can directly modify entity attributes or DXF group codes. When all available backends fail, the current drawing copy is rolled back and manual review is initiated. The output of this module connects to the independent verification and reporting module.
[0165] The independent verification and reporting module reopens the candidate modified drawing D′ in an independent CAD process separate from the deterministic execution module. Based on the immutable operation plan, it reads the wellhead anchor points, numbered text, elevation frames, two elevation texts, and associated entities handle by handle, calculating the target coordinate error, intra-group relative position error, and attribute consistency. It verifies the change in the number of prohibited modified entities, performs CAD auditing, and compares the original document hash value with the output file hash value. This module outputs verification evidence for the entire batch passing when all conditions at six levels—object level, intra-group level, attribute level, drawing level, file level, and CAD health—are met; otherwise, it outputs the handles, expected values, measured values, and failure stages of the failed entities. This module also outputs authoritative records, optimal and second-best CAD candidates, partial screenshots, various cost components, candidate gaps, and specific reasons for prohibiting automatic processing for objects determined to require manual review, allowing engineers to confirm, reject, or replace candidates. Finally, this module outputs the modified drawing, the automatically passed list, the pending list, a before-and-after comparison diagram, and the complete audit trail.
[0166] The CAD execution adaptation layer connects the deterministic execution module with various CAD backends. It selects the appropriate execution backend from the CAD command interface, COM interface, Core Console interface, and entity data interface based on the current operating environment and the type of entity to be modified, and converts the unified operation plan from the upper layer into executable instructions for each backend. This adaptation layer enables the system to be compatible with various engineering design platforms such as AutoCAD, GstarCAD, ZWCAD, and MicroStation.
[0167] Preferably, the independent verification and reporting module is deployed as an independent process or an independent container, running in a different computing environment from the deterministic execution module, to ensure the independence and objectivity of the verification process.
[0168] Preferably, the large language model or multimodal model in the task orchestration and access control module is only used to generate structured task candidates and does not directly output precise CAD coordinates and entity handles; the coordinates must come from authoritative surveying records and the handles must be read from the CAD entity index, thereby limiting the uncertainty of the probabilistic model to the candidate generation stage and preventing it from spreading to the deterministic modification stage.
[0169] The above are merely preferred embodiments of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A reliable correction method for construction CAD drawings based on AI intelligent agents, characterized in that, include: Acquire natural language tasks, authoritative data records, and existing CAD drawings; A standard record set is generated based on the authoritative data records; Identify multiple entities that constitute the same construction object in the existing CAD drawings and generate a set of entity groups; Construct a candidate cost matrix based on the standard record set and the entity group set, solve the global one-to-one correspondence, select the candidate entity group with the smallest comprehensive matching cost as the optimal candidate, select the candidate entity group with the second smallest comprehensive matching cost as the suboptimal candidate, and use the difference between the comprehensive matching costs of the two as the candidate gap. Confidence levels are determined based on the absolute cost, candidate gap, and entity group integrity of the optimal candidate, and a decision is output that allows automatic approval, manual review, or prohibition of modification. An immutable operation plan is generated only for objects that pass automatically. The plan includes a set of handles to the entities to be modified, a pre-execution state, and a target state. According to the operation plan, modifications are made to the copy of the drawing, and the success criterion is that the actual state reaches the target state. Verify the modified drawings in an independent process and output the verification results.
2. The method according to claim 1, characterized in that, The generation of the entity group set includes: Based on the entity index, using the wellhead block or elevation frame as the anchor point, the wellhead symbol, numbered text, elevation frame, well bottom elevation text and ground elevation text are combined according to the layer, entity type, text semantics and geometric position. Entities in each group are identified by a unique handle and maintain a fixed offset relative to the anchor point. If a key role is missing, a handle is duplicated, or the relative position deviates from the template, it is marked as an incomplete entity group.
3. The method according to claim 1, characterized in that, The construction of the candidate cost matrix includes: For each combination of a standard record and an entity group, calculate the planar coordinate distance cost, elevation difference cost, semantic inconsistency penalty, topological inconsistency penalty, and group incompleteness penalty respectively. After weighted summation, add hard rule penalties and output cost matrix elements that can be traced back to the CAD semantic source.
4. The method according to claim 1, characterized in that, The solution for the global one-to-one correspondence includes: adding unmatched virtual nodes and unmatched penalties to each standard record and each entity group; solving the global minimum cost allocation under the constraint that each record corresponds to at most one entity group and each entity group is occupied by at most one record; and outputting the optimal correspondence, unmatched records and unmatched entity groups, as well as the suboptimal candidate entity group corresponding to each record.
5. The method according to claim 1, characterized in that, The confidence level includes: Continuous confidence scores are calculated based on optimal cost, candidate gap, group integrity, and rule risk, and then superimposed with hard conditions such as absolute cost threshold, maximum displacement limit, handle uniqueness, key role integrity, and drawing writability. Automatic passage is determined when the optimal cost is lower than the safety threshold, the candidate gap reaches the threshold, the displacement does not exceed the limit, and the group is complete. Candidates exist but are only missing gaps or incomplete groups, and are judged to be subject to manual review; if the coordinates are abnormal, the displacement exceeds the limit, the key anchor points are missing, or the drawing cannot be written, it is judged to be prohibited from modification.
6. The method according to claim 1, characterized in that, The generation of the immutable operation plan includes: For each object that passes automatically, a unique translation vector is calculated based on the difference between the authoritative target anchor point and the current anchor point. This vector is then applied to all handles within the entity group that need to be moved synchronously. The target number, target elevation, relative position invariants within the group, and state before execution are recorded. The original image summary, preconditions, and postconditions are then frozen and a plan summary is calculated. The plan is generated once before execution, and the target object cannot be guessed again during execution.
7. The method according to claim 1, characterized in that, The verification of the modified drawing in an independent process and the output of the verification results include: reopening the modified drawing in an independent process, reading the entity status one handle at a time according to the operation plan, verifying whether the anchor point coordinate error, number and elevation attribute error and relative position error within the group are within the tolerance, and checking the change in the number of prohibited modification categories, the number of CAD audit errors and the original hash; If all conditions are met, mark the result as passed; otherwise, output the failure handle, expected value, measured value, and failure stage.
8. A reliable correction system for construction CAD drawings based on AI intelligent agents, characterized in that, include: The task orchestration and access control module is used to acquire natural language tasks, authoritative data records, and existing CAD drawings; The data standardization module is used to generate a standard record set based on the authoritative data records; The CAD perception and indexing module is used to identify multiple entities that constitute the same construction object in the existing CAD drawings and generate a set of entity groups. The matching and risk classification module is used to construct a candidate cost matrix based on the standard record set and the entity group set, solve the global one-to-one correspondence, select the candidate entity group with the smallest comprehensive matching cost as the optimal candidate, select the candidate entity group with the second smallest comprehensive matching cost as the suboptimal candidate, use the difference between the two comprehensive matching costs as the candidate gap, and perform confidence classification based on the absolute cost of the optimal candidate, the candidate gap and the integrity of the entity group, and output the judgment of automatic approval, manual review or prohibition of modification. The execution planning module is used to generate immutable operation plans only for objects that pass automatically. The plan includes a set of handles to the entities to be modified, the pre-execution state, and the target state. The deterministic execution module is used to perform modifications on the drawing copy according to the operation plan, with the success criterion being that the actual state reaches the target state. The Independent Verification and Reporting module is used to verify modified drawings in an independent process and output the verification results.
9. An electronic device comprising a memory, a processor, and a computing program stored in the memory and executable on the processor, characterized in that, When the processor executes the computing program, it implements the method of any one of claims 1-7.
10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the method of any one of claims 1-7.
