A CAD drawing parameter self-adaptive optimization method based on big data processing

CN122947577APending Publication Date: 2026-10-20HEFEI POWER TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611195951.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-07
Publication Date
2026-10-20

AI Technical Summary

Technical Problem

现有参数优化方式主要依赖参数模板、规则库或同类图纸的统计值,通常按照对象类型独立推荐参数,难以结合连续制图命令识别同一对象的参数变化过程,也难以反映关联对象之间依赖强度的动态变化

Benefits of technology

[0060]1、本发明根据命令作用对象标识建立CAD对象的跨版本对应关系,并依据保存节点和几何状态变化划分制图动作段,使训练样本保留同一CAD对象的连续参数变化及真实几何依赖关系,减少无关联制图命令对参数预测的干扰。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure FT_1
    Figure FT_1
  • Figure FT_2
    Figure FT_2
  • Figure FT_3
    Figure FT_3
Patent Text Reader

Abstract

This invention discloses an adaptive optimization method for CAD drawing parameters based on big data processing, belonging to the field of intelligent data processing technology. The method includes the following steps: S1, obtaining historical CAD drawing versions and drawing logs; S2, establishing the correspondence between the same CAD object and different historical CAD drawing versions; S3, dividing the drawing logs into drawing action segments; S4, constructing object time-series training samples; S5, training an improved MTGNN model and updating the object adjacency matrix of the next propagation level; S6, extracting geometric features and dimensional parameters, inputting them into the trained improved MTGNN model, and obtaining the predicted parameter adjustment amount; S7, writing the predicted parameter adjustment amount into the dimensional parameters or object attributes of the corresponding CAD object; S8, obtaining the CAD drawing with optimized parameters. This invention can improve the accuracy of CAD parameter optimization and reduce constraint conflicts and manual corrections.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of intelligent data processing technology, and in particular to an adaptive optimization method for CAD drawing parameters based on big data processing. Background Technology

[0002] In CAD drafting, parameters such as key point coordinates, length, radius, angle, dimension values, and block insertion scale collectively determine the geometric state of graphic objects. Different objects also exhibit relationships such as collinearity, concentricity, tangency, and dimensional constraints. As drafting tasks continue, CAD systems accumulate a large number of drawing versions and drafting logs, providing a historical data foundation for parameter optimization. Existing parameter optimization methods primarily rely on parameter templates, rule bases, or statistical values ​​from similar drawings. Parameters are typically recommended independently based on object type, making it difficult to identify parameter changes for the same object in conjunction with continuous drafting commands, and also difficult to reflect the dynamic changes in the strength of dependencies between related objects. While some machine learning methods can predict parameter changes, they often employ fixed feature processing sequences and object relationships, easily leading to inconsistent prediction results for related objects. After predicted parameters are written into CAD drawings, constraint conflicts, dimensional relationship failures, or abnormal graphic regeneration may occur, requiring designers to repeatedly check and correct, affecting drafting efficiency and the reliability of parameter optimization results.

[0003] Therefore, how to provide an adaptive optimization method for CAD drawing parameters based on big data processing is a problem that urgently needs to be solved by those skilled in the art. Summary of the Invention

[0004] One objective of this invention is to propose an adaptive optimization method for CAD drawing parameters based on big data processing. This invention establishes cross-version correspondences for CAD objects and divides drawing action segments according to saved nodes and changes in object geometric states, enabling the object's temporal training samples to accurately preserve continuous parameter changes and geometric dependencies of CAD objects. By setting two paths with opposite propagation orders and shared weights in the improved MTGNN model, and updating the object adjacency matrix level by level based on path output differences, the model adapts to changes in object dependency strength during the drawing process, improving the consistency and accuracy of parameter adjustments for associated CAD objects. Simultaneously, by combining parameter writing, geometric constraint solving, graphic regeneration, and transaction rollback, the parameter optimization results are verified, reducing constraint conflicts, dimension association failures, and the number of manual corrections.

[0005] An adaptive optimization method for CAD drawing parameters based on big data processing according to an embodiment of the present invention includes the following steps:

[0006] S1. Obtain historical CAD drawing versions and corresponding drafting logs;

[0007] S2. Based on the command action object identifier in the drawing log and the object record in the historical CAD drawing version, establish the correspondence between the same CAD object in different historical CAD drawing versions;

[0008] S3. Based on the saved nodes and the geometric state changes of CAD objects, the drafting log is divided into drafting action segments;

[0009] S4. Read each historical CAD drawing version, and construct object time-series training samples with CAD objects as nodes, geometric relationships between objects as dependencies, and object parameters as node features.

[0010] S5. Train the improved MTGNN model using the object temporal training samples. The improved MTGNN model sets up two paths with the temporal convolution and hybrid jump graph propagation order reversed and corresponding modules sharing weights. Update the object adjacency matrix of the next propagation stage according to the output difference of the two paths.

[0011] S6. Determine the current drafting action segment from the current drafting log of the CAD drawing to be optimized, extract the geometric features and dimensional parameters of the CAD objects involved in the current drafting action segment, input them into the trained improved MTGNN model, and obtain the prediction parameter adjustment amount of the corresponding CAD object.

[0012] S7. Write the predicted parameter adjustment amount into the dimension parameter or object attribute of the corresponding CAD object according to the object identifier;

[0013] S8. Solve the CAD object with adjusted parameters and regenerate the graphics to obtain the CAD drawing with optimized parameters.

[0014] Optionally, S1 includes:

[0015] S11. Read multiple historical CAD drawing versions for the same drafting task and extract the drawing identifier, version number, and save time for each version.

[0016] S12. Obtain the drafting commands, command execution time, command target identifier, object records before and after command execution, and save nodes corresponding to each historical CAD drawing version, and form the drafting log.

[0017] Optionally, S2 includes:

[0018] S21. Sort historical CAD drawing versions by save time and pair versions with adjacent save times.

[0019] S22. Identify the object record in the index version pair by the command action object in the drawing log;

[0020] S23. Write the preceding and following object records with the same object handle to the same matching record;

[0021] S24. Write a unified cross-version object identifier to the object records in the same matching record to generate an object mapping table.

[0022] Optionally, S3 includes:

[0023] S31. Define the log interval by adjacent storage nodes and arrange the drawing commands within the interval according to the execution time;

[0024] S32. Compare the object records before and after the command execution one by one, and write status change markers for commands that have changed key point coordinates, geometric types or geometric relationships between objects.

[0025] S33. Starting with a command that has a status change marker, write commands that act continuously on the same CAD object or CAD objects with geometric relationships into the same drafting action segment;

[0026] S34. End the current drawing action segment when reaching the next save node or when subsequent commands turn to CAD objects with no geometric relationship.

[0027] Optionally, S4 includes:

[0028] S41. According to the aforementioned correspondence, retrieve the CAD object records before and after the execution of commands within each historical drawing action segment;

[0029] S42. Using CAD objects as nodes, select the corresponding parameters from key point coordinates, length, radius, angle, size values ​​and object attributes according to the object type, and write them into the node features;

[0030] S43. Write dependency edges between nodes that share key points, share geometric datum, are collinear, concentric, tangent, or have dimensional constraints.

[0031] S44. Arrange the node features and dependent edges after each state change according to the command execution time, and sequentially extract the preceding state sequence with each non-terminal state as the end to form a sample sequence. Write the change in object parameters of the map action segment's ending state relative to the corresponding non-terminal state into the sample label.

[0032] Optionally, the improved MTGNN model includes multiple cascaded propagation stages, each of which includes a first temporal convolutional layer, a first hybrid hop graph propagation layer, a second hybrid hop graph propagation layer, a second temporal convolutional layer, and an adjacency update layer.

[0033] The first temporal convolutional layer is connected to the first hybrid jump graph propagation layer, and the second hybrid jump graph propagation layer is connected to the second temporal convolutional layer;

[0034] Two temporal convolutional layers within the same propagation level share weights, and two hybrid jump graph propagation layers share weights.

[0035] The adjacency update layer is connected to the first hybrid jump graph propagation layer, the second temporal convolutional layer, and the current object's adjacency matrix, respectively. The output of the adjacency update layer is connected to the input of the adjacency matrix of the next propagation stage.

[0036] The output features of the first hybrid jump graph propagation layer and the second temporal convolutional layer are element-wise averaged and then written into the next propagation stage.

[0037] Optionally, S6 includes:

[0038] S61. Read the command action object identifier in the current drawing action segment, locate the corresponding CAD object, and read the directly associated objects that have geometric relationships with the corresponding CAD object;

[0039] S62. According to the object type, read the key point coordinates, length, radius, angle, size value and object attributes one command at a time, and generate node feature records;

[0040] S63. Arrange the node feature records according to the command execution time to form a node feature sequence, and encode the geometric relationship between the current CAD objects into the current object adjacency matrix;

