A method and system for generating a numerical control machining program from a 3D drawing of a sorting product
By automatically analyzing the 3D models of copper and aluminum busbars, distinguishing between simple and complex elements, connecting the central axis, and calculating bending parameters, the problem of low efficiency in manual interpretation and improper handling of complex elements in existing technologies is solved, thus realizing efficient and stable CNC machining program generation.
Patent Information
- Application Number
- CN202511907555.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-17
- Publication Date
- 2026-02-24
- Estimated Expiration
- 2045-12-17
AI Technical Summary
Existing technologies rely on manual interpretation of 3D models in the processing of busbar products such as copper and aluminum busbars. This is inefficient and inconsistent, and it is difficult to handle complex primitives and curved boundaries, resulting in inaccurate recognition of processing features. Furthermore, computers have difficulty automatically determining the type and direction of bending, leading to NC program errors and material waste.
By importing a 3D model, calling the geometry kernel library to obtain the topology, distinguishing between simple and complex primitives, eliminating non-straight edges, using depth-first backtracking search to connect the central axis, calculating bending parameters, and generating a CNC machining program.
It has achieved an automated closed loop from 3D model to CNC machining program, which has improved the success rate of analyzing complex drawings, reduced manual analysis errors, reduced equipment debugging time and material consumption, and improved production efficiency and resource utilization.
Smart Images

