A method for generating sketch CAD models based on unit composition
By constructing sketch datasets and training network optimization algorithms, the problem of sketch CAD modeling software is insufficiently friendly to ordinary users, and the generation and editing of complex models is realized, which improves the robustness and user experience of the model.
Patent Information
- Application Number
- CN202510812606.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-18
- Publication Date
- 2025-08-26
- Estimated Expiration
- 2045-06-18
AI Technical Summary
The existing sketch CAD modeling software is not friendly to ordinary users, is highly professional, is difficult to generate complex models, and the generation model is not editable, has low reusability, and is difficult to connect with downstream applications.
By constructing a sketch dataset, using the CLIPascene method to generate sketches and train modeling operation classification networks and template parameter extraction networks, the CAD model is optimized using the coarse-to-fine strategy, and combined with corner detection and random search auxiliary MCMC methods for parameter optimization, realizing the transformation from sketch to CAD model.
It enables ordinary users to generate complex and editable CAD models, improves the robustness and reusability of the model, lowers the technical threshold, broadens the user base, and enhances the universality of sketch modeling.
Smart Images

Figure CN120337788B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of CAD modeling, in particular to a method for generating a sketch CAD model based on a unit assembly formula. Background Art
[0002] Sketching, as a tool for quickly expressing creativity and ideas, has become an effective way to interact and create on multimedia platforms with the rise of AR / VR technology. Spatial drawing and modeling software like Gravity Sketch and Sketchbox, as well as applications like Shapr3D that combine sketching with CAD modeling, are driving this trend. However, these software programs are typically targeted at professional designers. For ordinary users without modeling experience, they are often limited to simple doodles or rely on pre-designed models to piece together, similar to assembling Lego bricks. If an algorithm could be designed that could achieve basic modeling even with rough sketches, this would effectively lower the technical barriers to entry for professional software and allow ordinary users to participate in the modeling process. Such innovations would not only broaden the user base of modeling software but also help transform sketch modeling into a more universal creative tool.
[0003] Early research focused on completing the depth information of sketches, using dilation methods to do so, or solving optimization problems based on implicit constraints in sketches. However, these methods often require relatively clean, well-organized sketch inputs, and the resulting models are often non-editable and lack a clear model generation process. This makes such models less reusable and difficult to integrate with downstream applications such as secondary editing and manufacturing. Summary of the Invention
[0004] In order to solve the above technical problems existing in the prior art, the present invention proposes a method for generating a sketch CAD model based on a unit composition formula, and its specific technical solution is as follows:
[0005] A method for generating a sketch CAD model based on a unit composition formula, comprising:
[0006] Based on different CAD models, sketches are generated using the CLIPascene method and a sketch dataset is constructed;
[0007] The sketch dataset is used to train the modeling operation classification network and the template parameter extraction network to obtain the modeling category and corresponding parameters of the sketch;
[0008] generating an initialization CAD model according to the modeling category and corresponding parameters of the sketch;
[0009] The parameters of the initialized CAD model are optimized using a corase-to-fine strategy to obtain a reconstructed CAD model.
[0010] Furthermore, by sampling different modeling operation parameters, a CAD automatic generation algorithm is used to generate the different CAD models, and deduplication processing is performed.
[0011] Furthermore, the deduplication process is specifically based on pythonOCC to generate CAD model projection images from multiple perspectives, using a hash algorithm to deduplicate images and delete invalid wireframes.
[0012] Furthermore, in the CLIPascene method, the 11th layer output of the CLIP-ViT encoder is used as a feature to extract semantic information so that the generated sketch retains the semantic information.
[0013] Furthermore, the sketch is corner-detected, and the corner detection results are fused with the sketch initialization results calculated based on the attention weights extracted by the Clip-ViT encoder, and the points with the most sparse distribution are selected as the initialization control points.
[0014] Furthermore, a modeling operation classification network based on Inception-V3 as the skeleton network is trained to obtain the modeling category of the sketch.
[0015] Furthermore, according to the modeling category and corresponding parameters of the sketch, a CAD generation script is executed in the CAD software to generate an initialization CAD model.
[0016] Furthermore, the optimized parameters include the size, position and angle of the CAD model, and the parameter optimization adopts the random search assisted MCMC method to sample in the parameter space.
[0017] Furthermore, a random search-assisted MCMC method is used to perform sampling in the parameter space. Specifically, the generated initialized CAD model is first rendered to generate a projection image, and then the input sketch is back-projected into the CAD model space. The center point is calculated based on the projection result and used as the initial value of the CAD model position. Then, the OBB of the input sketch contour is calculated, and the OBB of the CAD model contour is calculated from the rendered projection image. Then, the overlap degree IoU of the two OBBs and the angle difference of the main axis are calculated. A random search is performed near the initial value, and MCMC is assisted in refinement to obtain the optimal solution.
[0018] Furthermore, after generating the unit body CAD model, the user can drag the generated model through the sketch to intersect it with another generated model; the system will pop up options to select "Merge", "Intersect", and "Difference". The user can select different options to perform Boolean operations of intersection and difference on the generated models to obtain a new CAD model.
[0019] Compared with the existing technology, the present invention constructs a sketch dataset that includes different drawing styles and multiple modeling operation semantics, realizes complex modeling types that cannot be reconstructed by existing methods, and achieves better robustness. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] Figure 1 This is an overall flow chart of a method for generating a sketch CAD model based on a unit assembly formula in this embodiment;
[0021] Figure 2 is a schematic diagram of a randomly generated CAD model of this embodiment;
[0022] Figure 3 This is a wireframe diagram generated based on the CAD model of this embodiment;
[0023] Figure 4 It is a hand-drawn sketch generated in this embodiment. DETAILED DESCRIPTION
[0024] In order to make the purpose, technical solution and technical effect of the present invention more clear, the present invention is further described in detail below with reference to the accompanying drawings and embodiments.
[0025] like Figure 1 As shown, a method for generating a sketch CAD model based on a unit assembly formula in this embodiment includes the following contents:
[0026] Sketch dataset construction:
[0027] Design model instantiation module, by sampling different modeling operation parameters, use CAD automatic generation algorithm to generate different CAD models, such as Figure 2 After obtaining the diverse CAD models, we generate 24 model projection images based on pythonOCC, use the hash algorithm to remove duplicate images, and delete invalid wireframes. Figure 3 As shown in Figure 1, due to the significant domain differences between regular wireframes and real human hand-drawn sketches, the sketch classification module trained on wireframes is difficult to directly transfer to hand-drawn applications. To improve the robustness of the sketch classification module, inspired by the work of CLIPascene, this embodiment generates simulated hand-drawn sketches of different types and abstractions based on CLIP, as shown in Figure 1. Figure 4 shown.
[0028] The sketch generation module was designed using the CLIPascene approach to sketch generation. CLIP encoding extracts feature outputs from the sketch and reference image, optimizing the sketch's Bezier curve control points to generate an abstract sketch that retains semantic information. When the input image is a sparse sketch, CLIPascene generates an image that is essentially identical to the original. To ensure that the generated sketch differs significantly from the original, the 11th layer output of the CLIP-ViT encoder model is used as a feature to extract semantic information. This ensures that the sketch content has lower geometric and structural fidelity with the original image while maintaining semantic consistency.
[0029] In addition, the sketch stroke initialization method has been optimized. Since the sketch generation method is based on iterative optimization of the objective function, and the objective function is non-convex, a relatively good initial solution is important for the optimization process and the final result. The original initialization method is based on the CLIP-ViT encoder to extract the features and attention weights of the input image, and calculate the attention saliency map. The result of the saliency map is multiplied with the result of edge extraction to obtain a probability map, and then the initial stroke control points are sampled based on the probability map. This method performs well on textured images, but for sparse sketches, the generation effect is poor, and the control points will be clustered together and key corner points will be missed. This initialization result will easily cause the subsequent optimization results to fall into the local optimal solution.
[0030] Therefore, in this implementation, we propose to perform corner detection on the input sketch, fuse the corner detection results with the initialization results extracted based on attention weights, and select the points with the sparsest distribution as the initial control points. This initialization method can generate a more reasonable control point layout and reach convergence faster, greatly improving the efficiency of generating sketch datasets and achieving better results.
[0031] In order to generate more complex and diverse models and train a modeling system that is robust to different sketch styles, an embodiment of the present invention constructs a sketch dataset that includes different drawing styles and multiple modeling operation semantics, such as modeling operations such as spirals, pyramids, and spheres that cannot be generated by existing methods.
[0032] Classification and parametric regression network training:
[0033] After building a sketch dataset containing various modeling categories and various hand-drawn styles, we trained a modeling operation classification network based on Inception-V3 as the skeleton network, and a template parameter extraction network, namely a parameter regression network.
[0034] CAD model generation and parameter optimization.
[0035] The overall optimization process for CAD model parameters is as follows: first, a random search is performed near the starting value, followed by MCMC optimization based on the optimal solution from the random search. After obtaining the global parameters of the CAD model, the detailed modeling parameters are optimized. While maintaining a fixed position and pose, the fine contours of the input sketch and projection are extracted. The IoU loss of the sketch and model projection contours is calculated. A random search is then performed within a certain range of the initial parameter values, supplemented by MCMC refinement, to obtain the optimal solution.
[0036] Specifically, after obtaining the modeling category and corresponding parameters based on the modeling operation classification network and the template parameter extraction network, a CAD script is executed in the CAD software, and then rendered to generate a CAD projection image Ip. Subsequently, the CAD model's pose, including position and angle, as well as specific modeling parameters, is optimized based on the input sketch Is. A corase-to-fine strategy is employed, first optimizing the specific dimensions, position, and angles of the CAD model, and then optimizing the detailed parameters. Because the CAD software's reconstruction and rendering functions are required, the entire optimization and update process is non-convex and gradient calculation is difficult. Therefore, a random search-assisted MCMC method is used to sample in the parameter space. First, an initialized CAD model is generated based on the modeling operation parameters. The input sketch is then back-projected into model space. The center point is calculated from the projection result and used as the initial value for the CAD model's position. The OBB of the input sketch's outline and the OBB of the CAD model's outline calculated from the rendered projection are then calculated. The degree of overlap (IoU) of the two OBBs and the angle difference between the principal axes are then calculated.
[0037] The present invention first classifies the modeling operations, then calls the corresponding template parameter extraction module based on the classification results, regresses the corresponding parameters, and then assists the coarse-to-fine parameter optimization algorithm to optimize the global and detail parameters of the CAD model, realizing complex modeling types that cannot be reconstructed by existing methods and achieving better robustness.
[0038] The above description is only a preferred embodiment of the present invention and does not constitute any form of limitation to the present invention. Although the implementation process of the present invention is described in detail above, it is still possible for those familiar with the art to modify the technical solutions described in the above examples or to replace some of the technical features therein with equivalents. Any modifications, equivalent replacements, etc. made within the spirit and principles of the present invention shall be included in the scope of protection of the present invention.
Claims
1. A method for generating a sketch CAD model based on a unit composition formula, characterized in that: include: Based on different unit CAD models, sketches are generated using the CLIPascene method and a sketch dataset is constructed; The sketch dataset is used to train the modeling operation classification network and the template parameter extraction network to obtain the modeling category and corresponding parameters of the sketch; generating an initialization CAD model according to the modeling category and corresponding parameters of the sketch; Using a corase-to-fine strategy to optimize the parameters of the initialized CAD model to obtain a reconstructed CAD model; The optimized parameters include the size, position and angle of the CAD model. The parameter optimization adopts the random search assisted MCMC method to sample in the parameter space. The random search-assisted MCMC method is used to sample in the parameter space. Specifically, the generated initialized CAD model is first rendered to generate a projection image, and then the input sketch is back-projected into the CAD model space. The center point is calculated based on the projection result and used as the initial value of the CAD model position. Then, the OBB of the input sketch contour is calculated, and the OBB of the CAD model contour is calculated from the rendered projection image. The overlap degree IoU of the two OBBs and the angle difference of the main axis are calculated. Random search is performed near the initial value, and MCMC is assisted for refinement to obtain the optimal solution.
2. The method for generating a sketch CAD model according to claim 1, wherein: By sampling different modeling operation parameters, a CAD automatic generation algorithm is used to generate the different unit body CAD models, and duplicate removal processing is performed.
3. The method for generating a sketch CAD model according to claim 2, wherein: The deduplication process is specifically based on pythonOCC to generate CAD model projection images from multiple perspectives, use a hash algorithm to deduplicate images, and delete invalid wireframes.
4. The method for generating a sketch CAD model according to claim 1, wherein: In the CLIPascene method, the 11th layer output of the CLIP-ViT encoder is used as a feature to extract semantic information so that the generated sketch retains the semantic information.
5. The method for generating a sketch CAD model according to claim 4, wherein: Corner detection is performed on the sketch, and the corner detection results are fused with the sketch initialization results calculated based on the attention weights extracted by the Clip-ViT encoder, and the points with the most sparse distribution are selected as the initialization control points.
6. The method for generating a sketch CAD model according to claim 1, wherein: Train the modeling operation classification network based on Inception-V3 as the skeleton network to obtain the modeling category of the sketch.
7. The method for generating a sketch CAD model according to claim 1, wherein: According to the modeling category and corresponding parameters of the sketch, a CAD generation script is executed in the CAD software to generate an initialization CAD model.
8. The method for generating a sketch CAD model according to claim 1, wherein: The reconstructed CAD model is subjected to Boolean operations of intersection and difference to obtain a new CAD model.
Citation Information
Patent Citations
Automatic generation and identification method for abstract sketch of mechanical part
CN117649456A