Engineering drawing label layout method and model training method
By automating the adjustment of engineering drawing labels through layout adjustment models, the problems of time-consuming, labor-intensive, and inconsistent manual layout are solved, achieving an efficient, aesthetically pleasing, and uniform label layout, thereby improving the quality of engineering drawings and design efficiency.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-01-29
- Publication Date
- 2026-03-31
AI Technical Summary
In the existing technology, the layout of labels on engineering drawings relies on manual operation, which is time-consuming and labor-intensive, and it is difficult to guarantee the overall quality, visual aesthetics and consistency of the label layout. Problems such as labels overlapping each other, overlapping with part elements or uneven distribution are prone to occur.
By acquiring the layout status information of the engineering drawing, the label is automatically adjusted using a layout adjustment model, including a combination of graph neural networks, attention networks, and policy networks, to optimize the label position and angle, so as to achieve a layout in which the label and the part do not overlap.
It significantly improves design efficiency and layout quality, generating non-overlapping, evenly distributed, and aesthetically pleasing engineering drawing layouts that adapt to different types and complexities of engineering drawings, freeing up designers and meeting the needs of modern engineering design.
Smart Images

Figure CN121598460B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of artificial intelligence technology, and in particular to the fields of image processing, engineering drawing label layout, deep learning, and model training, specifically to engineering drawing label layout methods and model training methods. Background Technology
[0002] In various engineering drawing fields such as mechanical design, architectural engineering, and electronic circuits, labels on drawings carry dimensions, tolerance requirements, material specifications, part numbers, and other key annotation information. The clarity, accuracy, and logical layout of these labels are crucial for the readability of the drawings, the effectiveness of production guidance, and subsequent archiving and management. Currently, the label layout of engineering drawings still largely relies on manual operation by designers. This traditional method is not only time-consuming and labor-intensive, especially when dealing with complex drawings containing numerous labels, but also inefficient. Furthermore, due to differences in designers' experience and subjective judgment, it is difficult to guarantee the overall quality, visual appeal, and consistency of the label layout, easily leading to problems such as labels overlapping, intersecting with part elements, or uneven distribution. With the rapid development of computer-aided design technology, the need for automatic label layout technology is becoming increasingly urgent. Summary of the Invention
[0003] This application provides a method for laying out labels on engineering drawings and a method for training models.
[0004] According to one aspect of this application, an engineering drawing label layout method is provided, comprising: acquiring an engineering drawing, wherein parts and labels for describing the parts are laid out on the engineering drawing; performing layout recognition on the engineering drawing to obtain layout state information of the engineering drawing, wherein the layout state information includes at least one of the following: part attribute information for describing the layout state of the parts, label attribute information for describing the layout state of the labels, part label relationship information for describing the association relationship between the parts and the labels, and label relationship information for describing the positional relationship between multiple labels; inputting the layout state information into a layout adjustment model to obtain label action information; and adjusting at least one label in the engineering drawing according to the label action information to obtain an optimized engineering drawing, so that the multiple labels and multiple parts in the optimized engineering drawing do not overlap with each other.
[0005] According to another aspect of this application, a method for training a model is provided, comprising: acquiring sample layout state information of a sample engineering drawing, wherein the sample engineering drawing includes parts and labels for describing the parts, and the sample layout state information includes at least one of the following: sample part attribute information for describing the layout state of the parts, sample label attribute information for describing the layout state of the labels, sample part label relationship information for describing the relationship between the parts and the labels, and sample label relationship information for describing the positional relationship between multiple labels; inputting the sample layout state information into an initial layout adjustment model to obtain sample label action information; performing uniform distribution recognition based on the sample label action information and the sample layout state information to determine uniform distribution reward values between multiple labels; performing overlap recognition based on the sample label action information and the sample layout state information to determine target overlap reward values between the parts and the labels; performing movement recognition based on the sample label action information to determine movement distance reward values; and adjusting the parameters of the initial layout adjustment model based on the uniform distribution reward values, the target overlap reward values, and the movement distance reward values to obtain a layout adjustment model.
[0006] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of this application, nor is it intended to limit the scope of this application. Other features of this application will become readily apparent from the following description. Attached Figure Description
[0007] The above-mentioned contents, other objects, features and advantages of this application will become clearer from the following description of embodiments of this application with reference to the accompanying drawings.
[0008] Figure 1 An exemplary system architecture of a drawing label layout method and apparatus according to an embodiment of this application is shown.
[0009] Figure 2 A flowchart of a drawing label layout method according to an embodiment of this application is shown.
[0010] Figure 3 An engineering drawing provided in an embodiment of this application is shown.
[0011] Figure 4 An optimized engineering diagram according to an embodiment of this application is shown.
[0012] Figure 5 A flowchart illustrating a method for laying out engineering drawing labels according to an embodiment of this application is shown.
[0013] Figure 6 A flowchart of a training method for a model according to an embodiment of this application is shown.
[0014] Figure 7 A schematic diagram illustrating the determination of a uniformly distributed reward value according to an embodiment of this application is shown.
[0015] Figure 8 A schematic diagram of model training according to an embodiment of this application is shown.
[0016] Figure 9 A block diagram of an electronic device suitable for implementing a drawing label layout method according to an embodiment of this application is shown. Detailed Implementation
[0017] The embodiments of this application will now be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of this application. In the following detailed description, numerous specific details are set forth to provide a thorough understanding of the embodiments of this application for ease of explanation. However, it will be apparent that one or more embodiments may be implemented without these specific details. Furthermore, descriptions of well-known structures and technologies are omitted in the following description to avoid unnecessarily obscuring the concepts of this application.
[0018] The terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the scope of this application. The terms “comprising,” “including,” etc., as used herein indicate the presence of the stated features, steps, operations, and / or components, but do not exclude the presence or addition of one or more other features, steps, operations, or components.
[0019] All terms used herein (including technical and scientific terms) have the meanings commonly understood by those skilled in the art, unless otherwise defined. It should be noted that the terms used herein are to be interpreted in a manner consistent with the context of this specification, and not in an idealized or overly rigid way.
[0020] When using expressions such as "at least one of A, B and C", they should generally be interpreted in accordance with the meaning that is commonly understood by those skilled in the art (e.g., "a system having at least one of A, B and C" should include, but is not limited to, a system having A alone, a system having B alone, a system having C alone, a system having A and B, a system having A and C, a system having B and C, and / or a system having A, B and C, etc.).
[0021] To address the shortcomings of existing manual layout methods, such as time-consuming and labor-intensive processes and poor consistency, as well as the deficiencies of traditional automatic layout methods in terms of adaptability, layout aesthetics, avoidance of critical parts areas, and computational efficiency, this invention provides an automatic layout method for engineering drawing labels. The method includes: acquiring an engineering drawing, wherein parts and labels describing the parts are laid out on the drawing; performing layout recognition on the engineering drawing to obtain layout state information, wherein the layout state information includes at least one of the following: part attribute information describing the layout state of the parts, label attribute information describing the layout state of the labels, part-label relationship information describing the association between parts and labels, and label relationship information describing the positional relationship between multiple labels; inputting the layout state information into a layout adjustment model to obtain label action information; and adjusting at least one label in the engineering drawing according to the label action information to obtain an optimized engineering drawing, such that multiple labels and multiple parts in the optimized engineering drawing do not overlap.
[0022] According to the engineering drawing label layout method provided in the embodiments of this application, the label position and angle can be optimized and adjusted under complex constraints by a layout adjustment model, thereby achieving efficient, beautiful and practical automatic layout.
[0023] Figure 1 An exemplary system architecture of a drawing label layout method and apparatus according to an embodiment of this application is shown.
[0024] like Figure 1 As shown, the system architecture 100 according to this embodiment may include a first terminal device 101, a second terminal device 102, a third terminal device 103, a network 104, and a server 105. The network 104 serves as a medium for providing communication links between the first terminal device 101, the second terminal device 102, the third terminal device 103, and the server 105. The network 104 may include various connection types, such as wired or wireless communication links, or fiber optic cables, etc.
[0025] Users can use the first terminal device 101, the second terminal device 102, and the third terminal device 103 to interact with the server 105 via the network 104 to receive or send messages, etc. Various communication client applications can be installed on the first terminal device 101, the second terminal device 102, and the third terminal device 103, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social media platform software, etc. (for example only).
[0026] The first terminal device 101, the second terminal device 102, and the third terminal device 103 can be various electronic devices with displays and support web browsing, including but not limited to smartphones, tablets, laptops, and desktop computers.
[0027] Server 105 can be a server that provides various services, such as a backend management server that supports websites browsed by users using the first terminal device 101, the second terminal device 102, and the third terminal device 103 (this is just an example). The backend management server can analyze and process data such as received user requests, and feed back the processing results (such as web pages, information, or data obtained or generated according to user requests) to the terminal devices.
[0028] It should be noted that the drawing label layout method provided in this application embodiment can generally be executed by server 105. Correspondingly, the drawing label layout device provided in this application embodiment can generally be located in server 105. The model training method provided in this application embodiment can also be executed by a server or server cluster that is different from server 105 and capable of communicating with the first terminal device 101, the second terminal device 102, the third terminal device 103, and / or server 105. Correspondingly, the model training device provided in this application embodiment can also be located in a server or server cluster that is different from server 105 and capable of communicating with the first terminal device 101, the second terminal device 102, the third terminal device 103, and / or server 105.
[0029] It should be understood that Figure 1 The number of first terminal devices, second terminal devices, third terminal devices, networks, and servers shown in the diagram is merely illustrative. Depending on implementation needs, any number of first terminal devices, second terminal devices, third terminal devices, networks, and servers can be included.
[0030] The following will be based on Figure 1 The described scene, through Figures 2-5 The engineering drawing label layout method of the embodiments of this application will be described in detail.
[0031] Figure 2 A flowchart of a drawing label layout method according to an embodiment of this application is shown.
[0032] like Figure 2 As shown, the engineering drawing label layout method of the embodiment of this application includes steps S201 to S204.
[0033] In step S201, the engineering drawing is obtained.
[0034] In this embodiment, the engineering drawing includes parts and labels describing the parts. The engineering drawing can refer to a two-dimensional digital drawing file containing at least one part and at least one descriptive label. Parts can include mechanical parts, building components, or electronic components. Labels can include text or annotation symbols describing these parts, such as dimension information, tolerance symbols, part numbers, technical specifications, etc. The engineering drawing can be a two-dimensional drawing file or image file from computer-aided design software, such as drawings in DWG format (Drawing), DXF format (Drawing Exchange Format), or images in PNG format (Portable Network Graphics), JPG format (Joint Photographic Experts Group), from AutoCAD or SolidWorks design software.
[0035] In step S202, the layout of the engineering drawing is identified to obtain the layout status information of the engineering drawing.
[0036] In this embodiment of the application, the engineering drawing is parsed and features are extracted to convert the visualized image information into digital state description information that can be understood by a computer. At least one of the following is extracted: part attribute information for describing the layout state of the parts, label attribute information for describing the layout state of the labels, part label relationship information for describing the relationship between parts and labels, and label relationship information for describing the positional relationship between multiple labels.
[0037] According to embodiments of this application, layout recognition can be analyzed using image recognition technology and processed using computer vision technology, such as automatically detecting graphic outlines and recognizing text in images.
[0038] In step S203, the layout status information is input into the layout adjustment model to obtain the label action information.
[0039] According to an embodiment of this application, the layout state information obtained in step S202 is input into a pre-trained layout adjustment model. The layout adjustment model may include one or more of the following: graph neural network, attention network, long short-term memory network, autoencoder, convolutional neural network, and multilayer perceptron.
[0040] In a preferred embodiment, the Proximal Policy Optimization (PPO) algorithm can be used to train the initial layout adjustment model to obtain the policy.
[0041] In step S204, at least one label in the engineering drawing is adjusted according to the label action information to obtain the optimized engineering drawing.
[0042] In this embodiment, the layout adjustment model outputs label action information. Label action information can be understood as specific adjustment instructions for each label or label group, including position offset information and angle offset information. Based on these adjustment instructions, the labels are updated to obtain the optimized engineering drawing.
[0043] In this embodiment, after the layout update is completed, the layout of the updated engineering drawing can be automatically checked for compliance. The goal of the check can be to see if the area occupied by each label overlaps with the parts and with other labels, which can be achieved by calculating the area of their intersections. If there is no overlap, the layout can be determined to be qualified.
[0044] If the check still finds overlaps, it means that the adjustment has not fully achieved the goal. At this time, the layout adjustment model can be called up to recalculate the optimization, or a small-scale adjustment can be made on the existing basis. This process can be repeated until all labels and parts no longer overlap, so that multiple labels and multiple parts in the optimized engineering drawing do not overlap with each other.
[0045] According to the embodiments of this application, the automated layout method of the layout adjustment model significantly improves design efficiency and layout quality. It can not only quickly generate non-overlapping, evenly distributed and beautiful engineering drawing layouts, but also adapt to engineering drawings of different types and complexities. In addition, the information referenced by the layout adjustment model only includes layout state information, which can be determined by layout recognition, making it readily available and effective.
[0046] According to a related example of this application, engineering drawings can be adjusted based on preset rules to obtain optimized engineering drawings. However, it is often difficult to exhaust all cases, resulting in insufficient adaptability and poor layout effect when faced with complex, varied, and diverse engineering drawings.
[0047] According to another related example of this application, the core content of an engineering drawing is the part itself, and labels, as supplementary information, should not obscure the key contours, features, or dimension lines of the part. However, many existing methods lack effective identification and intelligent avoidance of part areas, which can easily lead to labels covering important part information and affecting the complete transmission of drawing information.
[0048] According to another related example of this application, the label positions in engineering drawings can be optimized based on iterative optimization or search algorithms. However, when dealing with large-scale label sets or complex drawings, the computational efficiency is low and the convergence speed is slow, making it difficult to meet the pursuit of high efficiency in modern engineering design and limiting its application in actual production environments.
[0049] The engineering drawing label layout method provided in this application enables automated label adjustment, freeing designers from tedious manual adjustments and significantly shortening drawing completion time. It comprehensively considers multiple constraints and objectives, such as avoiding overlap, uniform distribution, and avoiding critical areas of parts, ensuring that labels are evenly distributed and visually appealing on the engineering drawing, while proactively avoiding key information areas of parts. This improves layout quality and design efficiency, meeting the practical needs of modern engineering design.
[0050] In the embodiments of this application, for example, Figure 2 In step S201, the initial engineering drawing can be a drawing including parts designed by an engineer. Alternatively, it can be an engineering drawing containing parts and randomly arranged labels, generated in response to a generation command triggered by a user in the drafting software, by configuring labels for each part in the initial engineering drawing using the drafting software.
[0051] Figure 3 An engineering drawing provided in an embodiment of this application is shown.
[0052] like Figure 3 As shown, the engineering drawing contains parts (see...). Figure 3 A hollow base that is wider at the top and narrower at the bottom) and labels automatically generated for the parts using drafting software (see...). Figure 3 (The drawings contain numerical identifiers with lead lines, etc.), but there is some overlap between parts and labels, and between multiple labels, which makes the information displayed in the engineering drawings incomplete.
[0053] Automating the labeling of parts in initial engineering drawings using drafting software can improve automation and reduce the workload of designers. However, problems such as labels overlapping, overlapping with part elements, or uneven distribution can easily occur. This affects the readability of the drawings and the effectiveness of production guidance. The following will explain how to perform layout recognition on engineering drawings and adjust labels based on the layout status information obtained from layout recognition, so that the labels in the optimized engineering drawings are clear, accurate, and reasonable.
[0054] In this embodiment, layout recognition is performed on the engineering drawing, and the resulting layout status information includes at least one of the following: label attribute information, part attribute information, part label relationship information, and label relationship information. This process achieves a complete and computable digital description of the drawing layout status, providing an accurate and reliable data foundation for subsequent layout adjustment model decisions. This ensures that the layout adjustment model can be optimized based on a deep understanding of the drawing, which is a key prerequisite for achieving high-quality automated layout.
[0055] Different types of layout status information may require different layout recognition methods.
[0056] For example, determining label attribute information may include: identifying the label from an engineering drawing based on its label feature information; and determining the label's size and position information to obtain the label attribute information.
[0057] In a CAD (Computer-Aided Design) system, label feature information can be represented as a specific entity type, such as multi-line text, its layer, or specific block attributes. The label's outline information can be represented by the vertex coordinates of its bounding box. Position information can be represented by the (x, y) coordinates of the center point of the label's bounding box.
[0058] In this embodiment, based on the feature information of the labels, an image recognition model is used to accurately locate the labels from the engineering drawing, determine the size and position information of the labels, and obtain the label attribute information. The image recognition model may include one or more layers of convolutional layers, graph neural network layers, long short-term memory networks, and attention mechanisms. Thus, using the engineering drawing as input, labels with label feature information are identified, and the size and position information of the labels are marked as label attribute information.
[0059] Label attribute information can include the size (width, height) of each label, initial position coordinates (e.g., center point x, y coordinates), rotation angle, and the anchor point coordinates of its associated parts.
[0060] For example, determining part attribute information may include: determining the part from the engineering drawing based on the part feature information; determining the part's contour information and position information to obtain the part attribute information.
[0061] Similar to the method for determining label attribute information, image recognition models can be used to identify parts from engineering drawings based on part feature information. The contour and position information of the parts are then marked to obtain part attribute information. Optionally, for two-dimensional drawings, part feature information can be represented as a contour composed of closed polylines, a specific fill pattern, or a component referenced as a block. To simplify calculations, the contour information of a part can be represented by a convex hull. For complex assembly drawings, which may contain multiple parts, the contour information of each part needs to be extracted and labeled separately. The contour information of a part can be represented by the vertex coordinate sequence of the actual contour polygon or by the vertex coordinates of the convex hull; this method simplifies calculations. Position information can be represented by the (x, y) coordinates of the center point of the bounding box of the part or label.
[0062] For example, determining part label relationship information may include: determining the parts and labels associated with the lead wires based on the anchor point information of the lead wires used to associate parts and labels, thereby obtaining part label relationship information.
[0063] The association between parts and labels can be established using leader lines in engineering drawings. Leader lines are used for binding and associating labels with parts. Anchor points can be the points where leader lines originate. Based on the anchor point information of the leader lines used to associate parts and labels, the parts and labels associated with the leader lines are identified, and the part-label relationship information is obtained. This method can clearly identify the specific part object described by the label and maintain the logical consistency of the drawings.
[0064] For example, determining label relationship information can include: determining the relative position information between multiple labels to obtain label relationship information.
[0065] Identify information such as relative position vectors and distances between labels. Determine the relative position information between multiple labels to obtain label relationship information.
[0066] According to embodiments of this application, the layout recognition described above enhances the layout adjustment model's ability as an agent to perceive the "overall layout structure" of the engineering drawing, improves policy stability and convergence speed, enhances the policy's understanding of spatial structure, and helps it learn more reliable layout rules. This provides a key prerequisite for achieving high-quality, automated label layout.
[0067] In embodiments of this application, the engineering drawing label layout method may further include, during the process of obtaining layout state information, performing group association identification on multiple labels to obtain identification results. If the identification results indicate that multiple labels belong to the same label group, the label attribute information of the label group is determined based on the label attribute information of each label in the label group, so that the label attribute information of the label group can be processed using a layout adjustment model.
[0068] Multiple labels can be grouped and identified to obtain recognition results, such as multiple labels forming a dimension chain or grouped annotations. Labels within the same label group are evenly distributed, and the annotation information is interconnected. Splitting is generally not recommended. Therefore, the overall label attribute information of the label group can be determined. For example, the layout adjustment model processes the label attribute information of the label group and outputs adjustment actions applicable to the entire group, performing a uniform translation or rotation on the entire label group during execution. This method maintains the logical layout relationship between labels within the group while simplifying movement operations and improving the overall efficiency of model layout optimization.
[0069] According to an embodiment of this application, after obtaining the layout state information, the layout state information can be input into the layout adjustment model to obtain the label action information.
[0070] In embodiments of this application, the layout adjustment model may include a graph neural network, an attention network, and a policy network.
[0071] The layout state information is input into the layout adjustment model to obtain label action information. This can include: inputting the layout state information into a graph neural network to perform feature representation of the layout state information using the graph neural network, obtaining layout state features; inputting the layout state features into an attention network to extract attention features, obtaining attention state features; and inputting the attention state features into a policy network to obtain label action information.
[0072] The layout adjustment model employs a three-layer processing architecture to progressively parse the input layout state information. The first layer uses a graph neural network to perform structured analysis of the labels, parts, and their spatial relationships within the layout state information, forming relevant feature representations and obtaining layout state features. The second layer uses an attention network to assign different weights to these layout state features, increasing the model's attention to key locations such as dense areas and potential conflict areas in the layout, thereby improving the understanding of the overall layout structure and forming attention state features. The third layer inputs the attention state features into a policy network, which integrates all information to make decisions and outputs label action information, i.e., specific adjustment instructions controlling the translation and rotation of each label. Through this layer-by-layer processing approach from global to local to comprehensive decision-making, the model can deeply understand the complex structure and constraints of the layout and generate precise adjustment actions, ultimately achieving high-quality and efficient automatic label layout results.
[0073] Graph neural networks can extract and represent features from layout state information with complex relationships. For example, a layout adjustment model can model the entire layout as a graph structure, where each part and each label is considered a node. If there is a relationship or proximity between two nodes, the logical connection between the two nodes is an edge. Through a message passing mechanism, the graph neural network enables each node to update its feature representation based on the information of its associated nodes. This ensures that each node's features include its own information, the features of its associated nodes, and the information of its surrounding nodes, thereby extracting layout state features that contain both global structure and local context. This allows for a more flexible and clearer understanding of the local positional relationships between labels and parts, making layout adjustment decisions more consistent with actual spatial logic.
[0074] The layout state features output by the graph neural network are further processed and analyzed using an attention network. The importance weights of features in different regions are automatically assigned, highlighting key regions with high overlap or dense labels, ensuring that the system can prioritize these key issues, thereby obtaining attention state features.
[0075] Attention networks can be used to process layout state features to obtain attention state features. The network structure of the attention network is not limited; for example, it can include self-attention mechanism layers, multi-head attention mechanism layers, and cross-attention mechanism layers. For instance, a multi-head attention mechanism layer can be used to divide the layout state features into multiple independent groups along different dimensions. Each group analyzes and weights the features from a different perspective, and the analysis results are then concatenated and integrated into the final output. This method enables the model to capture multifaceted information about the layout in parallel and comprehensively, thereby improving the overall understanding of complex layout states and the quality of decision-making.
[0076] Attention state features can be processed using policy networks to obtain label action information. Policy networks can include, but are not limited to, multilayer perceptrons (MLPs). The MLP calculates the optimal translation and rotation parameters for each label, such as (Δx, Δy, Δθ). Δx represents the horizontal position offset, Δy represents the vertical position offset, and Δθ represents the angular offset.
[0077] According to embodiments of this application, the graph neural network in the layout adjustment model enhances the modeling ability of spatial relationships between labels and between labels and parts. The attention network effectively understands local dense areas and potential overlapping areas of labels, thereby improving layout optimization performance. The policy network maps discrete data onto a single output dataset, thus preventing label action information from deviating from the target. In summary, the design of this layout adjustment model improves the ability to analyze complex layouts, the targeting of optimization decisions, and the efficiency and effectiveness of overall layout adjustment.
[0078] The following section provides a detailed explanation of how to adjust labels using the label action information output by the layout adjustment model.
[0079] In the embodiments of this application, the label action information output by the layout adjustment model is a specific instruction to guide the label to be adjusted, including position offset information and angle offset information.
[0080] According to embodiments of this application, for example, Figure 2 Step S204, as shown, involves adjusting at least one label in the initial engineering drawing according to the label action information to obtain an optimized engineering drawing. This step may include: determining the label's movement distance based on the offset value in the position offset information; determining the label's movement direction based on the sign of the numerical value in the position offset information; moving the label in the engineering drawing based on the movement distance and movement direction to obtain a label with adjusted position; determining the label's rotation angle based on the rotation value in the angle offset information; determining the label's rotation direction based on the sign of the numerical value in the angle offset information; and rotating the label in the engineering drawing based on the rotation angle and rotation direction to obtain a rotated label.
[0081] Upon receiving instructions to move and rotate, the labels can be precisely adjusted accordingly. This not only efficiently addresses objectives such as avoiding overlap and ensuring even distribution, but also allows for a refined approach to the optimal layout with each adjustment, preventing instability or chaos that could result from large, drastic jumps in adjustments.
[0082] Translational movements based on positional offset information can be represented by continuous numerical values. The absolute values of Δx and Δy (also called offset values) represent the distance moved. The numerical signs correspond to the horizontal and vertical directions of movement, respectively. Δx > 0 indicates movement to the right, Δx < 0 indicates movement to the left, Δy > 0 indicates movement upwards, and Δy < 0 indicates movement downwards. The center point of the label is moved by the corresponding offset value in the specified horizontal and vertical directions, for example, (Δx, Δy), thus completing the translation.
[0083] The rotation is based on angular offset information, where Δθ is represented by a signed continuous value. The rotation value in the angular offset information indicates the rotation amplitude. A positive sign indicates counter-clockwise rotation, and a negative sign indicates clockwise rotation, thus completely determining the rotation direction. The label is rotated by a specified angle (Δθ) around its center point. After rotation, the positions of the label's four corners and its orientation are updated synchronously, completing the rotation.
[0084] According to embodiments of this application, the above adjustment steps can be implemented using different techniques. For example, each label can be treated as a geometric object with coordinates and angles, and the program can perform all calculations internally, directly performing mathematical calculations on the initial coordinates and angles of the label to obtain the updated position and angle. Another technique is for the program to convert the label action information into a standard form of command that can be executed by professional drawing software (such as AutoCAD), and then the drawing software can execute the movement or rotation steps.
[0085] This method makes the optimization process stable and smooth by continuously fine-tuning the position and angle of the labels. It can accurately and quickly achieve all our preset layout requirements, such as labels not overlapping and being evenly distributed, ultimately resulting in an ideal layout that is both neat and practical.
[0086] According to an optional embodiment of this application, when the tag action information represents the tag action information of a tag group, adjusting at least one tag in the engineering drawing according to the tag action information to obtain an optimized engineering drawing may include: adjusting the tag group in the engineering drawing according to the tag action information of the tag group in the tag action information to obtain an optimized engineering drawing.
[0087] By utilizing the tag action information of the tag group provided in the embodiments of this application, the efficiency of tag adjustment can be improved, while also enhancing the standardization and aesthetics of tag adjustment.
[0088] In the embodiments of this application, the engineering drawing is adjusted according to the tag action information to obtain an optimized engineering drawing. However, it is not limited to this. The engineering drawing obtained after adjusting the tags can also be used as the initial optimized engineering drawing. The initial optimized engineering drawing is then verified to obtain the verification result.
[0089] Verification may include at least one of the following: whether there is overlap between parts and labels, and whether there is overlap between multiple labels. If there is no overlap between labels and parts, and no overlap between multiple labels, the initially optimized engineering drawing is considered normal. Conversely, if any two parts overlap between labels and parts, or between multiple labels, the initially optimized engineering drawing is considered abnormal.
[0090] The system checks whether part-label overlap and label-label overlap have been eliminated. If the check passes, it indicates that the initial optimized engineering drawing is optimized correctly, and the initial optimized engineering drawing is the optimized engineering drawing. If the check fails, it indicates that the initial optimized engineering drawing is abnormally optimized. New layout state information is generated based on the initial optimized engineering drawing and input again into the layout adjustment model for optimization until the optimized engineering drawing passes the check, resulting in the optimized engineering drawing. This process not only significantly improves the reliability and compliance of the layout results but also, through multiple rounds of progressive optimization, allows the layout to better balance uniformity and aesthetics while meeting the non-overlapping constraint.
[0091] Figure 4 An optimized engineering diagram according to an embodiment of this application is shown.
[0092] like Figure 4 The optimized engineering drawing shown is based on, for example: Figure 3 The diagram shown was obtained by adjusting the labels. Figure 4 The optimized engineering drawing shows no overlap between labels or between labels and parts, and the label layout is reasonable, uniform, and aesthetically pleasing. This improves the readability of the engineering drawing and the effectiveness of production guidance.
[0093] According to an optional embodiment of this application, when verifying the overlap between a part and a label, this can be achieved by calculating the actual overlap area between the label bounding box and the part region. The core method is to use a polygon clipping algorithm to calculate the overlap area. For example, the Sutherland-Hodgman (edge-by-edge clipping) algorithm, which is suitable for convex polygons, or the Weiler-Atherton (Weiler-Atherton) algorithm, which is suitable for complex non-convex shapes with holes, can be used for the calculation.
[0094] When verifying overlap between labels, the Separating Axis Theorem (SAT) can be used. This method treats each label as a rotated rectangular bounding box and selects four axes formed by the normal vectors on the two sides of each rectangular label as projection axes. For each projection axis, the projection intervals of the two rectangles on that axis are calculated, and then each axis is checked sequentially: if there is at least one axis such that the projection intervals of the two rectangles do not overlap, it proves that the two rectangles can be completely separated by a straight line parallel to that axis in that direction, thus determining that they do not overlap. If the projection intervals of the two rectangles overlap on all four projection axes, it proves that the two rectangles are inseparable in all possible separation directions, thus determining that they overlap.
[0095] This method effectively improves the reliability and aesthetics of the layout results, enabling the final drawings to eliminate all overlapping conflicts while also better balancing the uniformity and coordination of label distribution, thereby outputting high-quality, directly usable engineering drawings.
[0096] Figure 5 A flowchart illustrating a method for laying out engineering drawing labels according to an embodiment of this application is shown.
[0097] like Figure 5 As shown, the method includes performing layout recognition on the acquired engineering drawing to obtain the layout status information of the engineering drawing.
[0098] The layout state information is input into the layout adjustment model to obtain the label action information.
[0099] Adjust at least one label in the engineering drawing according to the label action information to obtain the initial optimized engineering drawing.
[0100] The initial optimized engineering drawings were verified, and the verification results were obtained.
[0101] If the verification results indicate that the initial optimized engineering drawing is normal, the initial optimized engineering drawing will be used as the optimized engineering drawing.
[0102] If the verification result indicates that the initial optimized engineering drawing is abnormal, the initial optimized engineering drawing is used as the new engineering drawing, and the above steps of layout recognition, obtaining label action information, and label adjustment are repeated until an optimized engineering drawing with a normal verification result is obtained.
[0103] The previous section explained in detail how to obtain label action information using the layout adjustment model and how to use the label action information to adjust the labels in the engineering drawing. The following section will explain how to train the layout adjustment model.
[0104] Figure 6 A flowchart of a training method for a model according to an embodiment of this application is shown.
[0105] like Figure 6 As shown, the method includes steps S610 to S660.
[0106] In step S610, the sample layout status information of the sample engineering drawing is obtained.
[0107] In step S620, the sample layout state information is input into the initial layout adjustment model to obtain the sample label action information.
[0108] In step S630, based on the sample label action information and sample layout state information, uniform distribution recognition is performed to determine the uniform distribution reward value among multiple labels.
[0109] In step S640, based on the sample tag action information and sample layout state information, overlap recognition is performed to determine the target overlap reward value between the parts and tags.
[0110] In step S650, based on the sample label action information, motion recognition is performed to determine the motion distance reward value.
[0111] In step S660, the parameters of the initial layout adjustment model are adjusted based on the uniform distribution reward value, the target overlap reward value, and the movement distance reward value to obtain the layout adjustment model.
[0112] The sample engineering drawing includes parts and labels used to describe the parts. The sample layout status information includes at least one of the following: sample part attribute information used to describe the layout status of the parts, sample label attribute information used to describe the layout status of the labels, sample part label relationship information used to describe the relationship between the parts and the labels, and sample label relationship information used to describe the positional relationship between multiple labels.
[0113] It should be noted that the difference between "engineering drawing, layout status information, and label action information" and "sample engineering drawing, sample layout status information, and label action information" provided in the embodiments of this application is the difference in terminology, which is used to indicate that they are applied in different embodiments. Their explanations or descriptions may be the same or similar, and will not be elaborated here.
[0114] In the embodiments of this application, the initial layout adjustment model can be constructed through various training methods. In a preferred embodiment, the initial layout adjustment model can be a policy model trained based on reinforcement learning. Specifically, the reinforcement learning model can be trained as a whole through repeated trials. Reinforcement learning operates on interdependent state-action-reward data tuples. The mathematical framework of reinforcement learning is mainly built on the following components: a state space, which can contain all available information related to the decisions the model may make; an action space, which can contain all decisions the model can make at a given moment. For example, in label layout adjustment, the action space contains all legal moves available at that time; a reward function, which determines the positive (or negative) feedback provided to the model after each action and converts it into a reward signal: that is, the scalar quantization of the feedback. For example, when using reinforcement learning to train the initial layout adjustment model, the reward function may incentivize moves that increase the probability of uniform distribution while inhibiting moves that reduce the probability of overlap; and a policy, which can be the "thought process" that drives the behavior of the reinforcement learning agent. Mathematically, a policy (π) is a function that takes a state (s) as input and returns an action (a): π(s) → a.
[0115] The goal of reinforcement learning algorithms is to optimize a policy to produce the maximum reward. In deep reinforcement learning, the policy is represented as a neural network whose parameters are continuously updated to maximize the reward function. In reinforcement learning, a model (or an agent powered by a model) interacts with the environment to earn a reward through correct steps. These parameters typically define a policy or value function to estimate the expected reward. The model updates its parameters by comparing the predicted reward with the reward actually earned.
[0116] In the embodiments of this application, sample label action information is obtained through an initial layout adjustment model. Based on the sample label action information and sample layout state information, a reward function is used to determine the target overlap reward value and the movement distance reward value between the parts and labels.
[0117] According to embodiments of this application, the reward function may include one or more of the following: uniform distribution reward function, coverage reward function, neatness reward function, avoidance of intrusion into part areas reward function, avoidance of overlap reward function, maintaining safe distance reward function, minimum movement reward function, and time efficiency reward function.
[0118] In the embodiments of this application, the parameters of the initial layout adjustment model are adjusted based on the uniform distribution reward value, the target overlap reward value, and the movement distance reward value to obtain the layout adjustment model. In a preferred embodiment, the Proximal Policy Optimization (PPO) algorithm is used to train the initial layout adjustment model. During training, the parameters of the initial layout adjustment model are adjusted, and the constructed label layout environment interacts through continuous trial and error (exploration) and the use of existing experience (expitation), and the parameters of the model are updated using data. This process is repeated until the performance of the initial layout model tends to stabilize or reaches the pre-set upper limit of training times.
[0119] By limiting the magnitude of each parameter update, the PPO algorithm improves sample utilization efficiency while ensuring learning stability.
[0120] According to embodiments of this application, sample label action information is obtained using sample layout state information and an initial layout adjustment model. This allows for the determination of target overlap reward values between parts and labels, resulting in a more uniform distribution of labels within the available space of the drawing. This ensures that labels do not obscure or obscure as little as possible the key information of parts, prevents labels from overlapping, and ensures that each label's information is clearly readable. Determining the movement distance reward value using sample label action information encourages the initial layout adjustment model to achieve the optimization goal with smaller adjustments, avoiding excessive and unnecessary movement of labels from their initial positions, and also helps to accelerate convergence. Furthermore, based on the uniform distribution reward value, target overlap reward value, and movement distance reward value, the parameters of the initial layout adjustment model are adjusted to obtain a layout adjustment model. This ensures learning stability while improving sample utilization efficiency, enabling it to more effectively understand locally dense areas and potential overlapping areas, thereby improving layout optimization performance.
[0121] Models are typically categorized into one of three different machine learning paradigms: supervised learning, unsupervised learning, or reinforcement learning. For example, supervised learning is used when a model is trained to predict the “correct” output from an input.
[0122] Behavior cloning pre-training can also be understood as supervised learning training. To accelerate the convergence process of reinforcement learning and guide it to explore a better policy space, a small number of high-quality layout cases manually adjusted by experienced designers can be used as expert data before PPO training begins. This is equivalent to letting the agent imitate the behavior patterns of experts first.
[0123] Mathematically, the goal of this type of learning is to minimize the loss function; this function quantifies the error of the model's output during the training task. When the output of the loss function falls below a certain predetermined threshold (meaning the model's error on the training task is small enough), the model is considered "trained." In reinforcement learning, the goal is exactly the opposite: optimizing the model parameters is not to minimize the loss function, but to maximize the reward function.
[0124] In the embodiments of this application, for example, Figure 6 The step S630 shown involves performing uniform distribution recognition based on sample label action information and sample layout state information to determine the uniform distribution reward value among multiple labels.
[0125] Specifically, evenly distributed rewards ( The aim is to distribute labels more evenly within the available space of the drawing. This can be achieved by obtaining sample label attribute information for all samples, such as the center point of the sample labels, and then performing Delaunay triangulation on these point sets.
[0126] Figure 7 A schematic diagram illustrating the determination of a uniformly distributed reward value according to an embodiment of this application is shown.
[0127] Extract the geometric center points of all label regions to be evaluated, for example... Figure 7 The dots in the diagram are denoted as the point set. ,in Let represent the center coordinates of the i-th label. Perform Delaunay triangulation on this set of points across the entire drawing area to obtain a set of triangles. ,like Figure 7 The diagram shows a triangle composed of three dots. For an ideal uniform distribution, all triangles obtained after partitioning should have approximately the same side length; therefore, we use the variance of the triangle's side lengths as an evaluation metric for uniformity. We then construct a set of all the side lengths. The standard deviation of uniformity is defined as ,in This represents the length of the k-th edge. The average of all side lengths Standard deviation The smaller the value, the more evenly the label center points are distributed, and the more reasonable the label layout. Therefore, according to The reward score is allocated based on its size, and a uniformly distributed reward function can be defined as follows: .
[0128] in, To adjust the hyperparameters of the reward change rate. This reward function in... When the value is small, it approaches 1 (i.e., a high reward value). When the reward is large, it rapidly decays to 0 (low reward value), thus effectively encouraging the center points to maintain an approximately equidistant distribution.
[0129] In the embodiments of this application, for example, Figure 6 The step S640 shown, determining the target overlap reward value between parts and labels may include: performing overlap recognition between parts and labels based on sample label action information and sample layout state information, and determining a first overlap reward value between parts and adjusted labels; performing overlap recognition between labels based on sample label action information and sample layout state information, and determining a second overlap reward value between multiple adjusted labels; and determining a target overlap reward value based on the first overlap reward value and the second overlap reward value.
[0130] The first overlap reward value can also be called the intrusion avoidance reward value. This can be achieved using the intrusion avoidance part region reward function (…). The determination is shown in the following formula (1).
[0131] ;Formula (1)
[0132] in The bounding box representing the i-th label can be approximated as a rectangle or any convex polygon; This represents the geometric boundary of the j-th part region (formed by the convex hull of the part profile). The penalty weighting coefficient is used to control the degree of influence of the avoidance of intrusion into the part area reward on the total reward; This represents the actual overlap area between the label bounding box and the corresponding part region. By calculating the overlap area between the bounding box of each label and the part region it belongs to (usually represented by a convex hull), the larger the overlap area, the greater the penalty (negative reward) is given.
[0133] The overlapping area can be accurately calculated using either the Sutherland-Hodgman or Weiler-Atherton polygon clipping algorithms. For convex polygon clipping scenarios, the Sutherland-Hodgman algorithm sequentially uses each edge of the clipping polygon as the clipping boundary, filtering and clipping the input polygon round by round until it gradually shrinks into the final overlapping polygon. For parts with concave structures, holes, or complex geometries, the Weiler-Atherton algorithm can be used. This algorithm records the entry and exit points of the polygons and iteratively constructs the clipped closed polygon along two sets of boundaries, enabling it to handle more complex overlapping relationships such as non-convex polygons and multi-connected regions, thus obtaining an accurate overlapping polygon.
[0134] The second overlapping reward value can also be called the overlapping avoidance reward value. This can be achieved using the overlapping avoidance reward function (…). The determination is shown in the following formula (2).
[0135] ;Formula (2)
[0136] in This represents the bounding box of the j-th label; This is an indicator function that takes the value 1 when the bounding boxes of label i and label j geometrically overlap, and 0 otherwise. The overlap penalty weight coefficient controls the strength of the impact of the overlap avoidance reward on the overall reward. As a penalty, any overlap between two tags will reduce the overall reward value, thereby driving the strategy to avoid overlapping layouts for any two tags.
[0137] In order to calculate the indicator function efficiently and accurately The value of can be used to detect the geometric overlap between labels using the Separating Axis Theorem (SAT). SAT determines whether two polygons intersect by projecting them onto a set of candidate projection axes and determining whether there are non-overlapping gaps between the projection intervals.
[0138] If there exists at least one projection axis that prevents the projection regions of the two polygons from overlapping, then the two are separable along that axis, indicating that the two label bounding boxes do not have geometric overlap, and I=0 in this case; if no separable regions are found on any projection axis, then the two label bounding boxes overlap, and I=1 in this case.
[0139] For common rotated rectangular bounding boxes, SAT detection requires a fixed number of projection axes (two sets of edge vectors for the two rectangles), resulting in low computational cost and suitability for frequent interactive operations in reinforcement learning environments. Leveraging SAT's rapid decision-making capabilities, this reward can reflect label overlap in real time and drive the policy network to generate more distinct and clearer layout results.
[0140] According to the embodiments of this application, the target overlap reward value is determined by weighted summation of the first overlap reward value and the second overlap reward value. This can effectively avoid overlap between tags and ensure that tags actively avoid key information areas of parts, ensuring that there is no overlap between tags or between tags and parts, and ensuring that the information of each tag and part is clearly readable. This comprehensively optimizes the layout effect, improves the coordination between tags and parts, and enhances the overall layout quality of multiple tags.
[0141] In the embodiments of this application, for example, Figure 6 Step S650 shown, determining the movement distance reward value may include: weighted summation of the offset values of the position offset information of multiple tags to obtain the movement distance reward value, wherein the sample tag action information includes the position offset information of each tag, and the position offset information includes the offset value and the sign value representing the positive or negative value.
[0142] According to embodiments of this application, the sample label action information output by the layout adjustment model can be specific quantitative instructions guiding the label adjustment, including information on the direction and distance of position movement and information on the direction and magnitude of rotation. Upon receiving the movement and rotation instructions, the label will be precisely adjusted according to the instructions.
[0143] Specifically, the reward value for the distance traveled can also be called the minimum reward value for the distance traveled. This can be achieved using the minimum reward function (…). The determination is shown in the following formula (3).
[0144] ;Formula (3)
[0145] in This indicates the current center position of the i-th label after layout adjustment in the current decision-making step; This indicates the initial layout position of the i-th label; This represents the square of the Euclidean distance from the initial position to the final position of the label. The subscript "2" indicates that the L2 norm is used, which is the definition of actual geometric distance; the superscript "2" indicates that the distance is squared to increase the penalty for large movements. Let be the movement penalty coefficient, when The larger the value, the more the initial layout adjustment model is constrained by "fewer moves". Since the squared distance is always ≥ 0, this term is always negative. Therefore, larger moves mean larger penalties, i.e., lower rewards. This leads the initial layout adjustment model to prioritize "small-step adjustments" to obtain the optimal layout, rather than making large jumps between labels.
[0146] According to the embodiments of this application, the offset values of the position offset information of multiple tags are weighted and summed to obtain the moving distance reward value. This can encourage the tags to reach the optimization goal with a smaller adjustment range, avoid the tags from moving too much and unnecessary from the initial position, and also help to speed up convergence and obtain higher quality layout results.
[0147] Figure 8 A schematic diagram of model training according to an embodiment of this application is shown.
[0148] like Figure 8 As shown, the layout of the sample engineering drawing is identified to obtain the sample layout status information.
[0149] The sample layout state information is input into the initial layout adjustment model to obtain the sample label action information.
[0150] Based on the sample label action information, determine the uniformly distributed reward value, the minimum movement reward value, the overlap-avoiding reward value, and the intrusion-avoiding reward value.
[0151] The total reward value is obtained by weighting and summing the uniformly distributed reward value, the minimum movement reward value, the overlap avoidance reward value, and the intrusion avoidance reward value.
[0152] The initial layout adjustment model is adjusted based on the total reward value to obtain the layout adjustment model.
[0153] The total reward value can be determined by the following total reward function as shown in formula (4).
[0154] ;Formula (4)
[0155] in, This represents the total reward value. , , and These are the weighting coefficients for each reward item.
[0156] The training method of the model provided in this application can enhance the intelligence and adaptability of the layout. For example, the reinforcement learning-based method has good learning and generalization capabilities, can adapt to engineering drawings of different types and complexities, and can effectively lay out labels of different sizes and numbers. In addition, by combining behavior cloning for pre-training, a small amount of expert data can be used to guide the initial exploration direction of reinforcement learning, accelerate the model convergence speed, and help obtain higher quality layout results. Furthermore, combining the reinforcement learning framework makes it easy to integrate new constraints or optimization objectives, considering the consistency of label orientation, the clarity of leaders, etc., which provides convenience for future functional expansion.
[0157] Figure 9 A block diagram of an electronic device suitable for implementing a drawing label layout method according to an embodiment of this application is shown.
[0158] like Figure 9 As shown, an electronic device 900 according to an embodiment of this application includes a processor 901, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 902 or a program loaded from a storage portion 908 into a random access memory (RAM) 903. The processor 901 may include, for example, a general-purpose microprocessor (e.g., a CPU), an instruction set processor and / or an associated chipset and / or a special-purpose microprocessor (e.g., an application-specific integrated circuit (ASIC)), etc. The processor 901 may also include onboard memory for caching purposes. The processor 901 may include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of this application.
[0159] RAM 903 stores various programs and data required for the operation of electronic device 900. Processor 901, ROM 902, and RAM 903 are interconnected via bus 904. Processor 901 executes various operations of the method flow according to embodiments of this application by executing programs in ROM 902 and / or RAM 903. It should be noted that programs may also be stored in one or more memories other than ROM 902 and RAM 903. Processor 901 may also execute various operations of the method flow according to embodiments of this application by executing programs stored in one or more memories.
[0160] According to embodiments of this application, the electronic device 900 may further include an input / output (I / O) interface 905, which is also connected to a bus 904. The electronic device 900 may also include one or more of the following components connected to the input / output (I / O) interface 905: an input section 906 including a keyboard, mouse, etc.; an output section 907 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 908 including a hard disk, etc.; and a communication section 909 including a network interface card such as a LAN card, modem, etc. The communication section 909 performs communication processing via a network such as the Internet. A drive 910 is also connected to the input / output (I / O) interface 905 as needed. A removable medium 911, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed on the drive 910 as needed so that computer programs read from it can be installed into the storage section 908 as needed.
[0161] This application also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments; or it may exist independently and not assembled into the device / apparatus / system. The computer-readable storage medium carries one or more programs, which, when executed, implement the method according to the embodiments of this application.
[0162] According to embodiments of this application, the computer-readable storage medium can be a non-volatile computer-readable storage medium, such as including but not limited to: portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this application, the computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. For example, according to embodiments of this application, the computer-readable storage medium may include ROM 902 and / or RAM 903 and / or one or more memories other than ROM 902 and RAM 903 described above.
[0163] Embodiments of this application also include a computer program product comprising a computer program containing program code for performing the methods shown in the flowchart. When the computer program product is run on a computer system, the program code is used to enable the computer system to implement the drawing label layout method provided in the embodiments of this application.
[0164] When the computer program is executed by the processor 901, it performs the functions defined in the system / apparatus of this application embodiment. According to the embodiments of this application, the systems, apparatuses, modules, units, etc., described above can be implemented by computer program modules.
[0165] In one embodiment, the computer program may rely on a tangible storage medium such as an optical storage device or a magnetic storage device. In another embodiment, the computer program may also be transmitted and distributed in the form of signals over a network medium, and downloaded and installed via the communication section 909, and / or installed from a removable medium 911. The program code contained in the computer program can be transmitted using any suitable network medium, including but not limited to: wireless, wired, etc., or any suitable combination thereof.
[0166] In such an embodiment, the computer program can be downloaded and installed from a network via the communication section 909, and / or installed from the removable medium 911. When the computer program is executed by the processor 901, it performs the functions defined in the system of this application embodiment. According to the embodiments of this application, the systems, devices, apparatuses, modules, units, etc., described above can be implemented by computer program modules.
[0167] According to embodiments of this application, program code for executing the computer programs provided in the embodiments of this application can be written in any combination of one or more programming languages. Specifically, these computational programs can be implemented using high-level procedural and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages include, but are not limited to, languages such as Java, C++, Python, "C", or similar programming languages. The program code can be executed entirely on the user's computing device, partially on the user's device, partially on a remote computing device, or entirely on a remote computing device or server. In cases involving remote computing devices, the remote computing device can be connected to the user's computing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computing device (e.g., via the Internet using an Internet service provider).
[0168] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, and combinations of blocks in a block diagram or flowchart, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0169] Those skilled in the art will understand that the features described in the various embodiments of this application can be combined and / or combined in various ways, even if such combinations or combinations are not explicitly described in this application. In particular, the features described in the various embodiments of this application can be combined and / or combined in various ways without departing from the spirit and teachings of this application. All such combinations and / or combinations fall within the scope of this application.
[0170] The embodiments of this application have been described above. However, these embodiments are merely illustrative and not intended to limit the scope of this application. Although various embodiments have been described above, this does not mean that the measures in the various embodiments cannot be used advantageously in combination. Without departing from the scope of this application, those skilled in the art can make various substitutions and modifications, all of which should fall within the scope of this application.
Claims
1. An engineering drawing label layout method, characterized by, The engineering drawing label layout method comprises: obtaining an engineering drawing, wherein the engineering drawing is laid out with parts and labels used for describing the parts; performing layout identification on the engineering drawing to obtain layout state information of the engineering drawing, comprising: determining the labels from the engineering drawing based on label feature information of the labels; determining size information and position information of the labels to obtain label attribute information; determining the parts from the engineering drawing based on part feature information of the parts; determining contour information and position information of the parts to obtain part attribute information; determining parts and labels related to the leads based on anchor point information of the leads used for associating the parts and the labels to obtain part-label relationship information; determining relative position information between a plurality of the labels to obtain label relationship information; inputting the layout state information into a layout adjustment model to obtain label action information; and adjusting at least one of the labels in the engineering drawing according to the label action information to obtain an optimized engineering drawing, comprising: determining a moving distance of the label based on a shift value in position shift information of the label action information; determining a moving direction of the label based on a value sign representing a positive or negative value in the position shift information; moving the label in the engineering drawing based on the moving distance and the moving direction to obtain a position-adjusted label; determining a rotation angle of the label based on a rotation value in angle shift information of the label action information; determining a rotation direction of the label based on a value sign representing a positive or negative value in the angle shift information; and rotating the label in the engineering drawing based on the rotation angle and the rotation direction to obtain a rotated label, so that a plurality of the labels and a plurality of the parts in the optimized engineering drawing do not overlap with each other.
2. The engineering diagram tag layout method of claim 1, wherein, The layout adjustment model comprises a graph neural network, an attention network, and a policy network; the inputting the layout state information into a layout adjustment model to obtain label action information comprises: inputting the layout state information into the graph neural network to perform feature representation on the layout state information by using the graph neural network to obtain layout state features; inputting the layout state features into the attention network to perform attention feature extraction to obtain attention state features; and inputting the attention state features into the policy network to obtain the label action information.
3. The engineering graphic tag layout method of claim 1, wherein, The engineering drawing label layout method further comprises: taking the engineering drawing obtained after the label is adjusted as an initial optimized engineering drawing; performing verification on the initial optimized engineering drawing to obtain a verification result, wherein the verification comprises at least one of the following: whether there is an overlap between the parts and the labels, and whether there is an overlap between a plurality of the labels; and in a case where the verification result indicates that the initial optimized engineering drawing is optimized normally, taking the initial optimized engineering drawing as the optimized engineering drawing.
4. The engineering graphic tag layout method of claim 1, wherein, the obtaining an engineering drawing comprises: In response to the generation instruction for generating the label, the label is configured to each part in the initial engineering drawing by using drawing software, and the engineering drawing is obtained.
5. The engineering graphic tag layout method of claim 1, wherein, The engineering drawing label layout method further comprises: group association recognition is performed on the plurality of labels to obtain a recognition result; in a case where the recognition result indicates that the plurality of labels belong to the same label group, label attribute information of the label group is determined based on label attribute information of each label in the label group, so that the label attribute information of the label group is processed by using the layout adjustment model; the label action information is used to adjust at least one label in the engineering drawing to obtain an optimized engineering drawing, comprising: the label action information of the label group in the label action information is used to adjust the label group in the engineering drawing to obtain the optimized engineering drawing. 6.A method for training a model, characterized in that, The method comprises: obtaining sample layout state information of a sample engineering drawing, wherein the sample engineering drawing comprises parts and labels for describing the parts, and the sample layout state information comprises sample part attribute information for describing the layout state of the parts, sample label attribute information for describing the layout state of the labels, sample part-label relationship information for describing the association relationship between the parts and the labels, and sample label relationship information for describing the positional relationship between a plurality of labels; inputting the sample layout state information into an initial layout adjustment model to obtain sample label action information; based on the sample label action information and the sample layout state information, uniform distribution recognition is performed to determine uniform distribution reward values between a plurality of labels; based on the sample label action information and the sample layout state information, overlap recognition of the parts and the labels is performed to determine a first overlap reward value between the parts and the adjusted labels; based on the sample label action information and the sample layout state information, overlap recognition of the labels and the labels is performed to determine a second overlap reward value between a plurality of adjusted labels; based on the first overlap reward value and the second overlap reward value, a target overlap reward value is determined; based on the sample label action information, movement recognition is performed to determine a movement distance reward value; and based on the uniform distribution reward value, the target overlap reward value and the movement distance reward value, the initial layout adjustment model is adjusted in parameters to obtain a layout adjustment model.
7. The training method of claim 6, wherein, The movement recognition based on the sample label action information to determine a movement distance reward value comprises: weighting and summing offset numerical values of position offset information of a plurality of labels to obtain the movement distance reward value, wherein the sample label action information comprises position offset information of each label, and the position offset information comprises an offset numerical value and a sign value representing the positive or negative of the numerical value.
Citation Information
Patent Citations
Layout element automatic layout method and device based on mixed strategy reinforcement learning
CN117408215A
Multi-agent joint layout model training method and device, equipment and medium
CN119312760A