[0041] S64. Input the node feature sequence and the current object adjacency matrix into the trained improved MTGNN model, and extract the prediction parameter adjustment amount according to the object identifier.

[0042] Optionally, S64 includes:

[0043] S641. Arrange the node feature sequence according to CAD object, parameter type and command time into a node feature tensor, form an initial node hidden feature tensor through channel mapping, and write it into the first propagation stage along with the current object adjacency matrix.

[0044] S642. The first temporal convolutional layer uses gated dilated temporal convolution to extract temporal features. The first hybrid skip graph propagation layer reads the current object's adjacency matrix and propagates the temporal features. The second hybrid skip graph propagation layer first propagates the node hidden features. The second temporal convolutional layer uses shared weights to perform gated dilated temporal convolution and outputs two sets of node features.

[0045] S643. The adjacency update layer takes the absolute difference of each element of the two sets of node features, splices the difference features of the two end nodes according to the dependent edge, generates the matrix element correction amount through linear mapping, and normalizes the corrected object adjacency matrix.

[0046] S644. The two sets of node features are averaged element by element and used as the hidden node features of the next propagation level, and written together with the corrected object adjacency matrix into the next propagation level.

[0047] S645. The hidden features of the last-level node are converted into parameter adjustment vectors for each node through output mapping, and the predicted parameter adjustment amount is extracted according to the object identifier.

[0048] Optionally, S7 includes:

[0049] S71. Read the object identifier, parameter type and adjustment value corresponding to the predicted parameter adjustment amount, and locate the CAD entity record according to the object identifier;

[0050] S72. According to the CAD object type, map the parameter type to the corresponding dimension value, key point coordinate, radius, angle or object attribute field;

[0051] S73. Read the current parameter value of the corresponding field, add the current parameter value to the adjustment value, and generate the parameter value to be written;

[0052] S74. In the same write transaction, batch update the corresponding fields of each CAD object and record the parameter values ​​before the update.

[0053] Optionally, S8 includes:

[0054] S81. Read the geometric constraint records of the CAD object after parameter adjustment, and divide the constraint solution object group according to the constraint-related objects;

[0055] S82. Set the adjusted CAD object parameters as the driving parameters of the CAD geometric constraint solver, and calculate the key point coordinates and geometric definition parameters of the CAD objects in each object group.

[0056] S83. Write the solution results into the corresponding CAD entity record, and regenerate the graphics for the parameter adjustment objects, constraint associated objects and associated dimensions;

[0057] S84. Read the constraint solution status and the regenerated object record, and verify the geometric relationship and dimension association status corresponding to each CAD constraint;

[0058] S85. If the constraint solution is conflict-free and the verification passes, retain the parameter adjustment results; otherwise, restore the object parameters before parameter adjustment and regenerate the graph.

[0059] The beneficial effects of this invention are:

[0060] 1. This invention establishes cross-version correspondence of CAD objects based on the object identifier of the command, and divides the drawing action segments according to the saved nodes and geometric state changes, so that the training samples retain the continuous parameter changes and real geometric dependencies of the same CAD object, reducing the interference of unrelated drawing commands on parameter prediction.

[0061] 2. In the improved MTGNN model, this invention sets up two paths with opposite propagation order and corresponding modules sharing weights, and updates the object adjacency matrix step by step according to the differences in path output, so that the node feature propagation intensity changes with the CAD object dependency state, thereby improving the consistency and accuracy of the adjustment of associated object parameters.

[0062] 3. This invention writes the predicted parameter adjustment amount into the corresponding CAD object, and combines geometric constraint solving, graphic regeneration and transaction rollback to complete the result verification, thereby reducing constraint conflicts, dimension association failures and manual corrections caused by parameter adjustment. Attached Figure Description

[0063] The accompanying drawings are provided to further illustrate the invention and form part of the specification. They are used in conjunction with embodiments of the invention to explain the invention and do not constitute a limitation thereof. In the drawings:

[0064] Figure 1 This is a flowchart of an adaptive optimization method for CAD drawing parameters based on big data processing proposed in this invention;

[0065] Figure 2 This is a schematic diagram illustrating the construction of object time-series training samples for an adaptive optimization method of CAD drafting parameters based on big data processing proposed in this invention.

[0066] Figure 3 This is a propagation level structure diagram of an improved MTGNN model for an adaptive optimization method of CAD drawing parameters based on big data processing proposed in this invention. Detailed Implementation

[0067] The present invention will now be described in further detail with reference to the accompanying drawings. These drawings are simplified schematic diagrams, illustrating only the basic structure of the invention, and therefore only show the components relevant to the invention.

[0068] refer to Figures 1-3 An adaptive optimization method for CAD drawing parameters based on big data processing includes the following steps:

[0069] S1. Obtain historical CAD drawing versions and corresponding drafting logs;

[0070] S2. Based on the command action object identifier in the drafting log and the object record in the historical CAD drawing versions, establish the correspondence between the same CAD object in different historical CAD drawing versions.

[0071] S3. Based on the saved nodes and the geometric state changes of CAD objects, divide the drafting log into drafting action segments;

[0072] S4. Read each historical CAD drawing version, and construct object time-series training samples with CAD objects as nodes, geometric relationships between objects as dependencies, and object parameters as node features.

[0073] S5. Train the improved MTGNN model using object temporal training samples. The improved MTGNN model sets up two paths with reversed temporal convolution and hybrid jump graph propagation order and corresponding modules sharing weights. Update the object adjacency matrix of the next propagation stage according to the output difference of the two paths.

[0074] S6. Determine the current drafting action segment from the current drafting log of the CAD drawing to be optimized, extract the geometric features and dimensional parameters of the CAD objects involved in the current drafting action segment, input them into the trained improved MTGNN model, and obtain the predicted parameter adjustment amount of the corresponding CAD object.

[0075] S7. Write the predicted parameter adjustment amount into the dimension parameter or object attribute of the corresponding CAD object according to the object identifier.

[0076] S8. Solve the CAD object with adjusted parameters and regenerate the graphics to obtain the CAD drawing with optimized parameters.

[0077] In this embodiment, S1 includes:

[0078] S11. Read multiple historical CAD drawing versions for the same drafting task and extract the drawing identifier, version number, and save time for each version.

[0079] S12. Obtain the drafting commands, command execution time, command target identifier, object records before and after command execution, and save nodes corresponding to each historical CAD drawing version, and form a drafting log.

[0080] In the specific implementation process, document save events, command start events, command end events, and entity write events are registered in the CAD main program, and task identifiers and drawing identifiers are generated when a drafting task is created. The historical CAD drawing versions for the same drafting task are read from the version repository using the task identifier, and the drawing identifier, version number, and save time are read from the document attributes and version records of each version. At the start of a command, the command name, execution time, and object handle of the currently selected object are recorded; during command execution, newly added, modified, or deleted CAD objects are recorded, and object records are read before object writing and after command completion; when the document is saved, a save node is generated, and the command records after the previous save node are associated with the current CAD drawing version to form a drafting log.

[0081] In this embodiment, S2 includes:

[0082] S21. Sort historical CAD drawing versions by save time and pair versions with adjacent save times.

[0083] S22. Identify the object record in the index version pair by the command action object in the drawing log;

[0084] S23. Write the preceding and following object records with the same object handle to the same matching record;

[0085] S24. Write a unified cross-version object identifier to the object records in the same matching record to generate an object mapping table.

[0086] In the specific implementation process, all historical CAD drawing versions are read from the version library by drawing identifier and sorted in ascending order of save time; if the save time is the same, they are sorted by version number. Each pair of adjacent versions is then formed into a version pair, and the preceding version number, the following version number, and the corresponding save node identifier are recorded.

[0087] In this implementation, historical CAD drawing versions are formed by continuously saving the same CAD document. Each version uses the object handles of the original CAD entities, and object handles are not reassigned to existing CAD entities. CAD entities that are deleted and then recreated use new object handles and are recorded as deleted and newly added objects, respectively.

[0088] For each version pair, the drafting log between the two saved nodes is read, and the object identifier of the command action is extracted and duplicate identifiers are removed. The object identifier is represented by the object handle of the CAD entity. The corresponding CAD object is searched in the object records of the previous and subsequent versions using the drawing identifier, version number, and object handle as search keys.

[0089] When the same object handle exists in both the previous and subsequent versions, both object records are written to the same matching record. The matching record includes the previous version number, the previous object handle, the subsequent version number, and the subsequent object handle. When the object handle exists only in the subsequent version, the corresponding object is marked as a newly added object; when the object handle exists only in the previous version, the corresponding object is marked as a deleted object. Newly added and deleted objects are not written to the same matching record.

[0090] Matching records are processed according to the chronological order of version pairs. For the first occurrence of an object handle, the drawing identifier, the first occurrence of the version number, and the object handle are concatenated sequentially to generate a cross-version object identifier. For objects that have already obtained a cross-version object identifier in a previous version pair, this cross-version object identifier is written into the corresponding object record in the next version. Matching records in consecutive version pairs are thus chained together to form a version record sequence for the same CAD object.