Figure CN121348976B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of intelligent manufacturing technology, specifically to a method and system for generating CNC machining programs from 3D drawings of products. Background Technology
[0002] Copper busbars, aluminum busbars, and other busbar-type products (square cross-section type) are widely used as high current-carrying conductors in power distribution scenarios such as automobile manufacturing, substations, and power distribution rooms. Their processing and manufacturing usually involve processes such as feeding and bending, which requires high accuracy in extracting and programming processing features (bending direction, bending angle, feeding length, etc.).
[0003] With the integration and development of CAD / CAM technology, the industry has seen the emergence of the idea of automatically generating numerical control code (NC code) based on 3D model data. This involves directly driving CNC equipment to complete the processing by parsing 3D design data, thereby improving the intelligence level and production efficiency of copper busbar processing.
[0004] However, in engineering practice, manufacturing systems still generally rely on technicians to manually interpret and convert the original 3D model: manually identify machining features, and then manually set machining steps and generate NC code in dedicated programming software.
[0005] The shortcomings of existing technology:
[0006] 1. Relying on manual interpretation is inefficient and inconsistent.
[0007] The existing process requires manual identification of processing features such as bending direction / angle / feed length from the 3D model and manual programming. The overall efficiency is significantly affected by the experience and condition of the personnel, and it is prone to deviation, making it difficult to guarantee stable and consistent parsing quality.
[0008] 2. Insufficient adaptability to "non-standard / complex drawings"
[0009] In the 3D model of a product, the same product may contain both simple and complex primitives: simple primitives are usually faces with four sides, while complex primitives may be composed of multiple planar geometric shapes with more than four sides.
[0010] Existing automatic parsing schemes often implicitly assume that "the surface is a regular quadrilateral / standard structure". When encountering complex primitives, spliced surfaces, or non-standard modeling methods, boundary extraction and feature recognition are prone to failure, resulting in the inability to reliably output executable processing data.
[0011] 3. It is difficult to determine the "unique correct centerline" from multiple centerline segments on the upper and lower surfaces.
[0012] Products with a grid pattern typically have two surfaces, top and bottom. After analysis, multiple unconnected centerline segments will be obtained. If the "correct and unique" centerline cannot be found among the multiple candidate segments, then subsequent key parameters such as length and bending position will accumulate errors.
[0013] Existing technologies generally lack robust mechanisms for global connectivity and path selection (avoiding misconnection, disconnection, and loop interference) of multiple central axis segments.
[0014] 4. Computers have difficulty automatically determining the type, direction, and angle of a bend, thus requiring manual intervention.
[0015] The bending process requires specifying the bending direction, bending angle, and bending type (such as horizontal / vertical bending). Computers cannot directly identify the bending direction, angle, and type like humans can, so traditional methods often require manual differentiation. If the bending parameters are not accurately identified, it will directly lead to NC program errors, increased trial production and debugging time, and material waste.
[0016] 5. Inadequate handling of curved edges and blending boundaries can easily introduce erroneous features.
[0017] The boundaries of a 3D model may contain non-linear edges such as arcs, spline curves, and Bézier curves. If the existing analytical scheme does not effectively process non-linear edges (remove, discretize, or calculate them together with linear edges), it can easily cause errors in boundary reconstruction, which in turn affects the extraction of the centerline and the calculation of bending parameters.
[0018] Therefore, existing technologies have shortcomings and need further improvement. Summary of the Invention
[0019] To address the problems existing in the prior art, this invention provides a method and system for generating CNC machining programs from 3D drawings of categorized products.
[0020] To achieve the above objectives, the specific solution of the present invention is as follows:
[0021] This invention provides a method for generating CNC machining programs from 3D drawings of products in a row, comprising the following steps:
[0022] S1. Import the 3D model file of the product, call the geometry kernel library to obtain the topology of the 3D model, traverse the face primitives of the 3D model and extract the edge set of each face primitive.
[0023] S2. For each face primitive, the complexity of the face primitive is distinguished based on the number of edges in the edge set: when the number of edges is greater than a preset threshold N, the face primitive is judged as a complex primitive; otherwise, it is judged as a simple primitive, where N is 4.
[0024] S3. Perform simple primitive parsing on simple primitives: Determine whether there are non-linear edges such as arcs, splines, or Bézier curves in the edge set; when there are no non-linear edges, extract the endpoints of each edge to form a vertex set, and pair the vertices according to diagonal points or opposite points to obtain the midpoint coordinates and store them; connect each midpoint according to the edge line order to obtain the central axis segment of the simple primitive.
[0025] S4. Perform complex primitive parsing on complex primitives: remove non-straight edges from the edge set and retain straight edges; break down each straight edge and extract points to form an endpoint set; calculate the distance between the endpoints of different straight edges, and select the pair with the smallest score from the candidate endpoint pairs that satisfy endpoint distance ≤ εd and direction angle ≤ εθ; repeat until a closed or nearly closed continuous edge line is formed or the iteration limit is reached; find the midpoint based on the matching of the first and last points of the continuous edge line, and connect each midpoint in the order of the edge line to obtain the central axis segment corresponding to the complex primitive;
[0026] S5. Gather the multiple centerline segments obtained in steps S3 and S4 and construct a centerline segment graph structure. Use a maximum path search based on depth-first backtracking search to traverse all candidate paths and combine path length and angle continuity penalty terms to select the candidate path with the highest score as the unique centerline. Connect the unique centerline according to the path order to obtain a complete and unique connected centerline.
[0027] S6. Identify the bent segment and calculate the bending parameters based on the connected central axis: Calculate the angle θ between the direction vectors of the straight edges before and after the bend, and determine the external tangent angle accordingly; calculate the midpoints of the two straight edges of the bent element and connect them to obtain the chord length L; calculate the bending radius R based on the relationship between the chord length and the central angle of the bend; compare and verify the bending radius R with the user-preset bending radius to determine whether the bending direction, bending angle, and bending type are horizontal or vertical bends.
[0028] S7. Generate CNC code or machining instruction sequence that matches the CNC equipment based on the length of the straight segment, the bending angle, and the bending type.
[0029] Furthermore, step S1 also includes: when traversing the model topology, dividing the entities in the model into several connected bodies according to topological connectivity; calculating the volume, surface area or bounding box size of each connected body respectively, and selecting the target connected body as the product body according to the preset geometric constraints of the product category, and eliminating the remaining connected bodies as interference items. The geometric constraints include at least: the cross-section is approximately rectangular, the thickness is within the preset thickness range, and the length direction dimension is significantly greater than the thickness direction dimension.
[0030] Furthermore, in step S3, when the simple primitive has non-linear edges, one of the following processing methods is adopted: a) reclassify the simple primitive as a complex primitive and proceed to step S4; or b) adaptively sample and discretize the non-linear edges into several line segments according to the arc length, so that the discretization error does not exceed the preset tolerance εc, and then form discrete edge lines together with the straight edges for subsequent midpoint calculation.
[0031] Furthermore, in step S4, when selecting the shortest distance endpoint pair for connection, a continuity constraint is introduced to form a candidate connection scoring function Score = w1·d + w2·(1 - cosΔθ), where d is the distance between endpoints, Δθ is the angle between the directions of the two line segments to be connected, and w1 and w2 are weights. Among the candidate connections that satisfy d≤εd and Δθ≤εθ, the one with the smallest Score is selected for connection, and when multiple solutions occur, a backtracking strategy is used to cancel the previous connection and try the next candidate connection.
[0032] Further, step S3 of obtaining the central axis segment includes: pairing adjacent or opposing vertices to form several point pairs, filtering point pairs that satisfy the tolerance range [W - εw, W + εw] of the product width W, calculating the midpoint of each filtered point pair and connecting the midpoints according to the edge topology order, thereby obtaining the central axis segment corresponding to the simple primitive.
[0033] Further, step S5, which constructs the central axis segment graph structure and searches for the unique central axis, includes: establishing an undirected graph with each central axis segment as a node and the connection relationship between two nodes with the same endpoint or the endpoint spacing not exceeding the connection tolerance εp as edges; performing a bidirectional depth-first backtracking search starting from any node and extending it from its two endpoints; calculating the total length of each candidate path under the constraint of not repeatedly visiting the same node; and selecting the path with the highest score as the unique central axis after introducing a penalty term for the continuity of the bends in the path.
[0034] Furthermore, the determination of the bending angle in step S6 includes: selecting two straight line segments adjacent to the bending segment on both sides of the bending segment, calculating the angle θ between their direction vectors, and determining the bending central angle α by θ; where α is the bending angle.
[0035] Further, the calculation of the bending radius R in step S6 includes: obtaining R=Lc / [2·sin(α / 2)] based on the arc chord length relationship Lc=2R·sin(α / 2); and comparing the bending radius R with the preset horizontal bending radius Rh and the preset vertical bending radius Rv respectively. When |R - Rh|≤εr, it is determined to be a horizontal bend, and when |R - Rv|≤εr, it is determined to be a vertical bend.
[0036] Furthermore, it also includes step S8, which involves performing adaptive reliability assessment and parameter optimization based on the centerline connection results and bending parameter analysis results, specifically including:
[0037] S801. After obtaining the unique centerline, calculate the ratio η = L_axis / L_module of the length L_axis of the unique centerline and the theoretical length L_module of the product. Based on the penalty term set for the continuity of the path bends during the connection of the centerline, sum the penalty amount of each bend to obtain the bend penalty sum ΣPenalty(Δφi). At the same time, calculate the bend radius deviation sum ΣΔR based on the deviation of each bend radius R from the preset horizontal bend radius Rh and the preset vertical bend radius Rv.
[0038] S802. Construct the analytical reliability scoring function:
[0039] C=β1·η+β2·f1(ΣPenalty(Δφi))+β3·f2(ΣΔR),
[0040] Where β1, β2, and β3 are weighting coefficients, and f1(·) and f2(·) are monotonically decreasing functions used to reduce the reliability score C when the corner penalty and ΣPenalty(Δφi) and the bending radius deviation and ΣΔR increase;
[0041] S803. Compare the reliability score C with the preset reliability threshold Cmin: When C≥Cmin, confirm that the current centerline connection result and bending parameters are valid analytical results, and execute step S7 to generate CNC code or machining instruction sequence accordingly; when C<Cmin, automatically adjust the weights w1 and w2, endpoint connection distance threshold εd, direction angle threshold εθ, and connection tolerance εp, width tolerance εw, and radius tolerance εr used in the centerline connection process within the preset value range in the candidate connection scoring function Score=w1·d+w2·(1 -cosΔθ). After obtaining the new parameter combination, re-execute the centerline connection and bending analysis steps, and repeatedly calculate the reliability score C until C≥Cmin or the preset iteration limit is reached.
[0042] S804. When C≥Cmin, the corresponding parameter combination {w1, w2, εd, εθ, εp, εw, εr} is stored in the parameter template library along with the geometric features of the current product. When parsing the 3D model files of subsequent products with similar geometric features, this parameter combination is called first to improve the success rate and stability of complex primitive parsing and central axis connection.
[0043] This invention also provides a system for generating CNC machining programs from 3D drawings of products for layout, used to implement the above method, including: a model import module, a graphic element differentiation module, a graphic element analysis module, a centerline connection module, a bending parameter calculation module, and a program generation module;
[0044] The model import module reads the 3D model of the product from the 3D design software, calls the geometry kernel library to obtain the topology of the 3D model, and outputs the topology and geometric data of the product body. The primitive differentiation module is connected to the model import module and is used to divide the model facets into simple primitives and complex primitives according to the number of edges and shape features based on the topology data. The primitive parsing module is connected to the primitive differentiation module and is used to perform centerline segment extraction and edge discretization processing on simple primitives and complex primitives respectively to obtain the corresponding centerline segment set. The centerline connection module is connected to the primitive parsing module and is used to receive the centerline segment set and obtain a complete and unique connected centerline through depth-first backtracking search. The bending parameter calculation module is connected to the centerline connection module and is used to identify each bending position based on the connected centerline and calculate the bending radius, bending angle and bending direction. The program generation module is connected to the bending parameter calculation module and the model import module respectively and is used to combine the feeding length on the centerline of the product and each bending parameter to generate a CNC machining program that conforms to the target CNC equipment program format, realizing the automatic conversion from 3D drawings to CNC machining programs.
[0045] The technical solution of this invention has the following beneficial effects:
[0046] 1. Achieve an automated closed loop from "3D model → executable programmable / NC code".
[0047] By disassembling the product model file and extracting key geometric data, the controller can reverse engineer the programming results that can be directly executed by the industrial equipment, thereby reducing the workload of manual interpretation and secondary modeling / redefinition of processing features.
[0048] 2. The resolution range has been significantly expanded, compatible with simple drawings and covering most complex / non-standard 3D drawings.
[0049] By adopting the approach of "differentiated parsing based on primitive complexity", the software overcomes the limitation of only being able to handle simple primitives while being compatible with conventional 3D model parsing, thereby improving the applicability and engineering application scope of the software.
[0050] 3. Complex graphic element processing is universal and does not require special adaptation for specific drawings.
[0051] By using the "complex graphic element edge segment connection logic" (eliminating non-straight edge lines, splitting lines to obtain points, gradually closing edge lines according to the shortest interval between endpoints and connecting the centerline based on this midpoint), even if a complex graphic element is formed by splicing together multiple simple graphic elements and has more than 4 edges, it can still be parsed using a unified mechanism, thus improving the success rate of parsing complex drawings.
[0052] 4. It can effectively identify and eliminate distracting items in drawings, improving stability and reliability.
[0053] To address the pain point of "insufficient resolution capability when complex graphic elements and drawings contain interference", this invention emphasizes the effective identification of interference items and the product itself, and the structural subdivision of complex graphic elements to reduce resolution failures caused by misidentification and misconnection from the source.
[0054] 5. By using maximum path / DFS backtracking to obtain a "unique and complete" connected centerline, the consistency of parameter calculation is improved.
[0055] The multiple central axis segments are constructed into a search tree. The maximum path method (equivalent to DFS backtracking and bidirectional search) is used to traverse all paths and take the longest path as the unique central axis. Finally, a complete and unique connected central axis is obtained, avoiding the problem of disconnection / misconnection caused by "multiple unconnected central axes on the upper and lower sides".
[0056] 6. Bending parameter calculations are quantifiable and verifiable, enhancing the accuracy of bending identification.
[0057] The external tangent angle is obtained by the included angle between the straight edges before and after bending; the chord length L is obtained by connecting the midpoints of the two straight edges of the bent element, and the bending radius is calculated by the chord length-radius relationship; finally, it is compared and verified with the user's preset bending radius to determine the bending angle and direction (and to support the distinction between horizontal and vertical bending), thereby improving the feasibility and repeatability of automatic judgment.
[0058] 7. Significantly reduces equipment setup time and material consumption, improving production efficiency and resource utilization.
[0059] By reducing manual analysis and repeated trial-and-error debugging, and increasing the success rate of analyzing complex drawings, the equipment debugging cycle can be effectively shortened, raw material waste can be reduced, and overall production efficiency and resource utilization can be improved.
[0060] 8. Significantly reduced reliance on human experience, resulting in more stable and consistent output quality.
[0061] Compared to the traditional method of "manually identifying machining features → manually programming to generate NC code", the automated parsing and feature extraction of this invention can reduce the impact of human error and experience differences on the results, and has better stability and consistency. Attached Figure Description
[0062] Figure 1 It is a 3D drawing preview of the product;
[0063] Figure 2 Here is a simplified flowchart of primitive analysis and centerline acquisition;
[0064] Figure 3 This is a schematic diagram of the central axis search tree structure;
[0065] Figure 4 This is a diagram illustrating DFS backtracking;
[0066] Figure 5 This is the overall flowchart of the present invention. Detailed Implementation
[0067] The present invention will now be described in further detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely for explaining the present invention and are not intended to limit the present invention. It should also be noted that, for ease of description, only the parts related to the present invention are shown in the accompanying drawings, and not all of them.
[0068] In this application, "graphic element" refers to a surface unit in a three-dimensional model; "set of edges" refers to the edges that constitute the boundary of the surface unit; "line splitting and point extraction" refers to extracting endpoints from the edges or obtaining points by discrete sampling at a preset step size; "centerline segment" refers to a local centerline formed by a sequence of center points of surface units; "connected centerline" refers to a centerline that runs through the product formed by connecting multiple centerline segments through graph search.
[0069] Combination Figures 1-5 As shown, the present invention provides a method for generating CNC machining programs by parsing 3D drawings of products, comprising the following steps:
[0070] S1. Import the 3D model file of the product, call the geometry kernel library to obtain the topology of the 3D model, traverse the face primitives of the 3D model and extract the edge set of each face primitive.
[0071] S2. For each face primitive, the complexity of the face primitive is distinguished based on the number of edges in the edge set: when the number of edges is greater than a preset threshold N, the face primitive is judged as a complex primitive; otherwise, it is judged as a simple primitive, where N is 4.
[0072] S3. Perform simple primitive parsing on simple primitives: Determine whether there are non-linear edges such as arcs, splines, or Bézier curves in the edge set; when there are no non-linear edges, extract the endpoints of each edge to form a vertex set, and pair the vertices according to diagonal points or opposite points to obtain the midpoint coordinates and store them; connect each midpoint according to the edge line order to obtain the central axis segment of the simple primitive.
[0073] S4. Perform complex primitive parsing on complex primitives: remove non-straight edges from the edge set and retain straight edges; break down each straight edge and extract points to form an endpoint set; calculate the distance between the endpoints of different straight edges, and select the pair with the smallest score from the candidate endpoint pairs that satisfy endpoint distance ≤ εd and direction angle ≤ εθ; repeat until a closed or nearly closed continuous edge line is formed or the iteration limit is reached; find the midpoint based on the matching of the first and last points of the continuous edge line, and connect each midpoint in the order of the edge line to obtain the central axis segment corresponding to the complex primitive;
[0074] S5. Gather the multiple centerline segments obtained in steps S3 and S4 and construct a centerline segment graph structure. Use a maximum path search based on depth-first backtracking search to traverse all candidate paths and combine path length and angle continuity penalty terms to select the candidate path with the highest score as the unique centerline. Connect the unique centerline according to the path order to obtain a complete and unique connected centerline.
[0075] S6. Identify the bent segment and calculate the bending parameters based on the connected central axis: Calculate the angle θ between the direction vectors of the straight edges before and after the bend, and determine the external tangent angle accordingly; calculate the midpoints of the two straight edges of the bent element and connect them to obtain the chord length L; calculate the bending radius R based on the relationship between the chord length and the central angle of the bend; compare and verify the bending radius R with the user-preset bending radius to determine whether the bending direction, bending angle, and bending type are horizontal or vertical bends.
[0076] S7. Generate CNC code or machining instruction sequence that matches the CNC equipment based on the length of the straight segment, the bending angle, and the bending type.
[0077] Step S1 further includes: when traversing the model topology, dividing the entities in the model into several connected bodies according to topological connectivity; calculating the volume, surface area or bounding box size of each connected body respectively, and selecting the target connected body as the product body according to the preset geometric constraints of the product category, and eliminating the remaining connected bodies as interference items. The geometric constraints include at least: the cross-section is approximately rectangular, the thickness is within the preset thickness range, and the length dimension is significantly greater than the thickness dimension.
[0078] In step S3, when the simple primitive has non-linear edges, one of the following processing methods is adopted: a) reclassify the simple primitive as a complex primitive and proceed to step S4; or b) adaptively sample and discretize the non-linear edges into several line segments according to the arc length, so that the discretization error does not exceed the preset tolerance εc, and then form discrete edge lines together with the straight edges for subsequent midpoint calculation.
[0079] In step S4, when selecting the shortest distance endpoint pair for connection, a continuity constraint is introduced and a candidate connection scoring function Score = w1·d + w2·(1 - cosΔθ) is formed, where d is the distance between endpoints, Δθ is the angle between the directions of the two line segments to be connected, and w1 and w2 are weights. Among the candidate connections that satisfy d≤εd and Δθ≤εθ, the one with the smallest Score is selected for connection, and when multiple solutions occur, a backtracking strategy is used to cancel the previous connection and try the next candidate connection.
[0080] Step S3, obtaining the central axis segment, includes: pairing adjacent or opposing vertices to form several point pairs; filtering point pairs that satisfy the tolerance range [W - εw, W + εw] of the product width W; calculating the midpoint of each filtered point pair and connecting the midpoints according to the topological order of the edge lines, thereby obtaining the central axis segment corresponding to the simple primitive.
[0081] Step S5, constructing the central axis segment graph structure and searching for the unique central axis, includes: establishing an undirected graph with each central axis segment as a node and the connection relationship between two nodes with the same endpoint or the endpoint spacing not exceeding the connection tolerance εp as edges; starting from any node, performing a bidirectional depth-first backtracking search with its two endpoints as the expansion direction; calculating the total length of each candidate path under the constraint of not repeatedly visiting the same node; and introducing a penalty term for the continuity of bends in the path before selecting the path with the highest score as the unique central axis.
[0082] The determination of the bending angle in step S6 includes: selecting two straight line segments adjacent to the bending segment on both sides of the bending segment, calculating the angle θ between their direction vectors, and determining the bending central angle α by θ; where α is the bending angle.
[0083] The calculation of the bending radius R in step S6 includes: obtaining R=Lc / [2·sin(α / 2)] based on the relationship of arc chord length Lc=2R·sin(α / 2); and comparing the bending radius R with the preset horizontal bending radius Rh and the preset vertical bending radius Rv respectively. When |R - Rh|≤εr, it is determined to be a horizontal bend, and when |R - Rv|≤εr, it is determined to be a vertical bend.
[0084] It also includes step S8, which performs adaptive reliability assessment and parameter optimization based on the centerline connection results and bending parameter analysis results, specifically including:
[0085] S801. After obtaining the unique centerline, calculate the ratio η = L_axis / L_module of the length L_axis of the unique centerline and the theoretical length L_module of the product. Based on the penalty term set for the continuity of the path bends during the connection of the centerline, sum the penalty amount of each bend to obtain the bend penalty sum ΣPenalty(Δφi). At the same time, calculate the bend radius deviation sum ΣΔR based on the deviation of each bend radius R from the preset horizontal bend radius Rh and the preset vertical bend radius Rv.
[0086] S802. Construct the analytical reliability scoring function:
[0087] C=β1·η+β2·f1(ΣPenalty(Δφi))+β3·f2(ΣΔR),
[0088] Where β1, β2, and β3 are weighting coefficients, and f1(·) and f2(·) are monotonically decreasing functions used to reduce the reliability score C when the corner penalty and ΣPenalty(Δφi) and the bending radius deviation and ΣΔR increase;
[0089] S803. Compare the reliability score C with the preset reliability threshold Cmin: When C≥Cmin, confirm that the current centerline connection result and bending parameters are valid analytical results, and execute step S7 to generate CNC code or machining instruction sequence accordingly; when C<Cmin, automatically adjust the weights w1 and w2, endpoint connection distance threshold εd, direction angle threshold εθ, and connection tolerance εp, width tolerance εw, and radius tolerance εr used in the centerline connection process within the preset value range in the candidate connection scoring function Score=w1·d+w2·(1 -cosΔθ). After obtaining the new parameter combination, re-execute the centerline connection and bending analysis steps, and repeatedly calculate the reliability score C until C≥Cmin or the preset iteration limit is reached.
[0090] S804. When C≥Cmin, the corresponding parameter combination {w1, w2, εd, εθ, εp, εw, εr} is stored in the parameter template library along with the geometric features of the current product. When parsing the 3D model files of subsequent products with similar geometric features, this parameter combination is called first to improve the success rate and stability of complex primitive parsing and central axis connection.
[0091] This invention also provides a system for generating CNC machining programs from 3D drawings of products for layout, used to implement the above method, including: a model import module, a graphic element differentiation module, a graphic element analysis module, a centerline connection module, a bending parameter calculation module, and a program generation module;
[0092] The model import module reads the 3D model of the product from the 3D design software, calls the geometry kernel library to obtain the topology of the 3D model, and outputs the topology and geometric data of the product body. The primitive differentiation module is connected to the model import module and is used to divide the model facets into simple primitives and complex primitives according to the number of edges and shape features based on the topology data. The primitive parsing module is connected to the primitive differentiation module and is used to perform centerline segment extraction and edge discretization processing on simple primitives and complex primitives respectively to obtain the corresponding centerline segment set. The centerline connection module is connected to the primitive parsing module and is used to receive the centerline segment set and obtain a complete and unique connected centerline through depth-first backtracking search. The bending parameter calculation module is connected to the centerline connection module and is used to identify each bending position based on the connected centerline and calculate the bending radius, bending angle and bending direction. The program generation module is connected to the bending parameter calculation module and the model import module respectively and is used to combine the feeding length on the centerline of the product and each bending parameter to generate a CNC machining program that conforms to the target CNC equipment program format, realizing the automatic conversion from 3D drawings to CNC machining programs.
[0093] Working principle:
[0094] This invention addresses the parsing of 3D model files for products such as copper and aluminum busbars (square cross-sections). Through a streamlined process of "element differentiation → element analysis → connecting the central axis → differentiating horizontal / vertical bends" in the 3D model, key geometric parameters that can be used to generate CNC machining programs (such as feed length, bending angle, bending direction / type, etc.) are finally extracted, realizing an automated closed loop from design model to executable machining programming.
[0095] 1) Core Concepts and Overall Process
[0096] Primitives: The "faces" in a 3D model are used as primitives; usually, a face consisting of four sides is a simple primitive, while a face with more than four sides (such as a rectangular face overlapping / splitting a sector face, which increases the number of sides) is a complex primitive.
[0097] Center line: The geometric center line used to characterize the "skeleton" of a product, which facilitates the program to identify the product shape and perform subsequent calculations of parameters such as bending and length.
[0098] Overall, this invention uses OpenCASCADE as the drawing parsing support library, and the process includes the following steps in sequence: element differentiation, element parsing, connecting the centerline, and differentiating between horizontal and vertical bends.
[0099] 2) Primitive Differentiation: Flow splitting analysis driven by the number of edge lines.
[0100] After importing the 3D model, each primitive in the model is traversed, and the number of its edges (lines) is extracted. If the number of edges is greater than 4, it is judged as a complex primitive; otherwise, it is judged as a simple primitive, and the corresponding parsing branch is entered accordingly. This splitting ensures that simple and complex primitives are processed using different mechanisms, improving the adaptability of non-standard / complex drawings from the source.
[0101] 3) Element Analysis: Obtain the central axis segment of each element.
[0102] (1) Simple primitive analysis principle
[0103] First, determine whether there are non-linear elements such as arcs, splines, or Bézier curves in the graphic element. If not, break the graphic element down to obtain four vertices. Then, perform cross-matching on the four vertices to calculate the midpoint. Select cases where the midpoints do not overlap and store the midpoint coordinates to obtain the central axis segment (formed by connecting a set of midpoints) corresponding to the simple graphic element.
[0104] (2) Principle of complex primitive analysis
[0105] First, remove non-straight lines from the graphic element, keeping only straight line segments; break down each straight line segment and take points; calculate the spacing between the endpoints of different line segments, select the shortest spacing endpoint pair to connect and repeat until all line segments are connected into a continuous edge line that fits the edge shape of the original graphic element; then continuously match the first and last points of the edge line and find the midpoint, and connect all the midpoints to obtain the central axis segment of the complex graphic element.
[0106] At the "shortest interval endpoint connection", a scoring and backtracking strategy of "distance + direction continuity" can be introduced to reduce the risk of false connection / disconnection. When there are multiple solutions or closed-loop interference, the previous connection can be canceled and the next candidate connection can be tried to improve the robustness of edge reconstruction of complex primitives.
[0107] 4) Connecting the central axis: The maximum path (DFS backtracking) yields a unique and complete connected central axis.
[0108] Since the model will result in multiple centerline segments after faceting, and products in a row typically have two faces (top and bottom), it is common for "each face to generate its own centerline segment, and none of them are connected." Therefore, it is necessary to find the "correct and unique" centerline before connecting them. To this end, this invention uses the maximum path method (which can be regarded as DFS backtracking) to solve for the maximum path: each centerline segment is regarded as a node, and nodes with the same endpoints are connected to form a path, thus forming a search tree; DFS backtracking is used to traverse the path in the search tree, and since the line segment has two endpoints, a bidirectional search is used; after the traversal is completed, the longest path is selected as the unique centerline, and the paths are connected step by step in order to obtain a complete and unique connected centerline.
[0109] Furthermore, constraints such as corner continuity penalty and endpoint spacing tolerance can be added to the "longest path" determination to avoid erroneous longest paths caused by local geometric noise and improve the stability of the unique centerline determination.
[0110] 5) Bending recognition and parameter calculation: Calculate the radius by adding the external tangent angle and chord length, and verify it against the preset radius to determine the type / direction.
[0111] After obtaining the connected centerline, the bent segments are identified and parameterized:
[0112] By calculating the angle between the straight edge before and after the bend, the external tangent angle complementary to the central angle of the bend can be obtained.
[0113] Since the radii of horizontal and vertical bends are usually fixed values, the midpoints of the two straight sides of the bend element can be found and connected to obtain the chord length L corresponding to the bend. Then, the bending radius can be calculated from the chord length-radius relationship.
[0114] After obtaining the bending radius, it is compared and verified with the user's preset bending radius to determine the bending angle and direction, and the horizontal / vertical bending type is distinguished based on the radius matching result.
[0115] The determination of the bending angle includes: selecting two straight line segments adjacent to the bending segment on both sides of the bending segment, calculating the angle θ between their direction vectors, and determining the bending central angle α by θ; where α is the bending angle.
[0116] The calculation of the bending radius R includes: obtaining R = Lc / [2·sin(α / 2)] based on the relationship of arc chord length Lc = 2R·sin(α / 2); and comparing the bending radius R with the preset horizontal bending radius Rh and the preset vertical bending radius Rv respectively. When |R - Rh|≤εr, it is determined to be a horizontal bend, and when |R - Rv|≤εr, it is determined to be a vertical bend.
[0117] 6) Output machining data / generate CNC program
[0118] Based on the "unique and complete connected centerline" and "bending parameters (angle, direction, type, radius)," the length of the straight segment (feeding length) and the process parameters of each bending segment can be further obtained. Executable CNC code or machining instruction sequences can be generated according to the equipment instruction format, enabling one-click programming and reducing manual debugging.
[0119] Example 1
[0120] This method runs on an industrial control computer equipped with 3D CAD software and 3D drawing parsing software. The parsing object is, for example,... Figure 1The image shows a three-dimensional model of a copper busbar product. The cross-section of the copper busbar is approximately rectangular, with a width of, for example, 30–120 mm and a thickness of, for example, 3–15 mm, and several horizontal and vertical bends along its length.
[0121] 1. Model import and primitive differentiation
[0122] First, import the 3D model file of the copper busbar product into the parsing software, such as STEP, IGES, or native CAD format. The parsing software calls the geometry kernel interface to perform topological traversal of the 3D model, treating each "face" in the model as a primitive.
[0123] For each graphic element, the software extracts the set of edges for that element and counts the number of edges:
[0124] When the number of edge lines is less than or equal to 4, the graphic element is classified as a simple graphic element.
[0125] When the number of edge lines is greater than 4, the graphic element is judged as a complex graphic element.
[0126] The classification results are written into the primitive attributes. During subsequent parsing, they are processed separately according to the simple primitive and complex primitive branches, so as to realize differentiated parsing of primitives with different complexities in the same 3D drawing.
[0127] 2. Simple primitive analysis and acquisition of central axis segment
[0128] For faces identified as simple primitives, the software first checks their edge type to determine whether there are non-linear edges such as arcs, splines, or Bézier curves.
[0129] If the aforementioned non-straight edge exists, in this embodiment, the primitive can be directly reclassified as a complex primitive and processed during the complex primitive parsing stage.
[0130] If there are no non-linear edges, it means that the primitive is approximately rectangular in shape with four straight edges, and can be analyzed using the following steps:
[0131] (1) Perform line splitting and point extraction operations on the four straight sides to obtain the coordinates of the four vertices of the rectangle;
[0132] (2) Pair the four vertices diagonally, for example (top left, bottom right) and (top right, bottom left), and calculate the midpoint coordinates of the two pairs of points respectively;
[0133] (3) Filter out duplicate midpoint coordinates and use the non-overlapping midpoints as the set of central axis points of the simple primitive;
[0134] (4) Connect the above midpoints according to the topological order of the edge lines of the primitive to obtain a segment of the central axis corresponding to the simple primitive.
[0135] The parsing software stores the centerline segments formed by all simple graphic elements into a centerline segment list and retains their correspondence with the original graphic elements.
[0136] 3. Complex primitive analysis and acquisition of central axis segments
[0137] For a surface identified as a complex primitive, this embodiment uses the following steps to obtain the central axis segment of the primitive:
[0138] (1) Remove non-straight edges: Traverse the edges of primitives, identify non-straight edges such as arcs, splines, and Bézier curves, remove them from the edge set, and keep straight line segments.
[0139] (2) Line segment splitting and point selection: For each line segment, points are selected according to a fixed step size or endpoint method to obtain the set of endpoint coordinates of each line segment.
[0140] (3) The edge line is formed by connecting the shortest distances between the endpoints:
[0141] Calculate the Euclidean distance between the endpoints of different line segments;
[0142] Each time, select the pair of endpoints with the shortest distance from the unconnected endpoints and connect them. Treat the two line segments as adjacent edges at this endpoint and add them to the current edge line.
[0143] Repeat the above steps until all straight line segments are connected into a closed or nearly closed edge line that geometrically matches the outline of the original complex primitive.
[0144] (4) Calculate the midpoint of the edge line to obtain the central axis segment:
[0145] Extract several discrete points along the closed edge line mentioned above, and calculate the midpoint coordinates by pairing adjacent points in sequence;
[0146] Connect all midpoints according to the point order of the edge lines to obtain a segment of the central axis corresponding to the complex primitive.
[0147] By following the steps above, complex graphic elements such as polygonal splicing and combinations of rectangles and sectors can be uniformly analyzed to obtain their corresponding central axis segments. The analysis results are also saved in the central axis segment list.
[0148] 4. Connection of central axis segments and determination of the unique central axis
[0149] The entire copper busbar product model typically includes an upper and lower surface, and the centerline segments obtained in steps 2 and 3 are all local and unconnected line segments. In this embodiment, the analysis software constructs all centerline segments into a graph structure and uses a depth-first backtracking-based maximum path search algorithm to solve for the unique centerline.
[0150] Specifically:
[0151] (1) Treat each segment of the central axis as a node, and take the two endpoints of the central axis segment as the two connecting endpoints of the node;
[0152] (2) For any two central axis segments, if their endpoint coordinates are the same within the preset tolerance range or the distance is less than the preset connection tolerance, then an undirected edge is established between the two nodes, indicating that the two central axis segments can be connected geometrically.
[0153] (3) Starting from any node in the graph, perform a depth-first backtracking search with the two endpoints of the node as the expansion direction, and traverse all feasible paths; calculate the total length of each path during the traversal.
[0154] (4) After the search is completed, the path with the longest total length is selected as the unique central axis path, and all central axis segments are connected in the order of the path segments to obtain a complete and unique connected central axis that runs through the entire copper busbar product.
[0155] This single central axis provides a unified reference "skeleton" for subsequent calculations of feeding length and bending position.
[0156] 5. Bending recognition and bending parameter calculation
[0157] After obtaining the connected central axis, this embodiment identifies and calculates the parameters of each bent segment in the copper busbar product to generate bending processing data:
[0158] (1) The analysis software identifies the area with a bend on the central axis through geometric analysis, and regards the two straight lines near the bend as the straight line before the bend and the straight line after the bend;
[0159] (2) Calculate the angle θ between the direction vectors of the two straight lines before and after the bend, and obtain the external tangent angle that is complementary to the central angle of the bend from this angle;
[0160] (3) For the specific bending primitive, select a representative straight line from the straight edge before bending and the straight edge after bending, calculate the midpoint of the two straight lines and connect them to obtain the chord length L corresponding to the bending.
[0161] (4) Calculate the bending radius R based on the geometric relationship between the chord length and the central angle;
[0162] (5) Compare the obtained bending radius R with the horizontal bending radius and vertical bending radius preset in the copper busbar product process. When the bending radius matches the preset radius of a certain type within the tolerance range, it can be determined that the bend is the corresponding type of horizontal bend or vertical bend, and the corresponding bending angle and bending direction can be determined.
[0163] By following the steps above, the bending angle, direction, and type of each bend can be automatically provided without manual interpretation.
[0164] 6. Feeding length and CNC machining data generation
[0165] Given a unique centerline and parameters of each bending segment, the analysis software calculates the length of the straight segment between adjacent bends along the centerline to obtain the feeding length for each process. At the same time, it combines parameters such as bending angle, bending radius, bending direction and feeding length, and generates corresponding CNC codes or processing instruction sequences according to the format required by the CNC bending machine or copper busbar processing equipment.
[0166] Ultimately, operators only need to import the generated machining program into the CNC equipment to complete the automatic bending process of copper busbars and other busbar products, significantly reducing manual programming and debugging time.
[0167] Example 2
[0168] Based on Example 1, this embodiment further presents an enhanced 3D drawing analysis and CNC programming system for copper-aluminum busbar products and its optimized algorithm, which enables robust analysis of complex drawings and drawings with interfering structures, and improves the accuracy of centerline connection and bend recognition.
[0169] 1. System Structure
[0170] The system in this embodiment includes:
[0171] Model import module: Used to import 3D model files of product categories and call the geometry kernel to parse the topology;
[0172] The primitive differentiation module is used to classify primitives into simple primitives and complex primitives based on the number of edges.
[0173] The primitive parsing module includes a simple primitive parsing submodule and a complex primitive parsing submodule, which are used to generate the central axis segment corresponding to each primitive respectively;
[0174] Interference identification module: used to remove non-product-body structures such as fixtures and annotation blocks from the model;
[0175] The central axis connection module is used to construct a graph structure based on the central axis segments and execute a depth-first backtracking-based maximum path search algorithm to obtain a unique and complete connected central axis.
[0176] Bending parameter calculation module: used to calculate bending angle, bending radius, bending type and bending direction;
[0177] Program generation module: Used to generate machining programs adapted to the target CNC equipment based on the centerline and bending parameters.
[0178] The above modules can be implemented by software function modules in the same industrial control computer, or they can be distributed in multiple devices and completed collaboratively through network communication.
[0179] 2. Interference Item Identification and Product Body Determination
[0180] After the model is imported, the interference identification module divides the model into several connected components based on the topological information provided by the geometric kernel. For each connected component, its volume, bounding box size, and cross-sectional shape features are calculated.
[0181] If the length dimension of a connected body is significantly larger than its cross-sectional dimension, and the cross-sectional shape satisfies the approximate rectangular characteristic, then the connected body is determined to be the body of a row-type product.
[0182] For connected solids that are small in size, irregular in shape, or only serve a labeling or clamping function, they are identified as interference items and ignored in the subsequent primitive differentiation and primitive analysis process.
[0183] Through the above processing, non-product parts such as fixtures, positioning blocks, and auxiliary marks can be automatically removed from the 3D drawings, ensuring that the calculation of the centerline and bending parameters is based solely on the product itself, thus improving the stability and accuracy of the analysis results.
[0184] 3. Scoring and backtracking optimization of endpoint connections for complex primitives
[0185] In Example 1, complex primitives are constructed using the "shortest distance connection to endpoints" method for edge lines. This example further introduces an endpoint connection scoring function and a backtracking mechanism to reduce false connections and disconnections.
[0186] Between the two endpoints that need to be connected, the system calculates the endpoint distance d and the angle Δθ between the corresponding line segment direction vectors, and constructs a scoring function:
[0187] Score = w1·d + w2·(1 - cosΔθ)
[0188] Among them, w1 and w2 are preset weight coefficients used to balance the degree of "distance priority" and "direction continuity priority".
[0189] During the parsing of complex primitives, only the candidate endpoint pairs with the smallest score are selected for connection if they satisfy d≤ε_d and Δθ≤ε_θ. If the edge lines formed in subsequent connection processes are found to be self-intersecting or significantly inconsistent with the overall shape of the primitive, a backtracking mechanism is triggered to cancel the most recent erroneous connection and try the next candidate endpoint pair with a smaller score.
[0190] Through this "scoring + backtracking" connection method, even if complex primitives contain many straight line segments or mixed modeling features, the edge lines that fit the original contour can be reconstructed relatively stably, providing a reliable foundation for subsequent centerline calculation.
[0191] 4. Comprehensive evaluation and selection of the only central axis route
[0192] In the central axis connection module, this embodiment introduces a corner continuity penalty term based on the "maximum path length" principle of embodiment 1, and calculates a comprehensive score for each candidate path.
[0193] For a path composed of several central axis segments, the system calculates the total length L_total while also tracking the change in angle between adjacent segments. It penalizes paths with excessively sharp turns or frequent reversals, for example, by constructing:
[0194] Score_path=L_total - λ·∑Penalty(Δφ_i)
[0195] Penalty(Δφ_i) increases monotonically with the degree to which the bend deviates from the smooth direction, and λ is the penalty weight. The system ultimately selects the path with the highest score as the unique central axis and connects all central axis segments in sequence according to this path.
[0196] In this way, when there is local noise, redundant line segments, or multiple alternative paths of similar length in the drawing, the system can still prioritize the selection of the centerline that is long enough, has smooth corners, and is more in line with the actual copper busbar routing, thus improving the physical rationality of the uniqueness of the centerline.
[0197] 5. Parametric determination of bending radius and bending type
[0198] In this embodiment, after identifying the bending position, the bending parameter calculation module converts the included angle θ between the straight edges before and after the bend into the external tangent angle φ and the central angle α:
[0199] The determination of the bending angle includes: selecting two straight line segments adjacent to the bending segment on both sides of the bending segment, calculating the angle θ between their direction vectors, and determining the bending central angle α by θ; where α is the bending angle.
[0200] The calculation of the bending radius R includes: obtaining R = Lc / [2·sin(α / 2)] based on the relationship of arc chord length Lc = 2R·sin(α / 2); and comparing the bending radius R with the preset horizontal bending radius Rh and the preset vertical bending radius Rv respectively. When |R - Rh|≤εr, it is determined to be a horizontal bend, and when |R - Rv|≤εr, it is determined to be a vertical bend.
[0201] Based on this, the direction of bending (e.g., upward, downward, leftward, rightward) can be determined by combining the local spatial posture of the central axis.
[0202] By using the above parameterized judgment method, the system can maintain a consistent bending classification logic under different specifications of copper busbars and different equipment process radii, avoiding complete reliance on manual experience for identification.
[0203] 6. Typical Application Process
[0204] In a typical application scenario, a user imports a 3D model of an aluminum busbar with multiple bends, and the system automatically runs in the following sequence:
[0205] 1. The aluminum busbar body is identified through the interference identification module, ignoring the fixtures and auxiliary structures;
[0206] 2. The primitive differentiation module classifies all faces into simple primitives and complex primitives based on the number of edges;
[0207] 3. The primitive parsing module generates the central axis segments of each primitive using the corresponding algorithm, among which the parsing of complex primitives adopts a scoring + backtracking endpoint connection strategy;
[0208] 4. The central axis connection module establishes an undirected graph with the central axis segment as the node, performs a maximum path search with an angle penalty, and selects the path with the highest score as the unique central axis;
[0209] 5. The bending parameter calculation module calculates the bending radius, bending angle, and bending type for each bending position based on the included angle between the straight edges before and after the bend, the chord length, and the preset radius.
[0210] 6. The program generation module automatically generates a machining program file adapted to the corresponding CNC bending machine based on the unique centerline, the length of each straight segment, and each bending parameter.
[0211] The system and algorithm described in this embodiment are also applicable to the analysis of 3D drawings and the generation of processing programs for other types of products such as iron bars. Only some thresholds and parameters need to be adjusted appropriately according to the product size range and process requirements.
[0212] Example 3
[0213] This embodiment is based on the three-dimensional drawing analysis and CNC programming method and system for product classification described in Embodiments 1 and 2. It further adds the functions of reliability assessment of analysis results and adaptive parameter optimization. By quantitatively evaluating the analysis results of the centerline connection results and bending parameters, and automatically adjusting the connection scoring parameters, threshold parameters and tolerance parameters when the reliability is insufficient, it achieves robust analysis in complex drawing scenarios. The optimized parameters are then solidified into templates for rapid analysis of similar products in the future.
[0214] I. Overall Structure and Operating Environment
[0215] Based on the system described in Example 2, the system in this example further includes: 1. A reliability assessment module: used to calculate the analytical reliability score C based on the unique centerline and bending analysis results; 2. A parameter self-optimization module: used to automatically adjust the weight parameters and various tolerance parameters in the candidate connection scoring function and trigger re-analysis when the reliability score C is lower than the preset threshold C_min; 3. A parameter template library module: used to store the parameter combinations obtained in the high reliability analysis process, as well as their corresponding geometric features of the ranked products, for subsequent analysis of similar products.
[0216] The above modules can be integrated into the same industrial control computer in the form of software, or they can be program modules on different devices working together through a bus or network.
[0217] II. Calculation of Reliability Scoring Index for Analysis Results
[0218] Based on Examples 1 and 2, after the centerline connection module completes the maximum path search and obtains a unique centerline, and the bending parameter calculation module completes the determination of bending angle, bending radius and bending type, the reliability assessment module performs the following steps:
[0219] 1. The system for calculating the length consistency index η calculates the total length L_axis of the central axis based on the geometric information of the connected central axes; simultaneously, it calculates the theoretical length L_module based on the overall geometric dimensions of the product body in the 3D model of the product (such as the theoretical length of straight segments, the arc length of bent segments, etc.); thus, the length ratio η = L_axis / L_module is obtained. If the central axis connection is correct, η should be close to 1; when there are missing segments or redundant connections, η will deviate from 1.
[0220] 2. Calculation of Angle Continuity Penalty and ΣPenalty(Δφi): For each angle position on the unique central axis, calculate the angle change Δφi between the direction vectors of adjacent line segments; construct a single-point penalty function based on the angle change, for example: Penalty(Δφi)=0, when Δφi≤φ_thr; Penalty(Δφi)=k·(Δφi - φ_thr)^2, when Δφi>φ_thr; where φ_thr is the angle smoothing threshold and k is the adjustment coefficient; sum over all angles on the entire path to obtain the angle penalty and ΣPenalty(Δφi). This sum will significantly increase when the central axis has "zigzag", "reversal", or unreasonable turns.
[0221] 3. Calculation of Bend Radius Deviation and ΣΔR For each bend position j, denote the parsed bend radius as Rj. According to the horizontally preset bend radius Rh and vertically preset bend radius Rv in the process, determine the type of this bend and calculate the deviation ΔRj between the actual radius and the corresponding preset radius: If it is judged as a horizontal bend, then ΔRj = |Rj - Rh|; if it is judged as a vertical bend, then ΔRj = |Rj - Rv|. Sum the deviations of all bend positions to obtain ΣΔR = ΣΔRj. When there are errors in bend recognition or parameter calculation, this deviation sum will increase.
[0222] 4. Calculation of Parsing Reliability Scoring Function C Combining the above three indicators, the system constructs a parsing reliability scoring function: C = β1·η + β2·f1(ΣPenalty(Δφi)) + β3·f2(ΣΔR), where β1, β2, and β3 are weight coefficients, which can be configured according to enterprise experience or preset strategies to make the influence degrees of the three types of indicators on the overall score adjustable; f1(·) and f2(·) are monotonically decreasing functions with respect to the sum of fold angle penalties and the sum of radius deviations. For example, f1(x) = 1 / (1 + γ1·x) and f2(y) = 1 / (1 + γ2·y) can be selected, where γ1 and γ2 are scaling coefficients. The system sets a reliability threshold C_min. When C ≥ C_min, the current parsing result is considered reliable; when C < C_min, the parameter adaptive optimization process is triggered.
[0223] III. Parameter Adaptive Optimization Process
[0224] When the reliability evaluation module determines that C < C_min, the parameter self-optimization module starts the process of automatic parameter adjustment and re-parsing, which specifically includes:
[0225] 1. Determination of the Set of Parameters to be Optimized In the parsing of complex graphic elements, in the candidate connection scoring function Score = w1·d + w2·(1 - cosΔθ), w1 and w2 are weights, d is the distance between endpoints, and Δθ is the included angle of the line segment direction; the connection distance threshold εd, the direction included angle threshold εθ; the connection tolerance εp and width tolerance εw used in the construction and connection of the central axis segment diagram; the radius tolerance εr in bend recognition and bend radius determination, etc. In this embodiment, the above parameter combination is denoted as P = {w1, w2, εd, εθ, εp, εw, εr}.
[0226] 2. Parameter Search Strategy: The parameter self-optimization module updates the parameter combination P within a preset search space by perturbation. For example, it takes multiple sets of values near the base value at a certain step size, or it uses a parameter-by-parameter scanning method to adjust individual parameters sequentially and observe the changing trend of C. Under each set of candidate parameters Pk, the system re-executes complex primitive analysis, central axis connection, bend recognition, and parameter calculation, that is, repeats the corresponding steps S4 to S6 in Examples 1 and 2; after completion, the reliability assessment module recalculates the score Ck.
[0227] 3. Stopping Conditions and Optimal Parameter Selection: The parameter self-optimization module sets the maximum number of iterations N_max and the reliability target threshold C_min. If a set of parameters Pk exists within the number of iterations such that Ck ≥ C_min, then a satisfactory analytical result is considered found, and the parameter combination with the largest Ck is selected as the optimal parameter combination P_opt, and parameter tuning is terminated. If, after reaching N_max, none of the Ck values reach C_min, then the combination with the largest Ck, P_sub, is selected as the suboptimal parameter combination, and a warning is given that the analytical quality may be low. When Ck ≥ C_min and P_opt is selected, the corresponding unique centerline and bending parameters will be used for subsequent machining program generation.
[0228] IV. Creation and Calling of Parameter Template Library
[0229] When a certain analysis obtains a high reliability score C_opt after adjustment by the parameter self-optimization module, the system stores the geometric characteristics of the current product category and the optimal parameter combination P_opt into the parameter template library.
[0230] 1. Construction of Geometric Feature Vectors To determine geometric feature similarity during subsequent analysis, this embodiment constructs a feature vector containing the following components: the total length range L of the product; the range or typical value of the cross-sectional width and thickness; the number of bends, and the ratio of horizontal to vertical bends; the proportion of complex primitives; and the range of bend radius values. The system encodes the above features into a vector F, which, along with the parameter combination P_opt, is stored in the template entry Template_i = (F_i, P_i).
[0231] 2. Template Matching and Rapid Parameter Tuning During Subsequent Parsing: When parsing a new 3D model of a product category, before executing S1 to S3 or S4, the system first roughly analyzes the geometric features of the model and generates a feature vector F_new; it calculates the similarity between F_new and each F_i in the parameter template library; if there is a template item Template_j with a similarity higher than a preset threshold, the corresponding parameter combination P_j is directly used as the initial parameter for the current parsing, instead of using the default parameters; if not enough similar templates are found, the default parameters are still used to start the parsing, and iterative updates are performed through the parameter adaptive optimization process of this embodiment when necessary.
[0232] In this way, when analyzing a large number of copper busbars, aluminum busbars, and iron busbars with similar specifications or process radii, the system can significantly reduce the number of parameter tuning iterations, accelerate the analysis convergence speed, and maintain stable analysis quality.
[0233] V. Typical Application Process Examples
[0234] In a certain batch production scenario, enterprises need to continuously analyze the 3D models of copper busbar products of various specifications. Some of the drawings have complex modeling habits, many fixtures and annotations. The initial analysis often results in a low reliability score C due to misconnection of the central axis or deviation of bending parameters.
[0235] When first parsing a complex copper busbar model of a certain specification, the system performs complete primitive analysis, central axis connection, and bending calculations through Examples 1 and 2. The reliability assessment module calculates that C is lower than C_min, triggering the parameter adaptive optimization process of this example. Within a limited number of iterations, the parameter self-optimization module automatically adjusts parameters such as w1, w2, εd, εθ, and εp in the Score function, ultimately obtaining a parsing result of C_opt ≥ C_min. The system writes the geometric features F and P_opt of the copper busbar of this specification into the template library. When parsing 3D models of copper busbar products with similar geometric features, the system retrieves similar templates from the template library, directly uses P_opt as the initial parameter, and obtains a reliable result of C ≥ C_min in one parsing, without needing to perform a large number of parameter tuning iterations again.
[0236] By introducing this embodiment, the present invention can not only adaptively improve the success rate and reliability of parsing complex drawings in a single parsing, but also realize the automatic accumulation and reuse of experience parameters in batch and multi-specification production scenarios through the template library mechanism, thereby forming an intelligent parsing system in which the parsing quality can be quantified and evaluated, the parameters can be self-optimized in a closed loop, and the experience can be automatically transferred. In terms of the overall technical solution, the invention's creativity and engineering application value are further enhanced.
[0237] The above description is only a preferred embodiment of the present invention and does not limit the patent scope of the present invention. All equivalent structural transformations made under the inventive concept of the present invention using the contents of the present invention specification and drawings, or direct / indirect applications in other related technical fields, are included within the protection scope of the present invention.
Claims
1. A method for generating CNC machining programs from 3D drawings of a product category, characterized in that, Includes the following steps: S1. Import the 3D model file of the product, call the geometry kernel library to obtain the topology of the 3D model, traverse the face primitives of the 3D model and extract the edge set of each face primitive. S2. For each face primitive, the complexity of the face primitive is distinguished based on the number of edges in the edge set: when the number of edges is greater than a preset threshold N, the face primitive is judged as a complex primitive; otherwise, it is judged as a simple primitive, where N is 4. S3. Perform simple primitive parsing on simple primitives: Determine whether there are non-linear edges such as arcs, splines, or Bézier curves in the edge set; when there are no non-linear edges, extract the endpoints of each edge to form a vertex set, and pair the vertices according to diagonal points or opposite points to obtain the midpoint coordinates and store them; connect each midpoint according to the edge line order to obtain the central axis segment of the simple primitive. S4. Perform complex primitive parsing on complex primitives: remove non-straight edges from the edge set and retain straight edges; decompose each straight edge to form an endpoint set; calculate the distance between the endpoints of different straight edges, and select the pair with the smallest score from the candidate endpoint pairs that satisfy endpoint distance ≤ εd and direction angle ≤ εθ; repeat until a closed or approximately closed continuous edge line is formed or the iteration limit is reached. The midpoint is obtained by matching the first and last points of the continuous edge line, and the midpoints are connected in the order of the edge line to obtain the central axis segment corresponding to the complex graphic element. S5. Gather the multiple centerline segments obtained in steps S3 and S4 and construct a centerline segment graph structure. Use a maximum path search based on depth-first backtracking search to traverse all candidate paths and combine path length and angle continuity penalty terms to select the candidate path with the highest score as the unique centerline. Connect the unique centerline according to the path order to obtain a complete and unique connected centerline. S6. Identify the bent segment and calculate the bending parameters based on the connected central axis: Calculate the angle θ between the direction vectors of the straight edges before and after the bend, and determine the external tangent angle accordingly; calculate the midpoints of the two straight edges of the bent element and connect them to obtain the chord length L; calculate the bending radius R based on the relationship between the chord length and the central angle of the bend; compare and verify the bending radius R with the user-preset bending radius to determine whether the bending direction, bending angle, and bending type are horizontal or vertical bends. S7. Generate CNC code or machining instruction sequence that matches the CNC equipment based on the length of the straight segment, the bending angle, and the bending type.
2. The method according to claim 1, characterized in that, Step S1 further includes: when traversing the model topology, dividing the entities in the model into several connected bodies according to topological connectivity; calculating the volume, surface area or bounding box size of each connected body respectively, and selecting the target connected body as the product body according to the preset geometric constraints of the product category, and eliminating the remaining connected bodies as interference items. The geometric constraints include at least: the cross-section is approximately rectangular, the thickness is within the preset thickness range, and the length dimension is significantly greater than the thickness dimension.
3. The method according to claim 1, characterized in that, In step S3, when the simple primitive has non-linear edges, one of the following processing methods is adopted: a) reclassify the simple primitive as a complex primitive and proceed to step S4; or b) adaptively sample and discretize the non-linear edges into several line segments according to the arc length, so that the discretization error does not exceed the preset tolerance εc, and then form discrete edge lines together with the straight edges for subsequent midpoint calculation.
4. The method according to claim 1, characterized in that, In step S4, when selecting the shortest distance endpoint pair for connection, a continuity constraint is introduced and a candidate connection scoring function Score = w1·d + w2·(1 - cosΔθ) is formed, where d is the distance between endpoints, Δθ is the angle between the directions of the two line segments to be connected, and w1 and w2 are weights. Among the candidate connections that satisfy d≤εd and Δθ≤εθ, the one with the smallest Score is selected for connection, and when multiple solutions occur, a backtracking strategy is used to cancel the previous connection and try the next candidate connection.
5. The method according to claim 1, characterized in that, Step S3, obtaining the central axis segment, includes: pairing adjacent or opposing vertices to form several point pairs; filtering point pairs that satisfy the tolerance range [W - εw, W + εw] of the product width W; calculating the midpoint of each filtered point pair and connecting the midpoints according to the topological order of the edge lines, thereby obtaining the central axis segment corresponding to the simple primitive.
6. The method according to claim 1, characterized in that, Step S5, constructing the central axis segment graph structure and searching for the unique central axis, includes: establishing an undirected graph with each central axis segment as a node and the connection relationship between two nodes with the same endpoint or the endpoint spacing not exceeding the connection tolerance εp as edges; starting from any node, performing a bidirectional depth-first backtracking search with its two endpoints as the expansion direction; calculating the total length of each candidate path under the constraint of not repeatedly visiting the same node; and introducing a penalty term for the continuity of bends in the path before selecting the path with the highest score as the unique central axis.
7. The method according to claim 1, characterized in that, The determination of the bending angle in step S6 includes: selecting two straight line segments adjacent to the bending segment on both sides of the bending segment, calculating the angle θ between their direction vectors, and determining the bending central angle α by θ; where α is the bending angle.
8. The method according to claim 7, characterized in that, The calculation of the bending radius R in step S6 includes: obtaining R=Lc / [2·sin(α / 2)] based on the relationship of arc chord length Lc=2R·sin(α / 2); and comparing the bending radius R with the preset horizontal bending radius Rh and the preset vertical bending radius Rv respectively. When |R - Rh|≤εr, it is determined to be a horizontal bend, and when |R - Rv|≤εr, it is determined to be a vertical bend.
9. The method according to claim 8, characterized in that, It also includes step S8, which performs adaptive reliability assessment and parameter optimization based on the centerline connection results and bending parameter analysis results, specifically including: S801. After obtaining the unique centerline, calculate the ratio η = L_axis / L_module of the length L_axis of the unique centerline and the theoretical length L_module of the product. Based on the penalty term set for the continuity of the path bends during the connection of the centerline, sum the penalty amount of each bend to obtain the bend penalty sum ΣPenalty(Δφi). At the same time, calculate the bend radius deviation sum ΣΔR based on the deviation of each bend radius R from the preset horizontal bend radius Rh and the preset vertical bend radius Rv. S802. Construct the analytical reliability scoring function: C=β1·η+β2·f1(ΣPenalty(Δφi))+β3·f2(ΣΔR), Where β1, β2, and β3 are weighting coefficients, and f1(·) and f2(·) are monotonically decreasing functions used to reduce the reliability score C when the corner penalty and ΣPenalty(Δφi) and the bending radius deviation and ΣΔR increase; S803. Compare the reliability score C with the preset reliability threshold Cmin: When C≥Cmin, confirm that the current centerline connection result and bending parameters are valid analytical results, and execute step S7 to generate CNC code or machining instruction sequence accordingly; when C<Cmin, automatically adjust the weights w1 and w2, endpoint connection distance threshold εd, direction angle threshold εθ, and connection tolerance εp, width tolerance εw, and radius tolerance εr used in the centerline connection process within the preset value range in the candidate connection scoring function Score=w1·d+w2·(1 -cosΔθ). After obtaining the new parameter combination, re-execute the centerline connection and bending analysis steps, and repeatedly calculate the reliability score C until C≥Cmin or the preset iteration limit is reached, where d is the distance between endpoints; S804. When C≥Cmin, the corresponding parameter combination {w1, w2, εd, εθ, εp, εw, εr} is stored in the parameter template library along with the geometric features of the current product. When parsing the 3D model files of subsequent products with similar geometric features, this parameter combination is called first to improve the success rate and stability of complex primitive parsing and central axis connection.
10. A system for generating CNC machining programs from 3D drawings of products, used to implement the method described in any one of claims 1-9, characterized in that, include: Model import module, element differentiation module, element parsing module, centerline connection module, bending parameter calculation module, program generation module; The model import module reads the 3D model of the product from the 3D design software, calls the geometry kernel library to obtain the topology of the 3D model, and outputs the topology and geometric data of the product body. The primitive differentiation module is connected to the model import module and is used to divide the model facets into simple primitives and complex primitives according to the number of edges and shape features based on the topology data. The primitive parsing module is connected to the primitive differentiation module and is used to perform centerline segment extraction and edge discretization processing on simple primitives and complex primitives respectively to obtain the corresponding centerline segment set. The centerline connection module is connected to the primitive parsing module and is used to receive the centerline segment set and obtain the complete and unique connected centerlines through depth-first backtracking search. The bending parameter calculation module is connected to the centerline connection module and is used to identify each bending position and calculate the bending radius, bending angle and bending direction based on the connected centerline. The program generation module is connected to the bending parameter calculation module and the model import module respectively and is used to generate a CNC machining program that conforms to the target CNC equipment program format by comprehensively considering the feeding length on the centerline of the product and each bending parameter, thereby realizing the automatic conversion from three-dimensional drawings to CNC machining programs.
Citation Information
Patent Citations
Code type identification method and device used for numerical control machine
CN101661278A
Multi-kind graphics output primitive mixed processing path optimization method
CN106125671A