[0091] After processing all version pairs, the cross-version object identifier, version number, object handle, and object record storage location are written into the object mapping table and sorted according to the cross-version object identifier and version number.

[0092] In this embodiment, S3 includes:

[0093] S31. Define the log interval by adjacent storage nodes and arrange the drawing commands within the interval according to the execution time;

[0094] S32. Compare the object records before and after the command execution one by one, and write status change markers for commands that have changed key point coordinates, geometric types or geometric relationships between objects.

[0095] S33. Starting with a command that has a status change marker, write commands that act continuously on the same CAD object or CAD objects with geometric relationships into the same drafting action segment;

[0096] S34. End the current drawing action segment when reaching the next save node or when subsequent commands turn to CAD objects with no geometric relationship.

[0097] In practice, each save node is read according to its save time, and the cartographic logs generated between two adjacent save nodes are grouped into the same log interval. Cartographic commands within an interval are arranged primarily by command number; if a command number is missing, they are arranged by command execution time.

[0098] The system sequentially reads the object record before and after modification for each drafting command, and then reads the key points according to the object type. Specifically, the key points for a straight line are the start and end points; for a circle and arc, the key points are the center and endpoints; for a polyline, the key points are the vertices; for a dimension object, the key points are the dimension definition points; and for a block reference, the key points are the insertion points. In this implementation, the geometric tolerance is set to 0.001 drawing units; any change in the coordinates of a corresponding key point exceeding the geometric tolerance is recorded as a change in the key point coordinates.

[0099] Compare the object type codes in the object records before and after the modification. If the object type codes are inconsistent, the object record was empty before the modification, or the object record is in a deleted state after the modification, this is considered a geometric type change.

[0100] Geometric relationship records are composed of object handles and relationship types. Geometric relationship types include shared keypoints, shared geometric datums, collinearity, concentricity, tangency, and dimensional constraints. Shared keypoints are determined by keypoint coordinates and geometric tolerances, while other geometric relationships are read from the CAD geometric constraint record. The geometric relationship records before and after command execution are compared; if relationships are added, deleted, or their types change, this is recorded as a change in geometric relationship between objects. When any of these changes occurs, a status change flag is written to the corresponding command.

[0101] The mapping action segment is created starting with the first command in the log interval that has a status change marker, and the target object identifier of that command is written to the action segment object set. Subsequent commands are then read; if the target object identifier of a subsequent command already exists in the action segment object set, or if the target object of a subsequent command has a geometric relationship with any object in the action segment object set, the subsequent command is added to the current mapping action segment, and the newly added object identifier is written to the action segment object set.

[0102] If the target of a subsequent command does not share the same object identifier and geometric relationship with the action segment object set, the current cartographic action segment ends before that subsequent command. If the subsequent command carries a state change marker, a new cartographic action segment is created using that subsequent command. Upon reaching the next save node corresponding to the log interval, the current cartographic action segment ends directly. View zoom, view pan, and interface operation commands with empty targets and no state change markers are not written into the cartographic action segment.

[0103] Each cartographic action segment records the action segment identifier, start command number, end command number, object identifier set, cartographic command sequence, and corresponding object status change record.

[0104] In this embodiment, S4 includes:

[0105] S41. According to the corresponding relationship, retrieve the CAD object records before and after the execution of commands in each historical drawing action segment;

[0106] S42. Using CAD objects as nodes, select the corresponding parameters from key point coordinates, length, radius, angle, size values ​​and object attributes according to the object type, and write them into the node features;

[0107] S43. Write dependency edges between nodes that share key points, share geometric datum, are collinear, concentric, tangent, or have dimensional constraints.

[0108] S44. Arrange the node features and dependent edges after each state change according to the command execution time, and sequentially extract the preceding state sequence with each non-terminal state as the end to form a sample sequence. Write the change in object parameters of the map action segment's ending state relative to the corresponding non-terminal state into the sample label.

[0109] In the specific implementation process, the action segment identifier, command sequence, and object identifier set of each historical cartographic action segment are read one by one. Using the cross-version object identifier in the object mapping table as the search key, the object records before and after the execution of each command are retrieved from the cartographic log and arranged according to the command sequence number. The same cross-version object identifier corresponds to the same node at different command times.

[0110] Each node has 60 feature positions. Feature positions 1 through 48 correspond to the 3D coordinates of sixteen keypoints, with every three consecutive feature positions containing the X, Y, and Z coordinates of one keypoint. Feature position 49 contains the length, feature position 50 contains the radius, feature positions 51 and 52 contain the start and end angles respectively, feature position 53 contains the dimension value, feature position 54 contains the rotation angle, feature positions 55 through 57 contain the insertion scale in three directions, and feature positions 58 through 60 contain the object type code, layer code, and linetype code respectively. The Z coordinate of a 2D CAD object is set to 0.

[0111] Line objects write the start point, end point, and length to the corresponding feature positions; circle objects write the center and radius to the corresponding feature positions; arc objects write the center, start point, end point, radius, and start and end angles to the corresponding feature positions; polyline objects write each vertex and the total length to the corresponding feature positions; dimension objects write the dimension definition point, text position, and dimension value to the corresponding feature positions; block reference objects write the insertion point, rotation angle, and insertion ratio in three directions to the corresponding feature positions.

[0112] Each CAD object retains sixteen keypoint locations. If the number of keypoints is less than sixteen, empty feature locations are written to 0 and an invalid feature flag is set. If the number of keypoints exceeds sixteen, the first and last keypoints are retained, and fourteen keypoints are selected from the intermediate keypoints at equal intervals in their original order. When selecting polyline keypoints, the original vertex number corresponding to each retained keypoint is recorded simultaneously. Feature locations not applicable to the current object type are written to 0 and an invalid feature flag is set.

[0113] The drawing bounding box at the start of the drafting action segment is read. The smallest coordinate point of the bounding box is used as the coordinate reference point, and the length of the bounding box's diagonal is used as the length reference. When the diagonal length of the bounding box is 0, the length reference is set to 1 drawing unit. Keypoint coordinates are first subtracted from the coordinate reference point, then divided by the length reference; length, radius, and dimension values ​​are divided by the length reference; angle parameters are divided by the angle value corresponding to one revolution. Each sample simultaneously saves the coordinate reference point and length reference. The coordinates, length, radius, and dimension adjustments in the sample labels are processed using the same length reference.

[0114] Read the geometric data and geometric constraint records of each CAD object at the same command time. Write a bidirectional dependency edge between two nodes if any of the following relationships exist: the distance between key points is no greater than 0.001 drawing units; they share the same geometric datum; or there are collinear, concentric, tangent, or dimensional constraints in the CAD constraint records. Write a self-connecting edge for each node simultaneously. Write 1 to the initial matrix element corresponding to the dependency edge, and 0 to the matrix element where no dependency edge has been established. If multiple geometric relationships exist between the same node pair, retain one dependency edge, and save all relationship types in the dependency edge record.

[0115] For each cartographic action segment, a node state is generated after each command with a state change marker is executed. Each node state before the end state is selected as the current state. The node states between the start state and the current state of the cartographic action segment are extracted to form a training sample. The end state of the cartographic action segment is not included in the training sample.

[0116] Each training sample's node set includes the objects affected by commands prior to the current state, and the CAD objects in the current state that have a direct geometric relationship with the affected objects. The nodes are arranged in a fixed order according to cross-version object identifiers.

[0117] Each training sample is set with 32 command time positions. If the number of states is less than 32, the start state of the mapping action segment is copied at the beginning of the sequence; if the number of states exceeds 32, the start state and the current state of the mapping action segment are retained, and 30 states are selected from the two at equal intervals in chronological order.

[0118] Encode the dependent edges in the current state into an initial object adjacency matrix. Read the parameters of the same CAD object in the current state and the final state of the drafting action segment, subtract the current state parameters from the final state parameters, and generate parameter change labels for the corresponding nodes. Objects that exist only in the current state or only in the final state are not written with valid labels. Object type codes, layer codes, linetype codes, derived parameters calculated from other parameters, and dimension values ​​of reference dimensions are marked as invalid.

[0119] In this embodiment, the improved MTGNN model includes multiple cascaded propagation stages, each of which includes a first temporal convolutional layer, a first hybrid hop graph propagation layer, a second hybrid hop graph propagation layer, a second temporal convolutional layer, and an adjacency update layer.

[0120] The first temporal convolutional layer is connected to the first hybrid jump graph propagation layer, and the second hybrid jump graph propagation layer is connected to the second temporal convolutional layer;

[0121] Two temporal convolutional layers within the same propagation level share weights, and two hybrid jump graph propagation layers share weights.

[0122] The adjacency update layer is connected to the first hybrid jump graph propagation layer, the second temporal convolutional layer, and the current object's adjacency matrix, respectively. The output of the adjacency update layer is connected to the input of the adjacency matrix of the next propagation stage.

[0123] The output features of the first hybrid jump graph propagation layer and the second temporal convolutional layer are element-wise averaged and then written into the next propagation stage.

[0124] In this embodiment, S6 includes:

[0125] S61. Read the command action object identifier in the current drawing action segment, locate the corresponding CAD object, and read the directly associated objects that have geometric relationships with the corresponding CAD object;

[0126] S62. According to the object type, read the key point coordinates, length, radius, angle, size value and object attributes one command at a time, and generate node feature records;

[0127] S63. Arrange node feature records according to command execution time to form a node feature sequence, and encode the geometric relationship between current CAD objects into the current object adjacency matrix;

[0128] S64. Input the node feature sequence and the current object adjacency matrix into the trained improved MTGNN model, and extract the prediction parameter adjustment amount according to the object identifier.

[0129] In this embodiment, S64 includes:

[0130] S641. Arrange the node feature sequence according to CAD object, parameter type and command time into a node feature tensor, form an initial node hidden feature tensor through channel mapping, and write it into the first propagation stage along with the current object adjacency matrix.

[0131] S642. The first temporal convolutional layer uses gated dilated temporal convolution to extract temporal features. The first hybrid skip graph propagation layer reads the current object's adjacency matrix and propagates the temporal features. The second hybrid skip graph propagation layer first propagates the node's hidden features. The second temporal convolutional layer uses shared weights to perform gated dilated temporal convolution and outputs two sets of node features.

[0132] S643. The adjacency update layer takes the absolute difference of each element of the two sets of node features, splices the difference features of the two end nodes according to the dependent edge, generates the matrix element correction amount through linear mapping, and normalizes the corrected object adjacency matrix.

[0133] S644. The two sets of node features are averaged element by element and used as the hidden node features of the next propagation level, and written together with the corrected object adjacency matrix into the next propagation level.

[0134] S645. The hidden features of the last-level node are converted into parameter adjustment vectors for each node through output mapping, and the predicted parameter adjustment amount is extracted according to the object identifier.

[0135] In practice, existing MTGNN models typically perform temporal convolution and hybrid skip graph propagation sequentially in each propagation layer, reusing the same adjacency matrix in a single forward computation. For CAD drafting, drafting commands not only cause object parameters to change over time but may also alter the geometric relationships between objects. Using a fixed propagation order and a fixed adjacency matrix makes it difficult to simultaneously reflect the impact of both command temporal changes and object dependency changes on parameter adjustment results.

[0136] Based on this, this implementation sets up two propagation paths in parallel at each propagation stage: one path performs temporal convolution first, then performs hybrid jump graph propagation; the other path performs hybrid jump graph propagation first, then performs temporal convolution. The temporal convolutional layers and hybrid jump graph propagation layers in the two paths share weights, so that the output difference between the two paths mainly reflects the difference in the order of temporal processing and object dependency propagation.

[0137] The output differences between the two paths are converted into dependency edge corrections, which are then used to adjust the object adjacency matrix of the next propagation stage. The adjusted object adjacency matrix participates in node feature propagation, enabling the model to change the propagation strength between associated objects as mapping actions are continuously executed. Shared weights prevent the two propagation paths from having independently configured temporal convolution parameters and graph propagation parameters, thus preventing the dual-path structure from causing a significant increase in network parameters. This also helps improve the consistency of parameter adjustments for associated CAD objects, reducing the likelihood of conflicts in subsequent constraint solving and graph regeneration.

[0138] This implementation sets up four cascaded propagation stages, with each stage having 32 hidden feature channels. Both the temporal convolutional layer and the hybrid skip graph propagation layer maintain a constant number of nodes and output channels. The temporal convolutional layer uses front-end padding to maintain a constant number of temporal positions, ensuring that the node features output by the two propagation paths have the same size.

[0139] The first propagation stage uses the initial object adjacency matrix obtained by encoding the dependent edges of CAD objects. The graph learning layer of the original MTGNN model no longer generates a second adjacency matrix for use by all propagation stages; both hybrid skip graph propagation layers use the CAD object adjacency matrix as the basis for graph propagation. The second to fourth propagation stages read the object adjacency matrix output by the adjacency update layer of the previous propagation stage, respectively.

[0140] The training data uses historical mapping action segments. Only action segments whose ending state persists to the next saved node and is not modified again by subsequent commands are retained, and their corresponding ending state is taken as the final state of that action segment.

[0141] For each historical mapping action segment, the states before the end of the action segment are sequentially selected as the current state. For each current state, the node feature records from the start state of the action segment to the current state are extracted to form a training sample. The parameters of the same CAD object in the current state and the final state are read, and the change in the final state parameters relative to the current state is written into the sample label. The final state is not used to generate separate training samples.

[0142] The initial object adjacency matrix in the training samples is generated using the dependency edges in the current state. Therefore, the training input only contains the current state and data prior to the current state, and the sample labels represent the amount of parameter adjustments needed to reach the final state from the current state.

[0143] CAD objects within the same sample are arranged in a fixed order based on cross-version object identifiers. Objects that exist only in the current state but not in the final state are not assigned valid parameter labels; newly added objects that exist only in the final state are not written to the node set of the current sample. Invalid node feature flags and invalid label flags record unavailable input fields and unpredictable output fields, respectively.

[0144] Each training sample contains 32 command time positions. If the number of states preceding the current state is less than 32, the start state of the action segment is repeated at the beginning of the sequence; if the number of states exceeds 32, the start state of the action segment and the current state are retained, and 30 states are selected from between them at equal intervals in chronological order.

[0145] For all command time positions within the same sample, the minimum coordinate point of the drawing bounding box at the start of the drafting action segment is used as the coordinate reference point, and the diagonal length of the drawing bounding box is used as the length reference. When the diagonal length of the bounding box is 0, the length reference is set to 1 drawing unit. Keypoint coordinates are subtracted from the coordinate reference point and then divided by the length reference; length, radius, and dimension values ​​are divided by the length reference; angle parameters are divided by the angle value corresponding to one revolution. Coordinate, radius, and dimension adjustments in the sample labels are processed using the same length reference.

[0146] First, arrange the cross-version object identifiers involved in the same mapping action segment in ascending order of characters, and assign node numbers sequentially starting from 1; arrange the mapping commands in ascending order of command number, and assign command time numbers sequentially starting from 1.

[0147] Each node has 60 feature positions. Positions 1-48 sequentially contain the 3D coordinates of sixteen key points; position 49 contains the length; position 50 contains the radius; positions 51 and 52 contain the start and end angles respectively; position 53 contains the dimension value; position 54 contains the rotation angle; positions 55-57 contain the insertion scale in three directions; position 58 contains the object type code; position 59 contains the layer code; and position 60 contains the linetype code. The third dimension of a 2D CAD object is set to 0.

[0148] The start state of the drafting action segment is written to the time position of the first command. When processing a subsequent command, all node features at the time position of the previous command are copied first, and then the feature positions of the corresponding nodes are overwritten with the object record after the command is executed; CAD objects unaffected by this command retain the parameter values ​​from the previous time position. For newly added objects, 0 is written to the feature positions before the addition and an invalidation flag is set; for deleted objects, 0 is written to the feature positions after the deletion and an invalidation flag is set; parameter positions not applicable to the current object type are also written to 0 and an invalidation flag is set.

[0149] After writing all command time positions, a node feature tensor is formed, consisting of the number of nodes × 60 feature positions × the number of command time positions. If the number of nodes differs within the same training batch, empty nodes are added to the end of the node dimension to reach the maximum number of nodes in that batch. All features, adjacency matrix rows, and adjacency matrix columns of empty nodes are written to 0, and the node's valid flag is written to 0; the valid flag of real nodes is written to 1.

[0150] The 60 input features of each node are transformed into 32 hidden feature channels through a channel mapping layer, forming the initial node hidden feature tensor. Self-connection is set only for real nodes, and row-by-row normalization of the object adjacency matrix is ​​performed, while the matrix rows and columns corresponding to empty nodes are kept to 0.

[0151] The initial node hidden feature tensor is first written to the first propagation stage. The first propagation stage writes the same node's hidden features to the first temporal convolutional layer and the second hybrid jump graph propagation layer, and writes the initial object adjacency matrix to both layers. After the temporal convolutional layer and the hybrid jump graph propagation layer output node features, the output features are multiplied by the valid node markers at the corresponding command time positions, ensuring that empty nodes, nodes before addition, and nodes after deletion remain at 0.

[0152] The first-time convolutional layer employs gated dilated temporal convolution. Specifically, the first-time convolutional layer sets up feature convolution channels and gated convolution channels. The feature convolution result is activated by hyperbolic tangent activation, and the gated convolution result is activated by sigmoid activation. The two results are then multiplied element-wise.

[0153] Both the feature convolutional channels and the gated convolutional channels are configured with four sets of temporal convolutional kernels of lengths 2, 3, 6, and 7. The four sets of convolutional results are padded and clipped in the temporal direction to ensure they have the same duration, and then concatenated along the channel direction and mapped to 32 output channels. The dilation intervals of the four propagation levels are set to 1, 2, 4, and 8, respectively. The first and second temporal convolutional layers within the same propagation level share the convolutional kernels, gating parameters, and channel mapping parameters, while different propagation levels store independent parameters.

[0154] The temporal features output by the first convolutional layer are written into the first hybrid hop graph propagation layer. The first hybrid hop graph propagation layer performs two-hop propagation according to the current object's adjacency matrix. The zero-hop feature is the temporal feature output by the first convolutional layer; the one-hop propagation gathers the features of directly related nodes according to the current object's adjacency matrix; the two-hop propagation gathers the features of related nodes again based on the one-hop propagation result.

[0155] Each hop propagation retains 5% of the input features of the current hybrid hop graph propagation layer, and retains 95% of the features aggregated according to the object adjacency matrix. The zero-hop, one-hop, and two-hop features are concatenated along the channel direction and then mapped to 32 output channels to form the first set of node features.

[0156] The second hybrid hop graph propagation layer directly receives the hidden node features from this propagation level and uses the same object adjacency matrix, propagation hop count, feature retention ratio, and graph propagation weights as the first hybrid hop graph propagation layer. The graph propagation features output by the second hybrid hop graph propagation layer are written into the second temporal convolutional layer, which performs gated dilated temporal convolution using weights shared with the first temporal convolutional layer to form the second set of node features.

[0157] The two sets of node features have the same node order, number of channels, and number of time positions. The adjacency update layer takes the absolute difference of each element of the two sets of node features, and then calculates the average value along the command time direction to form the order difference feature corresponding to each node.

[0158] For each dependent edge in the current object's adjacency matrix, the order difference features of the nodes at both ends of the dependent edge are concatenated according to a fixed node order. Each node's order difference feature contains 32 channels, which are concatenated to form a 64-channel edge difference feature. The edge difference feature is then input into the linear mapping in the adjacency update layer to obtain a matrix element correction.

[0159] The matrix element correction is processed by hyperbolic tangent, multiplied by 0.1, and then added to the corresponding matrix element in the current object adjacency matrix. If the adjustment result is less than 0, the corresponding matrix element is set to 0; matrix elements without dependent edges remain 0; self-connected positions do not receive matrix element corrections. After completing the matrix element adjustment, row-by-row normalization is performed again to obtain the object adjacency matrix for the next propagation level.

[0160] Therefore, the adjacency update layer only adjusts the weights of existing CAD object dependency edges, and does not add new dependency edges between CAD objects that do not have geometric relationships.

[0161] The node hidden features of the first and second sets of node features are added element by element and then averaged to obtain the node hidden features for the next propagation stage. The next propagation stage simultaneously receives the node hidden features and the updated object adjacency matrix, and repeats the two reverse propagation paths, order difference extraction, and adjacency matrix update until the fourth propagation stage is completed.

[0162] Each propagation level has two temporal convolutional layers that share a set of parameters, and two hybrid skip graph propagation layers that share a set of parameters; parameters are not shared between propagation levels. Each propagation level has its own adjacency update layer, and the adjacency update layers of different propagation levels store the linear mapping parameters separately.

[0163] After the fourth propagation stage outputs hidden features from the nodes, the hidden features corresponding to the last command time position are taken. The output mapping first converts the 32 hidden feature channels into 64 intermediate channels and performs linear rectification activation, then converts them into 56 parameter adjustment components. The 56 parameter adjustment components correspond to feature positions 1 to 48 and feature positions 50 to 57, respectively.

[0164] The length in the 49th feature position, the object type code in the 58th feature position, the layer code in the 59th feature position, and the line type code in the 60th feature position are only used as model inputs and do not generate corresponding parameter adjustment components.

[0165] Writable field markers are generated based on the CAD object type. For line objects, the coordinates of the first two key points are set to writable; for circle objects, the center coordinates and radius are set to writable; for arc objects, the center coordinates, radius, start angle, and end angle are set to writable; for polyline objects, the coordinates of retained vertices are set to writable; for dimension objects, the coordinates of the dimension definition point are set to writable, and for dimension objects with driving attributes, the dimension value is also set to writable; for block reference objects, the insertion point coordinates, rotation angle, and insertion scale in three directions are set to writable. The remaining parameter adjustment components are set to 0, and a parameter invalidation flag is set.

[0166] Before training, convolutional weights, graph propagation weights, adjacency update layer weights, and output mapping weights are initialized using the Xavier method, with all bias parameters initialized to 0. Training, validation, and test sets are divided according to the mapping task, and samples generated from the same mapping task are written to only one dataset. In this implementation, the training, validation, and test sets are divided in proportions of 70%, 15%, and 15%, respectively.

[0167] During training, parameter positions 1 to 48 and 50 to 57 are sequentially extracted from the sample labels to form a 56-dimensional target parameter adjustment vector. The model's output 56-dimensional parameter adjustment vector is compared element-by-element with the target parameter adjustment vector, and the smoothed absolute error is calculated only for the parameter components corresponding to the valid labels. Gradients generated by the two propagation paths are accumulated to the corresponding shared weights, and the parameters of the adjacent update layer and the output mapping are updated synchronously.

[0168] This implementation uses the Adam optimizer, with an initial learning rate of 0.001, a batch size of 16, and a maximum number of training epochs of 100. Training stops when the validation set error fails to decrease for ten consecutive epochs, and the network parameters at which the validation set error is lowest are saved to obtain the improved MTGNN model after training.

[0169] The drafting logs of the CAD drawing to be optimized, after the most recent saved node, are arranged by command number. A candidate drafting action segment is created using the first command with a status change marker, and the corresponding object of the command is recorded. When a subsequent command acts on an already recorded object or has a direct geometric relationship with an already recorded object, the subsequent command is added to the candidate drafting action segment. When a subsequent command redirects to a CAD object without a geometric relationship, the previous candidate drafting action segment ends, and a new candidate drafting action segment is created if the subsequent command has a status change marker. After processing the latest command, any candidate drafting action segments that have not yet ended are identified as the current drafting action segment; if no candidate drafting action segment exists, parameter prediction is not performed.

[0170] Locate the corresponding CAD object based on the command action object identifier in the current drafting action segment, and write all related objects with direct geometric relationships into the current node set. Arrange the CAD objects in the current node set according to the character order of their object handles, assign node numbers starting from 1, and save the correspondence between node numbers and object handles.

[0171] Extract key point coordinates, length, radius, angle, dimension values, and object attributes of each CAD object in the current node set according to object type and command execution time, forming a node feature record. Use the smallest coordinate point of the bounding box at the start of the current drafting action segment as the coordinate reference point, and the length of the bounding box diagonal as the length reference; when the bounding box diagonal length is 0, the length reference is set to 1 drawing unit. Key point coordinates minus the coordinate reference point are divided by the length reference; length, radius, and dimension values ​​are divided by the length reference; angle parameters are divided by the angle value corresponding to one revolution.

[0172] If the number of states in the current mapping action segment is less than 32, repeat the start state of the action segment at the beginning of the sequence; if the number of states exceeds 32, retain the start state and the current state, and select 30 states at equal intervals from the middle states to form a node feature sequence with the same dimension as the training samples.

[0173] The geometric relationships between CAD objects in the current state are read, and dependency edges, node self-connections, and matrix elements are written in the same way as in the training phase to generate the adjacency matrix of the current object. The node feature sequences and the adjacency matrix of the current object are input into the improved MTGNN model after training, and passed through four propagation stages to obtain the parameter adjustment vector of each node.

[0174] Using the length and angle references recorded in the current drafting action segment, the parameter adjustment vector is reverse-converted to restore the scaled parameter adjustment amount to CAD drawing units. Finally, the corresponding object identifier is obtained according to the node arrangement order, and the object identifier, parameter type, and parameter adjustment value are written together into the predicted parameter adjustment record.

[0175] In this embodiment, S7 includes:

[0176] S71. Read the object identifier, parameter type and adjustment value corresponding to the predicted parameter adjustment amount, and locate the CAD entity record according to the object identifier;

[0177] S72. According to the CAD object type, map the parameter type to the corresponding dimension value, key point coordinate, radius, angle or object attribute field;

[0178] S73. Read the current parameter value of the corresponding field, add the current parameter value to the adjustment value, and generate the parameter value to be written;

[0179] S74. In the same write transaction, batch update the corresponding fields of each CAD object and record the parameter values ​​before the update.

[0180] The improved MTGNN model output prediction parameter adjustment record includes drawing identifier, object identifier, parameter type, adjustment value, and parameter validity flag. Adjustment records with invalid parameter validity flags are not included in the parameter writing process.

[0181] The object identifier uses the object handle from the current CAD drawing. The drawing identifier and object handle form the CAD entity retrieval key, which reads the corresponding entity record from the current CAD entity database. If the entity record does not exist, the object has been deleted, or the object is in a writable state, the corresponding predicted parameter adjustment record is marked as a write failure, and no record is created for writing.

[0182] The parameter type numbers are consistent with the node feature positions. Specifically, numbers 1 to 48 correspond to the 3D coordinates of sixteen keypoints, with every three consecutive numbers corresponding to the X, Y, and Z coordinates of a keypoint. Number 49 corresponds to length, number 50 to radius, numbers 51 and 52 to start and end angles respectively, number 53 to dimension value, number 54 to rotation angle, numbers 55, 56, and 57 to insertion ratios in the X, Y, and Z directions respectively, and numbers 58 to 60 to object type code, layer code, and linetype code respectively. Numbers 49 and 58 to 60 are only used as model inputs and not as output as prediction parameter adjustments.

[0183] For line objects, the coordinates of the first keypoints (numbered 1 to 3) are mapped to the line start field, and the coordinates of the second keypoints (numbered 4 to 6) are mapped to the line end field. The line length is calculated based on the start and end points; no length field is created for this purpose.

[0184] For a circle object, map the coordinates of the first key point to the center field, and map the parameter adjustment amount corresponding to number 50 to the radius field.

[0185] For arc objects, the coordinates of the first keypoint are mapped to the center field, and the parameter adjustments corresponding to numbers 50 to 52 are mapped to the radius, start angle, and end angle fields, respectively. The start and end points of the arc are recalculated based on the center, radius, and start and end angles, and keypoint coordinate adjustments are not accepted.

[0186] For polyline objects, the coordinates of each valid key point are mapped to the corresponding vertex field according to the original vertex number saved in the node feature record.

[0187] For dimension objects, the coordinates of valid key points are mapped to the dimension definition point field; when a dimension object has a driving attribute, the parameter adjustment amount corresponding to number 53 is mapped to the dimension constraint value field; no dimension value is written to the mapping for reference dimensions.

[0188] For block reference objects, map the coordinates of the first key point to the block insertion point field, and map the parameter adjustment amounts corresponding to numbers 54 to 57 to the rotation angle and the insertion ratio fields in the three directions, respectively.

[0189] The same CAD object uses only one set of writable parameters that can directly define the object's geometric state, with length, diameter, perimeter, arc length, and arc endpoint coordinates as derived parameters, and no duplicate write fields are created.

[0190] After completing the parameter field mapping, the coordinate adjustment values ​​are added to the corresponding coordinate components, and the adjustment values ​​for radius, start angle, end angle, dimension value, rotation angle, and insertion scale are added to the corresponding scalar fields to generate the parameter values ​​to be written. The line length, total polyline length, and arc endpoint coordinates are recalculated based on the corresponding geometric parameters after the parameters are written.

[0191] Perform field checks on the parameter values ​​to be written. Length and radius must be greater than zero, block insertion scale must not be zero, angle values ​​must be converted to the full circle angle range used by the CAD system, and coordinate values ​​must be converted to the coordinate precision of the current CAD drawing. If the parameter value to be written does not conform to the data type or value range of the corresponding field, mark all records to be written for that object as write failures.

[0192] For prediction results that pass the field checks, records to be written are generated according to the object identifier and parameter type. Each record to be written includes the object handle, object type, parameter fields, current parameter value, and parameter value to be written. When the same object has multiple fields to be written, all fields are written to the same object update record.

[0193] After all records to be written have been generated, the current CAD document is locked, and a CAD database write transaction is initiated. CAD entities are opened sequentially in write mode according to their object handles. Before modifying fields, the current parameter values ​​of the corresponding entities are copied, and the object handles, parameter fields, and parameter values ​​before the update are written to the transaction rollback record.

[0194] Subsequently, the parameter values ​​to be written are batch-written into the corresponding CAD entity fields. For line objects, the adjusted start and end coordinates are written, and the line length is recalculated based on the written start and end coordinates; for arc objects, the center, radius, start angle, and end angle are written, and the start and end coordinates of the arc are recalculated; for polyline objects, the corresponding vertex coordinates are written according to the original vertex sequence number; for dimension objects, dimension constraint values ​​or dimension definition points are written; for block reference objects, the insertion point, rotation angle, and insertion ratio in three directions are written.

[0195] All parameter writes are completed within the same transaction. The transaction is not committed during the write process, nor is a separate CAD drawing regeneration triggered. If any CAD entity cannot be opened, any field write fails, or the written entity record fails the CAD database's field check, all field updates in this transaction are rolled back.

[0196] After all records to be written are successfully written, the write transaction remains in an uncommitted state, and the transaction identifier, the set of updated object handles, and the parameter values ​​before the update are passed to the subsequent geometric constraint solving and graphics regeneration processes. The write transaction is committed when the subsequent solution and verification are successful; if a solution conflict occurs or the verification fails, the parameter values ​​before the update are restored using the transaction rollback record.

[0197] In this embodiment, S8 includes:

[0198] S81. Read the geometric constraint records of the CAD object after parameter adjustment, and divide the constraint solution object group according to the constraint-related objects;

[0199] S82. Set the adjusted CAD object parameters as the driving parameters of the CAD geometric constraint solver, and calculate the key point coordinates and geometric definition parameters of the CAD objects in each object group.

[0200] S83. Write the solution results into the corresponding CAD entity record, and regenerate the graphics for the parameter adjustment objects, constraint associated objects and associated dimensions;

[0201] S84. Read the constraint solution status and the regenerated object record, and verify the geometric relationship and dimension association status corresponding to each CAD constraint;

[0202] S85. If the constraint solution is conflict-free and the verification passes, retain the parameter adjustment results; otherwise, restore the object parameters before parameter adjustment and regenerate the graph.

[0203] In practice, the CAD geometric constraint solver and the graphics regeneration module read uncommitted CAD entity records through the same write transaction context, and the solution results are also recorded in the same write transaction. The write transaction saves the object handle, parameter fields, parameter values ​​before update, and parameter values ​​to be written.

[0204] Read the updated object handles from the written transaction, and use the object handles as the retrieval key to read the corresponding geometric constraint records from the constraint database of the current CAD drawing. Each geometric constraint record includes at least the constraint identifier, constraint type, object handles involved in the constraint, constraint parameters, and constraint status.

[0205] Constraint types include coincidence, collinearity, parallelism, perpendicularity, concentricity, tangency, equal length, equal radius, fixed, distance, angle, radius, and diameter constraints. When a dimension object has driving attributes, the dimension association record is used as a distance, angle, radius, or diameter constraint; when a dimension object only has measurement or annotation attributes, only the handle of the associated object is retained, and the corresponding dimension association record is not written to the constraint solver.

[0206] When grouping constraint-solving objects, first, an updated object is written to the current object group. Then, handles of other objects that share common constraint records with that object are read, and the read objects are written to the current object group. This process continues, reading constraint records for newly added objects until no more associated objects appear. The next object group is then created starting with the updated objects that have not yet been grouped. When different object groups contain the same object handle, the corresponding object groups are merged.

[0207] For updated objects that do not have geometric constraint records, treat the object as a separate object group, do not call the geometric constraint solver, and only perform validity checks and graphic regeneration on the written geometric fields.

[0208] The geometric definition parameters for each object group include the start and end points of line objects, the center, radius, and start and end angles of circle and arc objects, the vertices of polyline objects, the dimension definition points, dimension values, and associated object handles of dimension objects, and the insertion point, rotation angle, and scale of each direction for block reference objects.

[0209] Write the parameter values ​​to be written in the transaction to the corresponding geometric variables, and set the corresponding geometric variables as driving variables. Geometric variables that have not been modified by predicted parameter adjustments are set as variables to be solved. Objects with fixed constraints in the CAD constraint record remain in a fixed state and do not participate in position adjustments.

[0210] Establish constraint solving inputs based on the constraint records in the object group. Coincident constraints are written to two key points; collinear, parallel, and perpendicular constraints are written to the corresponding line objects; concentric constraints are written to the center position of the circle; tangent constraints are written to the lines, circles, or arcs involved in the tangency; and distance, angle, radius, and diameter constraints are written to their corresponding constraint values. For dimensional constraints with driving attributes, if there are dimension values ​​to be written, write the dimension values ​​to the corresponding constraints; otherwise, retain the original dimension values. Reference dimensions are not written to the constraint solving inputs.

[0211] The driving variables, variables to be solved, and constraint records of the object group are submitted to the CAD geometric constraint solver. In this implementation, the position solution tolerance is set to 0.001 drawing units, the angle solution tolerance is set to 0.01 degrees, and the maximum number of iterations is set to 50.

[0212] The geometric constraint solver iteratively adjusts the key point coordinates and geometric definition parameters of the object to be solved while keeping the driving variables and fixed objects unchanged. When the solution residuals of all constraints are not greater than the corresponding solution tolerance, the object group is marked as successfully solved; if there are still constraints exceeding the solution tolerance after reaching the maximum number of iterations, or if the same geometric variable is assigned incompatible constraint values, the object group is marked as having a constraint conflict, and the identifier of the conflicting constraint is recorded.

[0213] For successfully solved object groups, the key point coordinates and geometric definition parameters output by the solver are written back to the CAD entity record in the transaction, according to the object handle. For lines, the start and end points are written back; for circles and arcs, the center, radius, and start and end angles are written back; for polylines, the vertex coordinates are written back; for dimension objects, the dimension definition points and dimension values ​​are written back; and for block references, the insertion point, rotation angle, and scale parameters are written back.

[0214] For object groups without geometric constraint records, directly verify the entity records after the parameters are written. If the length and radius are greater than zero, the block insertion ratio is not zero, and the entity state is valid, mark the object group as successfully solved; otherwise, mark it as having invalid object parameters.

[0215] After all object groups have been processed, the parameter adjustment objects, constraint-related objects, and associated dimensions from the successfully solved object groups are written into the regenerated object set. Graphic regeneration is then performed in the order of basic geometric objects, constraint-related objects, and dimension objects.

[0216] First, reconstruct lines, circles, arcs, polylines, and block references based on the keypoint coordinates and geometric definition parameters after writing back. Then, refresh the geometric constraint states associated with these objects. Finally, recalculate the dimension lines, dimension text positions, and displayed dimension values ​​for the dimension objects. When the object group contains block references, simultaneously update the transformation matrix of the block references and the visible entities within the block.

[0217] After the graphics are regenerated, the constraint solution status of each object group and the regenerated CAD entity records are read. For coincident, collinear, parallel, perpendicular, concentric, and tangent constraints, the constraint residuals are recalculated by calling the CAD geometric constraint check interface; the residuals of positional constraints must not exceed 0.001 drawing units, and the residuals of angle constraints must not exceed 0.01 degrees.

[0218] For distance, radius, diameter, and angle constraints, read the regenerated actual measurement values ​​and compare them with the target values ​​in the constraint record. If the difference between the two does not exceed the corresponding solution tolerance, the check is recorded as passed.

[0219] For dimension association status, verify the associated object handle and associated object status of the dimension object, and recalculate the dimension measurement value. If the difference between the measured value and the displayed dimension value for distance, radius, and diameter dimensions does not exceed 0.001 drawing units, and the difference between the measured value and the displayed dimension value for angle dimensions does not exceed 0.01 degrees, the dimension association is recorded as valid.

[0220] Simultaneously check the status of the regenerated CAD entities. CAD entities cannot contain invalid coordinates, line lengths, circle and arc radii must be greater than zero, the number of polyline vertices must not be less than the minimum requirement for the corresponding entity type, and the scale of the block reference in all three directions must not be zero.

[0221] When all object groups have been successfully solved, all geometric constraints have passed verification, all dimension associations are valid, and all CAD entity states are valid, the write transaction is committed, and the parameter adjustment results and constraint solution results are officially written to the current CAD drawing database. Subsequently, the document is saved, creating a parameter-optimized CAD drawing version.

[0222] If any object group experiences constraint conflicts, invalid object parameters, failed geometric constraint checks, failed dimension associations, or an invalid CAD entity state, the commit operation is terminated and the entire write transaction is rolled back, revoking the parameter values ​​to be written, as well as the keypoint coordinates and geometric definition parameters written back by the solver. Subsequently, based on the restored CAD entity record, the processed objects and associated dimensions are regenerated, restoring the current CAD drawing to its state before parameter adjustments.

[0223] After completing the commit or rollback, release the CAD document lock and record the object group identifier, solution status, conflict constraint identifier, transaction processing result, and drawing version number.

[0224] Example 1: To verify the feasibility of this invention in practice, it was applied to the CAD design process of mechanical mounting brackets and positioning plates for a non-standard automated equipment manufacturing company. This company uses parametric CAD software to complete the drawing of equipment mounting holes, positioning slots, arc transition edges, dimensional constraints, and standard blocks. For the same type of part, the hole spacing, arc radius, plate outline, and block insertion ratio are repeatedly adjusted according to equipment specifications. Existing methods mainly call parameter templates from similar drawings; however, parameter adjustments easily lead to the disruption of concentricity, separation of associated dimensions, and constraint conflict, requiring designers to make corrections item by item.

[0225] Register command start, command end, entity write, and document save events in the CAD main program. Select 480 drafting tasks generated within 12 consecutive months from the company, containing 3264 historical CAD drawing versions and 176540 drafting command records. Divide the saved nodes and object geometric state changes into 10860 historical drafting action segments. Then, extract the preceding state sequence from the node states before the end state of each action segment to obtain 52416 object temporal training samples.

[0226] Each node has 60 feature locations, recording keypoint coordinates, length, radius, start and end angles, dimension values, rotation angle, insertion scale, object type code, layer code, and linetype code. Dependency edges are established between CAD objects that share keypoints, share geometric datums, are collinear, concentric, tangent, or have dimensional constraints. Each sample retains 32 command time locations. If there are fewer than 32, the start state of the action segment is repeated at the beginning of the sequence. If there are more than 32, the start state and the current state are retained, and 30 states are selected at equal intervals from the middle states.

[0227] The samples were divided into training, validation, and test sets according to the mapping tasks, containing 336, 72, and 72 mapping tasks, respectively. Samples generated from the same mapping task were assigned to only one dataset. The improved MTGNN model was configured with four propagation levels and 32 hidden feature channels per node. Each propagation level included a temporal convolution-mixed skip graph propagation path and a mixed skip graph propagation-temporal convolution path, with weights shared between similar layers in both paths. The adjacency update layer corrected the object adjacency matrix of the next propagation level based on the output difference between the two paths. Training employed the Adam optimizer with an initial learning rate of 0.001 and a batch size of 16. Training stopped when the validation set error failed to decrease for 10 consecutive rounds.

[0228] In actual optimization, the current drawing action segment is defined as the drawing action segment that has not yet ended since the most recent saved node. The current node set is composed of the command's target object and its directly associated objects. CAD objects in the current node set are arranged according to their object handles, and node feature sequences and the current object adjacency matrix are generated using the same feature positions, coordinate bases, and length bases as in the training phase. The node feature sequences and the current object adjacency matrix are processed by the improved MTGNN model after training, outputting predicted adjustments for keypoint coordinates, radius, angle, dimension values, rotation angles, and insertion scale. These predicted adjustments are then converted to the coordinate units, angle units, and scale values ​​used in the current CAD drawing. The predicted adjustments are written to the corresponding CAD entity in the same write transaction. Subsequently, the CAD geometric constraint solver is called to process the associated objects, and the drawing is regenerated. If the constraint solving or regeneration check fails, the entire write transaction is rolled back.

[0229] From 72 mapping tasks in the test set, 600 mapping action segments containing at least 5 node states were selected. The node states in each mapping action segment were arranged according to command execution time. The node state corresponding to the position obtained by multiplying the number of commands by 60% was used as the state to be optimized, and the ending state of the corresponding mapping action segment was used as the verification state. The original parameter template method directly adopted existing template parameters for the corresponding part type. The original improved MTGNN model only retained a single propagation path after temporal convolution followed by hybrid skip graph propagation, and reused the same current object adjacency matrix at each propagation level. The three methods were compared using the same state to be optimized, object dependencies, parameter writing conditions, constraint solution tolerance, and graph regeneration verification conditions.

[0230] The criteria for parameter adjustment compliance are as follows: the difference between the key point coordinates, radius, and dimension values ​​and the verification state does not exceed 0.20 mm; the angle difference does not exceed 0.20°; and the insertion scale difference does not exceed 0.005. When all valid predicted parameters in the same drafting action segment meet the corresponding criteria, the drafting action segment is recorded as parameter adjustment compliant; if any valid predicted parameter exceeds the corresponding criteria, it is recorded as parameter adjustment non-compliant. When any constraint solution object group experiences a solution conflict, the corresponding drafting action segment is recorded as constraint conflict. The number of manual corrections is counted according to the number of times the designer actually modified parameters or constraint relationships after automatic optimization. The results are shown in Table 1.

[0231] Table 1 Comparison of CAD Drafting Parameter Optimization Effects

[0232] Traditional parameter template 73.17 11.83 2.36 Original Improved MTGNN Model 85.50 6.17 1.31 This invention 94.17 2.33 0.54

[0233] Of the 600 test mapping action segments, 439, 513, and 565 action segments using the traditional parameter template method, the original improved MTGNN model method, and the method of this invention, respectively, met the parameter adjustment requirements; while 71, 37, and 14 action segments, respectively, experienced constraint conflicts. The total number of manual corrections for the 72 test mapping tasks were 170, 94, and 39, respectively.

[0234] Comparative results show that traditional parameter template methods cannot adjust parameters based on continuous drafting commands and object dependencies, resulting in a low parameter adjustment compliance rate. While the original improved MTGNN model can extract temporal changes in object parameters, it reuses the same object adjacency matrix at each propagation level, limiting its ability to express changes in object dependencies during drafting. This invention extracts propagation order differences through two reverse-order shared weight paths and accordingly modifies the object adjacency matrix at each level, achieving a parameter adjustment compliance rate of 94.17%, reducing the constraint conflict rate to 2.33%, and lowering the average number of manual corrections to 0.54 per task. This verifies the feasibility of this invention in adaptive optimization of CAD drafting parameters.

[0235] The above description is only a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any equivalent substitutions or modifications made by those skilled in the art within the scope of the technology disclosed in the present invention, based on the technical solution and inventive concept of the present invention, should be covered within the scope of protection of the present invention.

Claims

1. An adaptive optimization method for CAD drawing parameters based on big data processing, characterized in that, Includes the following steps: S1. Obtain historical CAD drawing versions and corresponding drafting logs; S2. Based on the command action object identifier in the drawing log and the object record in the historical CAD drawing version, establish the correspondence between the same CAD object in different historical CAD drawing versions; S3. Based on the saved nodes and the geometric state changes of CAD objects, the drafting log is divided into drafting action segments; S4. Read each historical CAD drawing version, and construct object time-series training samples with CAD objects as nodes, geometric relationships between objects as dependencies, and object parameters as node features. S5. Train the improved MTGNN model using the object temporal training samples. The improved MTGNN model sets up two paths with the temporal convolution and hybrid jump graph propagation order reversed and corresponding modules sharing weights. Update the object adjacency matrix of the next propagation stage according to the output difference of the two paths. S6. Determine the current drafting action segment from the current drafting log of the CAD drawing to be optimized, extract the geometric features and dimensional parameters of the CAD objects involved in the current drafting action segment, input them into the trained improved MTGNN model, and obtain the prediction parameter adjustment amount of the corresponding CAD object. S7. Write the predicted parameter adjustment amount into the dimension parameter or object attribute of the corresponding CAD object according to the object identifier; S8. Solve the CAD object with adjusted parameters and regenerate the graphics to obtain the CAD drawing with optimized parameters.

2. The adaptive optimization method for CAD drawing parameters based on big data processing according to claim 1, characterized in that, S1 includes: S11. Read multiple historical CAD drawing versions for the same drafting task and extract the drawing identifier, version number, and save time for each version. S12. Obtain the drafting commands, command execution time, command target identifier, object records before and after command execution, and save nodes corresponding to each historical CAD drawing version, and form the drafting log.

3. The adaptive optimization method for CAD drawing parameters based on big data processing according to claim 1, characterized in that, S2 includes: S21. Sort historical CAD drawing versions by save time and pair versions with adjacent save times. S22. Identify the object record in the index version pair by the command action object in the drawing log; S23. Write the preceding and following object records with the same object handle to the same matching record; S24. Write a unified cross-version object identifier to the object records in the same matching record to generate an object mapping table.

4. The adaptive optimization method for CAD drawing parameters based on big data processing according to claim 1, characterized in that, S3 includes: S31. Define the log interval by adjacent storage nodes and arrange the drawing commands within the interval according to the execution time; S32. Compare the object records before and after the command execution one by one, and write status change markers for commands that have changed key point coordinates, geometric types or geometric relationships between objects. S33. Starting with a command that has a status change marker, write commands that act continuously on the same CAD object or CAD objects with geometric relationships into the same drafting action segment; S34. When the next save node is reached or the next drawing command is applied to other CAD objects that have no geometric relationship with any of the CAD objects in the current drawing action segment, the current drawing action segment ends.

5. The adaptive optimization method for CAD drawing parameters based on big data processing according to claim 1, characterized in that, S4 includes: S41. According to the aforementioned correspondence, retrieve the CAD object records before and after the execution of commands within each historical drawing action segment; S42. Using CAD objects as nodes, select the corresponding parameters from key point coordinates, length, radius, angle, size values ​​and object attributes according to the object type, and write them into the node features; S43. Write dependency edges between nodes that share key points, share geometric datum, are collinear, concentric, tangent, or have dimensional constraints. S44. Arrange the node features and dependent edges after each state change according to the command execution time, and sequentially extract the preceding state sequence with each non-terminal state as the end to form a sample sequence. Write the change in object parameters of the map action segment's ending state relative to the corresponding non-terminal state into the sample label.

6. The adaptive optimization method for CAD drawing parameters based on big data processing according to claim 1, characterized in that, The improved MTGNN model includes multiple cascaded propagation stages, each of which includes a first temporal convolutional layer, a first hybrid hop graph propagation layer, a second hybrid hop graph propagation layer, a second temporal convolutional layer, and an adjacency update layer. The first temporal convolutional layer is connected to the first hybrid jump graph propagation layer, and the second hybrid jump graph propagation layer is connected to the second temporal convolutional layer; Two temporal convolutional layers within the same propagation level share weights, and two hybrid jump graph propagation layers share weights. The adjacency update layer is connected to the first hybrid jump graph propagation layer, the second temporal convolutional layer, and the current object's adjacency matrix, respectively. The output of the adjacency update layer is connected to the input of the adjacency matrix of the next propagation stage. The output features of the first hybrid jump graph propagation layer and the second temporal convolutional layer are element-wise averaged and then written into the next propagation stage.

7. The adaptive optimization method for CAD drawing parameters based on big data processing according to claim 6, characterized in that, S6 includes: S61. Read the command action object identifier in the current drawing action segment, locate the corresponding CAD object, and read the directly associated objects that have geometric relationships with the corresponding CAD object; S62. According to the object type, read the key point coordinates, length, radius, angle, size value and object attributes one command at a time, and generate node feature records; S63. Arrange the node feature records according to the command execution time to form a node feature sequence, and encode the geometric relationship between the current CAD objects into the current object adjacency matrix; S64. Input the node feature sequence and the current object adjacency matrix into the trained improved MTGNN model, and extract the prediction parameter adjustment amount according to the object identifier.

8. The adaptive optimization method for CAD drawing parameters based on big data processing according to claim 7, characterized in that, S64 includes: S641. Arrange the node feature sequence according to CAD object, parameter type and command time into a node feature tensor, form an initial node hidden feature tensor through channel mapping, and write it into the first propagation stage along with the current object adjacency matrix. S642. The first temporal convolutional layer uses gated dilated temporal convolution to extract temporal features. The first hybrid skip graph propagation layer reads the current object's adjacency matrix and propagates the temporal features. The second hybrid skip graph propagation layer first propagates the node hidden features. The second temporal convolutional layer uses shared weights to perform gated dilated temporal convolution and outputs two sets of node features. S643. The adjacency update layer takes the absolute difference of each element of the two sets of node features, splices the difference features of the two end nodes according to the dependent edge, generates the matrix element correction amount through linear mapping, and normalizes the corrected object adjacency matrix. S644. The two sets of node features are averaged element by element and used as the hidden node features of the next propagation level, and written together with the corrected object adjacency matrix into the next propagation level. S645. The hidden features of the last-level node are converted into parameter adjustment vectors for each node through output mapping, and the predicted parameter adjustment amount is extracted according to the object identifier.

9. The adaptive optimization method for CAD drawing parameters based on big data processing according to claim 1, characterized in that, S7 includes: S71. Read the object identifier, parameter type and adjustment value corresponding to the predicted parameter adjustment amount, and locate the CAD entity record according to the object identifier; S72. According to the CAD object type, map the parameter type to the corresponding dimension value, key point coordinate, radius, angle or object attribute field; S73. Read the current parameter value of the corresponding field, add the current parameter value to the adjustment value, and generate the parameter value to be written; S74. In the same write transaction, batch update the corresponding fields of each CAD object and record the parameter values ​​before the update.

10. The adaptive optimization method for CAD drawing parameters based on big data processing according to claim 1, characterized in that, S8 includes: S81. Read the geometric constraint records of the CAD object after parameter adjustment, and divide the constraint solution object group according to the constraint-related objects; S82. Set the adjusted CAD object parameters as the driving parameters of the CAD geometric constraint solver, and calculate the key point coordinates and geometric definition parameters of the CAD objects in each object group. S83. Write the solution results into the corresponding CAD entity record, and regenerate the graphics for the parameter adjustment objects, constraint associated objects and associated dimensions; S84. Read the constraint solution status and the regenerated object record, and verify the geometric relationship and dimension association status corresponding to each CAD constraint; S85. If the constraint solution is conflict-free and the verification passes, retain the parameter adjustment results; otherwise, restore the object parameters before parameter adjustment and regenerate the graph.