A machine learning-based intelligent mapping method and system for 3D models

By using machine learning technology, the problems of inconsistent modeling benchmarks for 3D models and inconsistent view orientations in engineering drawings have been solved, enabling automatic generation of 3D models and improving design efficiency and standardization.

CN116306218BActive Publication Date: 2026-04-03JIANGSU UNIV OF SCI & TECH
View PDF 4 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-16
Publication Date
2026-04-03

AI Technical Summary

Technical Problem

In the field of mechanical design, the lack of uniformity in the modeling benchmarks of 3D models and the inconsistent orientation of engineering drawings leads to a lack of standardization in the output of engineering drawings. Designers need to manually generate drawings, resulting in low automation and low design efficiency.

Method used

By employing machine learning techniques, and through text and image similarity calculations, combined with the KNN algorithm and SolidWorks API functions, we can automatically generate 3D model drawings, including view selection, scale adjustment, position arrangement, dimension annotation, and BOM generation.

Benefits of technology

It enables automatic generation of engineering drawings, improves design efficiency, reduces manual intervention, lowers the error rate, and standardizes the 3D model and engineering drawings.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116306218B_ABST
    Figure CN116306218B_ABST
Patent Text Reader

Abstract

This invention discloses an intelligent 3D model drawing generation method and system based on machine learning. The method includes automatic view selection, intelligent drawing size selection, view scale adjustment, reasonable view position arrangement, automatic dimension annotation, and automatic BOM generation. The system includes a module for establishing a 3D model and engineering drawing information database, a module for reading component models, a module for preprocessing component model data, a module for calculating, matching, and predicting component model information, and a module for generating engineering drawings. This invention utilizes text similarity retrieval technology, image similarity retrieval technology, and the KNN algorithm, calling corresponding SolidWorks API functions to achieve automatic drawing generation of engineering drawings, ensuring the correctness of views, the standardization of dimensions, and the rationality of layout. This saves a significant amount of time compared to manual drawing generation, freeing drawing designers from tedious and repetitive tasks and shortening the product development cycle.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to 3D models, and in particular to an intelligent method and system for generating 3D models based on machine learning. Background Technology

[0002] In the manufacturing industry, 3D design software such as UG and Solidworks are widely used. However, engineering drawings remain crucial technical data for most companies in designing, manufacturing parts, and inspecting products. Currently, some mechanical design fields, such as the automotive and shipbuilding industries, still tend to rely on manual drawing, failing to effectively digitize and reuse design resources, resulting in a large amount of redundant drawings and models. Furthermore, the standardization of 3D modeling and engineering drawing production is lacking. Each designer uses their own methods, and due to differences in modeling habits and drafting skills, the standardization of 3D models and engineering drawings cannot be unified. These are pressing issues that small and medium-sized manufacturing enterprises in my country need to address.

[0003] Chinese invention patent application number 202010635999.2 discloses a method for automatically adjusting views in Solidworks 2D engineering drawings. By performing secondary development on Solidworks, calling corresponding API functions, and utilizing the calculation formulas for the drawing scale and spacing, the method achieves automatic adjustment of the view scaling ratio and view position. While the proposed method is practical, it does not consider other drawing elements. Automatic adjustment of 2D engineering drawings also needs to consider dimensions, annotations, BOM tables, etc.

[0004] Chinese invention patent application number 201210277404.6 discloses an automatic drawing generation method and system for engineering drawings. It obtains the information needed to create engineering drawings from a 3D model assembly drawing and automatically inserts various tables and figures into the engineering drawings based on the obtained information and national standards for engineering drawings, thus achieving automatic drawing generation. However, this invention involves too many manual selection steps, resulting in limited automation, and it does not consider situations where the modeling datum and view orientation of the 3D model are inconsistent. Summary of the Invention

[0005] Purpose of the Invention: The purpose of this invention is to provide an intelligent 3D model drawing generation method and system based on machine learning. This addresses the problems of inconsistent standardization in engineering drawing generation, inconsistent benchmarks in 3D model building, and inconsistent view orientations in engineering drawings caused by differences in designers' experience and drafting abilities. Machine learning is applied to engineering drawing generation, and automation is achieved through secondary development of Solidworks. This frees engineering designers from tedious engineering drawing design work, saving significant time, reducing manual intervention, lowering error rates, and allowing computers to handle a large amount of simple, repetitive work. Furthermore, it provides unified storage and management of models and drawings, improving design efficiency.

[0006] Technical solution: The present invention provides an intelligent 3D model rendering method based on machine learning, comprising the following steps:

[0007] (1) Automatic selection of view: The attributes and related drawing information of the existing models of the enterprise are organized and stored in the SQL Server database. The text similarity calculation is used to match the model name of the required engineering drawing with the database model name. The corresponding drawings in the database are retrieved and the engineering drawing view is captured. The mean Hash algorithm is used to perform similarity retrieval on the images of each view of the required engineering drawing model. The correct selection of the engineering drawing view is achieved when the model benchmark is not uniform.

[0008] (1.1) Text similarity calculation;

[0009] Create a new SQL Server database, and create a data table with column names of model name, model file size, number of views, and drawing sheet. Collect and organize the company's existing models and corresponding engineering drawings, and import their corresponding information into the data table.

[0010] Read the data from the data table and preprocess it. Remove duplicate data by using a multivariate array <model name, model file size, number of views, drawing area>. At the same time, use a stop word library to remove stop words from the data to obtain a more complete dataset. Then, build a keyword library, extract the names of the models that need to be used to generate engineering drawings, and perform word segmentation together with the model names in the dataset.

[0011] The model names in the dataset are one-hot encoded according to the keyword list obtained after word segmentation. That is, N state register bits are used to encode N states, and only one bit is valid, thus establishing the encoded dataset. Then, the keywords obtained after word segmentation of the model names that need to generate engineering drawings are one-hot encoded according to the keyword list of the encoded dataset, and the data is binarized.

[0012] After extending the discrete feature values ​​to Euclidean space, the cosine similarity algorithm is used to calculate the similarity between the model name in the dataset and the model name from which the engineering drawings need to be generated. The model name that is closest to the model name in the dataset is obtained. In subsequent steps, the model corresponding to the model name is called the similar model. The calculation formula is as follows:

[0013]

[0014] Where, n-dimensional vector For mapping the values ​​of the encoded dataset, an n-dimensional vector This is a mapping of the values ​​that need to be output as the names of the engineering drawing models after encoding; the larger the cosine value and the closer the result is to 1, the smaller the angle between the two vectors and the higher the text similarity; conversely, the closer the result is to 0, the lower the text similarity.

[0015] (1.2) Image similarity calculation.

[0016] Open the model for which you want to generate engineering drawings, call the UpdateStandardViews(ViewName) function to adjust the model's view orientation, and then use the SaveAs3(NewName,SaveAsVersion,Options) function to save the images of the model's six basic view orientations as PNG format. In the following steps, this image will be referred to as the detection image.

[0017] Collect and organize the engineering drawing views of all models, and save them in PNG image format in the document with the corresponding model name. Create a database of these documents for retrieval and retrieval. Obtain the model name of the similar model matched in step (1.1), extract the view image of the corresponding file name, and refer to this image as the template image in subsequent steps.

[0018] The `image.resize()` function is called to resize the template image and the detection image, discarding differences caused by image size or aspect ratio. The `image.convert()` function is called to convert the modes of the template image and the detection image, converting them to grayscale. OpenCV functions are used to calculate the average grayscale value of each pixel in the two images. Then, the difference between the grayscale value of each pixel and the average grayscale value is calculated; a result greater than 0 is recorded as 1, and a result less than or equal to 0 is recorded as 0, thus generating a binary array. The calculated 64-bit binary array is converted into a vector, and the similarity between the two images is compared using the Hamming distance formula as follows:

[0019]

[0020] Where a represents the vector corresponding to the template image and b represents the vector corresponding to the detection image. The smaller the calculated value, the closer the Hamming distance is and the more similar the two images are.

[0021] The template image is compared with the corresponding N detection images in turn, and the closest view image is calculated from the detection images to achieve intelligent selection of the engineering drawing view.

[0022] (2) Intelligent selection of map sheet: The data in the SQL Server database is preprocessed, the appropriate feature values ​​are extracted from the 3D model of the required engineering drawing, the KNN algorithm is used for training and prediction to obtain the most suitable map sheet, and the SolidWorks API function is called to complete the corresponding operation.

[0023] (2.1) Call the SQL Server database to preprocess the dataset information; after removing stop words and deduplicating data in step (1.1), call the fit_transform() function to standardize the binary array <file size, number of views> in the dataset, remove the unit restrictions of each attribute data, and make each data attribute belong to the same order of magnitude, which is convenient for comparison and weighting.

[0024] (2.2) Extract the information of the model for which engineering drawings are to be generated, including model name, model file size, and number of views; call the FileLen(pathname) function to obtain the size of the model file for which engineering drawings are to be generated, and obtain the number of engineering drawing views of the model for which engineering drawings are to be generated based on the calculation results of step (1.2). Standardize this set of data in the form of a binary array of <model file size, number of views> with the binary array of the dataset in step (2.1) to obtain a set of values ​​in a specific range.

[0025] (2.3) Assume that there are m training samples in the dataset in the database, represented as {G1, G2, ..., G...} m Based on the map size, the sample categories are divided into 5 categories, represented as {A0, A1, A2, A3, A4}; D i Feature vector representing the training samples: D i ={X i1 ,X i2 ,…,X in}, where 1≤i≤m, the feature vector of the sample D to be tested is: D={X1,X2,…,X n The similarity between the test sample and the training sample is calculated using cosine similarity, as shown in the following formula:

[0026]

[0027] The K training samples D with the highest similarity to the test sample are calculated using the cosine formula.i We calculate the weights for these K samples and determine the final classification of the samples based on their weights, using the following formula:

[0028]

[0029] Where y = (D i A j () represents the category attribute of the sample, and the formula is as follows:

[0030]

[0031] Based on the calculation results, the sample D to be tested is assigned to category A, which has a higher weight. j middle.

[0032] (3) Adjusting the view scale: The scale of the main view is determined by controlling the ratio of the view envelope to the drawing boundary. All basic views are traversed to make the view scale consistent with the main view. The scale of local views is specially set. The corresponding program is written by calling the SolidWorks API interface to complete the setting of the engineering drawing scale.

[0033] (3.1) Obtain the drawing boundary, the default view scale, and the view envelope.

[0034] After creating the engineering drawing view by calling the CreateDrawViewFromModelView3(ModelName,ViewName,LocX,LocY,LocZ) function, the view scale is the default scale. You need to use the GetProperties2() function to get the current drawing properties, where Papersize is the drawing size, TemplateIn is the drawing template, Scale1 is the numerator of the drawing scaling ratio, Scale2 is the denominator of the drawing scaling ratio, Width is the drawing width, and Height is the drawing height.

[0035] Call the GetOutline() function to get the bounding box coordinates of the view. The return value is a double array containing four values: Xmin, Ymin, Xmax, and Ymax.

[0036] (3.2) Determine the scale of the engineering drawing by using the scale of the main view.

[0037] Call the `swView.Position()` function to get the center coordinates of the main view. Reassign these coordinates to position the main view at the center of the upper left quarter of the drawing. Adjust the scale of the main view to ensure that the ratio of the shorter side of the main view's bounding box to the corresponding drawing boundary is 2:3, as shown in the following formula:

[0038]

[0039] Among them, B cur W1 represents the default scale of the current drawing, which can be obtained from the values ​​of Scale1 and Scale2; W2 represents the length of the shorter boundary corresponding to the drawing, which is calculated from the drawing width and drawing height; W3 represents the length of the shorter side of the main view envelope, which is obtained by subtracting the envelope coordinates Xmin, Ymin, Xmax, and Ymax.

[0040] After calculating the appropriate view scale, the GetFirstView() and GetNextView() functions are used to traverse each basic view, and the swView.ScaleDecimal() function is used to reassign the scale of each view to make the scale of the engineering drawing view consistent with the main view; the scale of the local view can be specially adjusted using the swView.ScaleRatio() function.

[0041] (4) Reasonable arrangement of view positions: Determine the position of the main view, and based on the total number of views and the drawing boundary, arrange the remaining views at equal intervals with the main view as the reference to achieve a reasonable arrangement of view positions.

[0042] (4.1) Using text similarity retrieval technology, count the view names calculated in step (1); based on the statistical results, place the views in the order of right view, front view, left view, and rear view in the project according to the principle of equal width and height. Figure 1 The upper half of the 2 / 2 area serves as the horizontal view, with the lower view correspondingly placed below the front view; if a top view exists, the horizontal view needs to be positioned within the project area. Figure 1 In the lower half of the 2 / 2 area, the top view should be placed above the front view; if both top and bottom views exist, the horizontal view should be placed above the project view. Figure 2 The middle area of ​​ / 3, with the top and bottom views placed above and below the front view respectively.

[0043] (4.2) Based on the drawing sheet calculated in step (2), use the GetProperties2() function to obtain the drawing boundary value, count the number of horizontal views other than the top and bottom views, call the GetOutline() function to obtain the size of the bounding box of the horizontal view, and place the horizontal views at equal intervals according to the drawing boundary and the bounding box of each view. The spacing calculation formula is as follows:

[0044]

[0045] Among them, W z The horizontal length of the engineering drawing is obtained by subtracting the boundary values ​​of the drawing; W iRepresents the length of the bounding box of the i-th view, obtained by subtracting the coordinate X max from X min ; m1 represents the number of views in the horizontal direction.

[0046] For the calculation of the view spacing in the vertical direction, it is necessary to determine the number of views in the vertical direction, including the top view, bottom view, and front view; after the completion of the statistics using the text similarity retrieval technology, the GetOutline() function is also used to obtain the size of the bounding box of the views in the vertical direction to calculate the spacing. The formula is as follows:

[0047]

[0048] where, W H represents the length of the engineering drawing in the vertical direction, obtained by taking the difference of the drawing boundary values; W i represents the length of the bounding box of the i-th view, obtained by subtracting the coordinate Y max from Y min ; m2 represents the number of views in the vertical direction.

[0049] (4.3) According to the calculation results of each spacing, use the swView.Position() function to reassign the coordinates of the center points of each view, and complete the reasonable arrangement of the view positions.

[0050] (5) Automatic dimension annotation: Adjust and modify the dimension annotations in the 3D model, insert the required notes, automatically project the 3D model dimensions onto the 2D engineering drawing, and automatically arrange the dimensions according to the layout.

[0051] (5.1) Manually annotate and adjust the required note information in the 3D model to ensure the standardization and standardness of the note information.

[0052] (5.2) In the engineering drawing module, call the InsertModelAnnotations3() function to map the dimensions in the 3D model to the corresponding 2D engineering drawing views.

[0053] (5.3) Use the SelectAllinDocument(swModel, swModelDocExt, swSelMgr) function to select all the dimensioned dimensions in the engineering drawing views, and call the AlignDimensions() function to automatically arrange all the dimensions to ensure the neatness and beauty of the dimension annotations and notes.

[0054] (6) Automatic generation of BOM table: Determine the corresponding positioning points of the BOM table according to the size of the drawing sheet, and call the corresponding API function to complete the automatic generation of the BOM table.

[0055] (6.1) Obtain the drawing sheet calculated in step (2), call the GetProperties2() function to obtain the drawing information, including the coordinates of the drawing boundary frame, so as to set the relative coordinate position of the BOM table.

[0056] (6.2) Call the ActivateView(ViewName) function to activate the view of the BOM table to be output, and then use the InsertBomTable4() function to set the X and Y coordinate positions of the BOM table and the BOM table template to complete the automatic insertion of the BOM table.

[0057] A machine learning-based intelligent 3D model mapping system, which employs the aforementioned machine learning-based intelligent 3D model mapping method, includes the following modules:

[0058] Establish a 3D model and engineering drawing information database module: This module is used to statistically analyze and manage the large number of existing 3D models and related engineering drawing information of the enterprise, and to facilitate the matching and retrieval of component model information.

[0059] Read Component Model Module: Used to obtain the relevant attributes of the 3D model required for generating engineering drawings;

[0060] Parts model data preprocessing module: This module is used to deduplicate, remove stop words, and segment the data obtained from the parts model module. It also performs one-hot encoding on keywords to optimize and improve the data, thereby increasing the accuracy of matching with data in the database.

[0061] The component model information calculation, matching, and prediction module is used to calculate and match the optimized data information from the component model data preprocessing module with the database information to obtain relevant information about similar models.

[0062] Engineering drawing output module: This module is used to automatically output engineering drawings by utilizing information related to matched similar models, similarity retrieval technology, KNN algorithm, and SolidWorks API functions.

[0063] A computer storage medium storing a computer program, which, when executed by a processor, implements the aforementioned intelligent mapping method for 3D models based on machine learning.

[0064] A computer device includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the above-described intelligent 3D model rendering method based on machine learning.

[0065] Beneficial effects: Compared with the prior art, the present invention has the following advantages: Under the premise of inconsistent 3D model benchmarks and inconsistent engineering drawing view directions, the present invention utilizes text similarity retrieval technology, image similarity retrieval technology, and KNN algorithm, and calls the corresponding SolidWorks API functions to realize the automatic generation of engineering drawings, while ensuring the correctness of views, the standardization of dimensions, and the rationality of layout. This saves a lot of manual labor, liberates drawing designers from tedious and repetitive simple work, shortens the product development cycle, and improves the work efficiency of employees. Attached Figure Description

[0066] Figure 1 This is a schematic diagram of the system described in this invention;

[0067] Figure 2 This is a flowchart of the steps of the method described in this invention;

[0068] Figure 3 This is a schematic diagram of the SQL Server database interface;

[0069] Figure 4 A schematic diagram of the interface for generating engineering drawings. Detailed Implementation

[0070] The technical solution of the present invention will be further described below with reference to the accompanying drawings.

[0071] This embodiment discloses a technology for intelligently generating engineering drawings from 3D models using Solidworks 3D modeling software as a platform and through secondary development using VB.net and Python programming languages. The method described in this invention is not limited to the aforementioned languages ​​and platforms.

[0072] like Figure 1 As shown, a machine learning-based intelligent 3D model rendering system includes the following modules:

[0073] Establish a 3D model and engineering drawing information database module: This module is used to statistically analyze and manage the large number of existing 3D models and related engineering drawing information of the enterprise, and to facilitate the matching and retrieval of component model information.

[0074] Read Component Model Module: Used to obtain the relevant attributes of the 3D model required for generating engineering drawings;

[0075] Parts model data preprocessing module: This module is used to deduplicate, remove stop words, and segment the data obtained from the parts model module. It also performs one-hot encoding on keywords to optimize and improve the data, thereby increasing the accuracy of matching with data in the database.

[0076] The component model information calculation, matching, and prediction module is used to calculate and match the optimized data information from the component model data preprocessing module with the database information to obtain relevant information about similar models.

[0077] Engineering drawing output module: This module is used to automatically output engineering drawings by utilizing information related to matched similar models, similarity retrieval technology, KNN algorithm, and SolidWorks API functions.

[0078] like Figure 2 As shown, a machine learning-based intelligent 3D model rendering method includes the following steps:

[0079] (1) Automatic selection of view: The attributes and related drawing information of the existing models of the enterprise are organized and stored in the SQL Server database. The text similarity calculation is used to match the model name of the required engineering drawing with the database model name. The corresponding drawings in the database are retrieved and the engineering drawing view is captured. The mean Hash algorithm is used to perform similarity retrieval on the images of each view of the required engineering drawing model. The correct selection of the engineering drawing view is achieved when the model benchmark is not uniform.

[0080] (1.1) Text similarity calculation;

[0081] Create a new SQL Server database, and create a data table with column names for model name, model file size, number of views, and drawing sheet. Collect and organize the company's existing models and corresponding engineering drawings, and import their corresponding information into the data table, such as... Figure 3 As shown.

[0082] Read the data from the data table and preprocess it. Remove duplicate data by using a multivariate array <model name, model file size, number of views, drawing area>. At the same time, use a stop word library to remove stop words from the data to obtain a more complete dataset. Then, build a keyword library, extract the names of the models that need to be used to generate engineering drawings, and perform word segmentation together with the model names in the dataset.

[0083] The model names in the dataset are one-hot encoded according to the keyword list obtained after word segmentation. That is, N state register bits are used to encode N states, and only one bit is valid, thus establishing the encoded dataset. Then, the keywords obtained after word segmentation of the model names that need to generate engineering drawings are one-hot encoded according to the keyword list of the encoded dataset, and the data is binarized.

[0084] After extending the discrete feature values ​​to Euclidean space, the cosine similarity algorithm is used to calculate the similarity between the model name in the dataset and the model name from which the engineering drawings need to be generated. The model name that is closest to the model name in the dataset is obtained. In subsequent steps, the model corresponding to the model name is called the similar model. The calculation formula is as follows:

[0085]

[0086] Where, n-dimensional vector For mapping the values ​​of the encoded dataset, an n-dimensional vector This is a mapping of the values ​​that need to be output as the names of the engineering drawing models after encoding; the larger the cosine value and the closer the result is to 1, the smaller the angle between the two vectors and the higher the text similarity; conversely, the closer the result is to 0, the lower the text similarity.

[0087] (1.2) Image similarity calculation.

[0088] Open the model for which you want to generate engineering drawings, call the UpdateStandardViews(ViewName) function to adjust the model's view orientation, and then use the SaveAs3(NewName,SaveAsVersion,Options) function to save the images of the model's six basic view orientations as PNG format. In the following steps, this image will be referred to as the detection image.

[0089] Collect and organize the engineering drawing views of all models, and save them in PNG image format in the document with the corresponding model name. Create a database of these documents for retrieval and retrieval. Obtain the model name of the similar model matched in step (1.1), extract the view image of the corresponding file name, and refer to this image as the template image in subsequent steps.

[0090] The `image.resize()` function is called to resize the template and detection images to 8x8 pixels, removing details and preserving only the structure and tonal relationships, discarding differences caused by image size or proportion. The `image.convert()` function is then called to convert the template and detection images to grayscale, transforming them into 64 levels of grayscale. OpenCV functions are used to calculate the average grayscale value of each pixel in both images. The difference between the average grayscale value and the average grayscale value is calculated; a result greater than 0 is recorded as 1, and a result less than or equal to 0 is recorded as 0, generating a binary array. This 64-bit binary array is then converted into a vector, and the similarity between the two images is compared using Hamming distance, as shown in the following formula:

[0091]

[0092] Where a represents the vector corresponding to the template image and b represents the vector corresponding to the detection image. The smaller the calculated value, the closer the Hamming distance is and the more similar the two images are.

[0093] The template image is compared with six detection images in turn, and the closest view images are calculated from the detection images to achieve intelligent selection of the engineering drawing view.

[0094] (2) Intelligent selection of map sheet: The data in the SQL Server database is preprocessed, the appropriate feature values ​​are extracted from the 3D model of the required engineering drawing, the KNN algorithm is used for training and prediction to obtain the most suitable map sheet, and the SolidWorks API function is called to complete the corresponding operation.

[0095] (2.1) Call the SQL Server database to preprocess the dataset information; after removing stop words and deduplicating data in step (1.1), call the fit_transform() function to standardize the binary array <file size, number of views> in the dataset, remove the unit restrictions of each attribute data, and make each data attribute belong to the same order of magnitude, which is convenient for comparison and weighting.

[0096] (2.2) Extract the information of the model for which engineering drawings are to be generated, including model name, model file size, and number of views; call the FileLen(pathname) function to obtain the size of the model file for which engineering drawings are to be generated, and obtain the number of engineering drawing views of the model for which engineering drawings are to be generated based on the calculation results of step (1.2). Standardize this set of data in the form of a binary array of <model file size, number of views> with the binary array of the dataset in step (2.1) to obtain a set of values ​​in a specific range.

[0097] (2.3) Assume that there are m training samples in the dataset in the database, represented as {G1, G2, ..., G...} m Based on the map size, the sample categories are divided into 5 categories, represented as {A0, A1, A2, A3, A4}; D i Feature vector representing the training samples: D i ={X i1 ,X i2 ,…,X in}, where 1≤i≤m, the feature vector of the sample D to be tested is: D={X1,X2,…,X n The similarity between the test sample and the training sample is calculated using cosine similarity, as shown in the following formula:

[0098]

[0099] The K training samples D with the highest similarity to the test sample are calculated using the cosine formula.i We calculate the weights for these K samples and determine the final classification of the samples based on their weights, using the following formula:

[0100]

[0101] Where y = (D i A j () represents the category attribute of the sample, and the formula is as follows:

[0102]

[0103] Based on the calculation results, the sample D to be tested is assigned to category A, which has a higher weight. j middle.

[0104] (3) Adjusting the view scale: The scale of the main view is determined by controlling the ratio of the view envelope to the drawing boundary. All basic views are traversed to make the view scale consistent with the main view. The scale of local views is specially set. The corresponding program is written by calling the SolidWorks API interface to complete the setting of the engineering drawing scale.

[0105] (3.1) Obtain the drawing boundary, the default view scale, and the view envelope.

[0106] After creating the engineering drawing view by calling the CreateDrawViewFromModelView3(ModelName,ViewName,LocX,LocY,LocZ) function, the view scale is the default scale. You need to use the GetProperties2() function to get the current drawing properties, where Papersize is the drawing size, TemplateIn is the drawing template, Scale1 is the numerator of the drawing scaling ratio, Scale2 is the denominator of the drawing scaling ratio, Width is the drawing width, and Height is the drawing height.

[0107] Call the GetOutline() function to get the bounding box coordinates of the view. The return value is a double array containing four values: Xmin, Ymin, Xmax, and Ymax.

[0108] (3.2) Determine the scale of the engineering drawing by using the scale of the main view.

[0109] Call the `swView.Position()` function to get the center coordinates of the main view. Reassign these coordinates to position the main view at the center of the upper left quarter of the drawing. Adjust the scale of the main view to ensure that the ratio of the shorter side of the main view's bounding box to the corresponding drawing boundary is 2:3, as shown in the following formula:

[0110]

[0111] Among them, B cur W1 represents the default scale of the current drawing, which can be obtained from the values ​​of Scale1 and Scale2; W2 represents the length of the shorter boundary corresponding to the drawing, which is calculated from the drawing width and drawing height; W3 represents the length of the shorter side of the main view envelope, which is obtained by subtracting the envelope coordinates Xmin, Ymin, Xmax, and Ymax.

[0112] After calculating the appropriate view scale, the GetFirstView() and GetNextView() functions are used to traverse each basic view, and the swView.ScaleDecimal() function is used to reassign the scale of each view to make the scale of the engineering drawing view consistent with the main view; the scale of the local view can be specially adjusted using the swView.ScaleRatio() function.

[0113] (4) Reasonable arrangement of view positions: Determine the position of the main view, and based on the total number of views and the drawing boundary, arrange the remaining views at equal intervals with the main view as the reference to achieve a reasonable arrangement of view positions.

[0114] (4.1) Using text similarity retrieval technology, count the view names calculated in step (1); based on the statistical results, place the views in the order of right view, front view, left view, and rear view in the project according to the principle of equal width and height. Figure 1 The upper half of the 2 / 2 area serves as the horizontal view, with the lower view correspondingly placed below the front view; if a top view exists, the horizontal view needs to be positioned within the project area. Figure 1 In the lower half of the 2 / 2 area, the top view should be placed above the front view; if both top and bottom views exist, the horizontal view should be placed above the project view. Figure 2 The middle area of ​​ / 3, with the top and bottom views placed above and below the front view respectively.

[0115] (4.2) Based on the drawing sheet calculated in step (2), use the GetProperties2() function to obtain the drawing boundary value, count the number of horizontal views other than the top and bottom views, call the GetOutline() function to obtain the size of the bounding box of the horizontal view, and place the horizontal views at equal intervals according to the drawing boundary and the bounding box of each view. The spacing calculation formula is as follows:

[0116]

[0117] Among them, W z The horizontal length of the engineering drawing is obtained by subtracting the boundary values ​​of the drawing; W iThe length of the envelope of the i-th view is represented by the coordinate X. max With X min Subtracting the two, we get m1, which represents the number of views in the horizontal direction.

[0118] Calculating the vertical view spacing requires determining the number of vertical views, including the top, bottom, and front views. After statistical analysis using text similarity retrieval technology, the GetOutline() function is used to obtain the size of the envelope of the vertical views and calculate the spacing, as shown in the following formula:

[0119]

[0120] Among them, W H The vertical length of the drawing is obtained by subtracting the boundary values ​​of the drawing; W i The length of the envelope of the i-th view is represented by the coordinate Y. max With Y min Subtracting the two, we get m2, which represents the number of views in the vertical direction.

[0121] (4.3) Based on the calculation results of each spacing, the coordinates of the center point of each view are reassigned using the swView.Position() function to complete the reasonable arrangement of the view positions, such as... Figure 4 As shown.

[0122] (5) Automatic dimensioning: Adjust and modify dimensioning in the 3D model, insert the required annotations, automatically project the 3D model dimensions onto the 2D engineering drawing, and automatically arrange the dimensions according to the layout.

[0123] (5.1) Manually annotate and adjust the required annotation information in the 3D model to ensure the standardization and normalization of the annotation information.

[0124] (5.2) In the drawing module, call the InsertModelAnnotations3() function to map the dimensions in the 3D model to the corresponding 2D drawing view.

[0125] (5.3) Use the SelectAllinDocument(swModel, swModelDocExt, swSelMgr) function to select all labeled dimensions in the drawing view, and call the AlignDimensions() function to automatically arrange all dimensions, ensuring that the labeled dimensions and annotations are neat and aesthetically pleasing. Figure 4 As shown.

[0126] (6) Automatically generate BOM: Determine the corresponding positioning points of the BOM based on the size of the map sheet, and call the corresponding API function to complete the automatic generation of the BOM.

[0127] (6.1) Obtain the drawing sheet calculated in step (2), call the GetProperties2() function to obtain the drawing information, including the coordinates of the drawing boundary frame, so as to set the relative coordinate position of the BOM table.

[0128] (6.2) Call the ActivateView(ViewName) function to activate the view from which the BOM table is to be displayed. Then, use the InsertBomTable4() function to set the X and Y coordinates of the BOM table and the BOM table template to complete the automatic insertion of the BOM table. Figure 4 As shown.

Claims

1. A machine learning-based intelligent mapping method for 3D models, characterized in that, Includes the following steps: (1) Automatic view selection: The attributes and related drawing information of the existing enterprise model are organized and stored in the SQL Server database. The text similarity calculation is used to match the model name of the required engineering drawing with the database model name. The corresponding drawings in the database are retrieved and the engineering drawing views are extracted. The mean Hash algorithm is used to perform similarity retrieval on the images of each view of the required engineering drawing model, so as to achieve the correct selection of the engineering drawing view when the model benchmark is not uniform; specifically: (1.1) Text similarity calculation; Create a new SQL Server database, and create a data table with column names of model name, model file size, number of views, and drawing sheet. Collect and organize the company's existing models and corresponding engineering drawings, and import their corresponding information into the data table. Read the data from the data table and preprocess it. Remove duplicate data by using a multivariate array <model name, model file size, number of views, drawing sheet>. At the same time, use a stop word library to remove stop words from the data to obtain a more complete dataset. Then, build a keyword library, extract the names of the models that need to be used to generate engineering drawings, and perform word segmentation together with the model names in the dataset. The model names in the dataset are one-hot encoded according to the keyword list obtained after word segmentation. That is, N state register bits are used to encode N states, and only one bit is valid, thus establishing the encoded dataset. Then, the keywords obtained after word segmentation of the model names that need to generate engineering drawings are one-hot encoded according to the keyword list of the encoded dataset, and the data is binarized. After extending the discrete feature values ​​to Euclidean space, the cosine similarity algorithm is used to calculate the similarity between the model name in the dataset and the model name from which the engineering drawings need to be generated. The model name that is closest to the model name in the dataset is obtained. In subsequent steps, the model corresponding to the model name is called the similar model. The calculation formula is as follows: Where, n-dimensional vector For mapping the values ​​of the encoded dataset, an n-dimensional vector This is a mapping of the values ​​that need to be output as the names of the engineering drawing models after encoding; the larger the cosine value and the closer the result is to 1, the smaller the angle between the two vectors and the higher the text similarity; conversely, the closer the result is to 0, the lower the text similarity. (1.2) Image similarity calculation; Open the model for which you want to generate engineering drawings, call the UpdateStandardViews(ViewName) function to adjust the model's view orientation, and then use the SaveAs3(NewName,SaveAsVersion,Options) function to save the images of the model's six basic view orientations as PNG format. In the following steps, this image will be referred to as the detection image. Collect and organize the engineering drawing views of all models, and save them in PNG image format in the document with the corresponding model name. Create a database of these documents for retrieval and retrieval. Obtain the model name of the similar model matched in step (1.1), extract the view image of the corresponding file name, and refer to this image as the template image in subsequent steps. The `image.resize()` function is called to resize the template image and the detection image, discarding differences caused by image size or aspect ratio. The `image.convert()` function is called to convert the modes of the template image and the detection image, converting them to grayscale. OpenCV functions are used to calculate the average grayscale value of each pixel in the two images. Then, the difference between the grayscale value of each pixel and the average grayscale value is calculated; a result greater than 0 is recorded as 1, and a result less than or equal to 0 is recorded as 0, thus generating a binary array. The calculated 64-bit binary array is converted into a vector, and the similarity between the two images is compared using the Hamming distance formula as follows: Where a represents the vector corresponding to the template image and b represents the vector corresponding to the detection image. The smaller the calculated value, the closer the Hamming distance is and the more similar the two images are. The template image is compared with the corresponding N detection images in turn, and the closest view image is calculated from the detection images to achieve intelligent selection of the view of the engineering drawing; (2) Intelligent selection of map sheet: The data in the SQL server database is preprocessed, the appropriate feature values ​​are extracted from the 3D model of the required engineering drawing, the KNN algorithm is used for training and prediction to obtain the most suitable map sheet, and the SolidWorks API function is called to complete the corresponding operation. (3) Adjustment of view scale: The scale of the main view is determined by controlling the ratio of the view envelope to the paper boundary. All basic views are traversed to make the view scale consistent with the main view. The scale of local views is specially set. The corresponding program is written by calling the SolidWorks API interface to complete the setting of the scale of the engineering drawing. (4) Reasonable arrangement of view positions: Determine the position of the main view, and based on the total number of views and the drawing boundary, arrange the remaining views at equal intervals with the main view as the reference to achieve a reasonable arrangement of view positions; (5) Automatic dimensioning: Adjust and modify dimensioning in the 3D model, insert the required annotations, automatically project the 3D model dimensions onto the 2D engineering drawing, and automatically arrange the dimensions according to the layout; (6) Automatically generate BOM: Determine the corresponding positioning points of the BOM based on the size of the map sheet, and call the corresponding API function to complete the automatic generation of the BOM.

2. The intelligent 3D model mapping method based on machine learning according to claim 1, characterized in that, Step (2) specifically involves: (2.1) Call the SQL Server database to preprocess the dataset information; after removing stop words and deduplicating data in step (1.1), call the fit_transform() function to standardize the binary array <file size, number of views> in the dataset, remove the unit restrictions of each attribute data, and make each data attribute belong to the same order of magnitude, which is convenient for comparison and weighting; (2.2) Extract information about the model from which engineering drawings are to be generated, including model name, model file size, and number of views; Call the FileLen(pathname) function to get the size of the model file for which the engineering drawings need to be generated, and obtain the number of engineering drawing views of the model for which the engineering drawings need to be generated based on the calculation results of step (1.2). Standardize this set of data in the form of a binary array of <model file size, number of views> with the binary array of the dataset in step (2.1) to obtain a set of values ​​in a specific range. (2.3) Assume that there are m training samples in the dataset in the database, represented as follows: Based on the map size, the sample categories are divided into 5 types, represented as follows: ; Feature vectors representing training samples: ,in The feature vector of the sample D to be tested is: The similarity between the test sample and the training sample is calculated using cosine similarity, as shown in the following formula: The K training samples with the highest similarity to the test sample are calculated using the cosine formula. We calculate the weights for these K samples and determine the final classification of the samples based on their weights, using the following formula: in, For the category attribute of the sample, the formula is as follows: Based on the calculation results, the sample D to be tested is assigned to the category with the higher weight. middle.

3. The intelligent 3D model mapping method based on machine learning according to claim 2, characterized in that, The specific steps (3) are as follows: (3.1) Obtain the drawing boundary, default view scale, and view envelope; After creating the engineering drawing view by calling the CreateDrawViewFromModelView3(ModelName,ViewName,LocX, LocY,LocZ) function, the view scale is the default scale. You need to use the GetProperties2() function to get the current drawing properties, where Papersize is the drawing size, TemplateIn is the drawing template, Scale1 is the numerator of the drawing scaling ratio, Scale2 is the denominator of the drawing scaling ratio, Width is the drawing width, and Height is the drawing height. Call the GetOutline() function to get the bounding box coordinates of the view. The return value is a double array containing four values, representing Xmin, Ymin, Xmax, and Ymax respectively. (3.2) Determine the scale of the engineering drawing by using the scale of the main view; Call the `swView.Position()` function to get the center coordinates of the main view. Reassign these coordinates to position the main view at the center of the upper left quarter of the drawing. Adjust the scale of the main view to ensure that the ratio of the shorter side of the main view's bounding box to the corresponding drawing boundary is 2:3, as shown in the following formula: in, This indicates the default scale of the current drawing, which can be obtained from the values ​​of Scale1 and Scale2; The length of the shorter boundary corresponding to the drawing is calculated using the drawing width and drawing height. The length of the shorter side of the main view's envelope is represented by subtracting the envelope coordinates Xmin, Ymin, Xmax, and Ymax. After calculating the appropriate view scale, the GetFirstView() and GetNextView() functions are used to traverse each basic view, and the swView.ScaleDecimal() function is used to reassign the scale of each view to make the scale of the engineering drawing view consistent with the main view; the scale of the local view can be specially adjusted using the swView.ScaleRatio() function.

4. The intelligent 3D model mapping method based on machine learning according to claim 3, characterized in that, Step (4) specifically involves: (4.1) Using text similarity retrieval technology, count the view names calculated in step (1); according to the statistical results, place the views in the upper half of the engineering drawing 1 / 2 in the order of right view, front view, left view and back view, according to the principle of equal width and height, as horizontal views, and place the bottom view below the front view accordingly. If a top view exists, the horizontal view should be placed in the lower half of the drawing (1 / 2), and the top view should be placed above the front view. If both top and bottom views exist, the horizontal view should be placed in the middle of the drawing (2 / 3), and the top and bottom views should be placed above and below the front view, respectively. (4.2) Based on the drawing sheet calculated in step (2), use the GetProperties2() function to obtain the drawing boundary value, count the number of horizontal views other than the top and bottom views, call the GetOutline() function to obtain the size of the bounding box of the horizontal view, and place the horizontal views at equal intervals according to the drawing boundary and the bounding box of each view. The spacing calculation formula is as follows: in, The horizontal length of the engineering drawing is obtained by subtracting the boundary values ​​of the drawing. The length of the envelope of the i-th view is represented by coordinates. and Subtracting them gives the result; Indicates the number of views in the horizontal direction; Calculating the vertical view spacing requires determining the number of vertical views, including the top, bottom, and front views. After statistical analysis using text similarity retrieval technology, the GetOutline() function is used to obtain the size of the envelope of the vertical views and calculate the spacing, as shown in the following formula: in, The vertical length of the engineering drawing is obtained by subtracting the boundary values ​​of the drawing. The length of the envelope of the i-th view is represented by coordinates. and Subtracting them gives the result; Indicates the number of views in the vertical direction; (4.3) Based on the calculation results of each spacing, the coordinates of the center point of each view are reassigned using the swView.Position() function to complete the reasonable arrangement of the view positions.

5. The intelligent 3D model mapping method based on machine learning according to claim 4, characterized in that, Step (5) specifically involves: (5.1) Manually annotate and adjust the required annotation information in the 3D model to ensure the standardization and normalization of the annotation information; (5.2) In the drawing module, call the InsertModelAnnotations3() function to map the dimensions in the 3D model to the corresponding 2D drawing view; (5.3) Use the SelectAllinDocument(swModel, swModelDocExt, swSelMgr) function to select all labeled dimensions in the drawing view, and call the AlignDimensions() function to automatically arrange all dimensions to ensure that the labeled dimensions and annotations are neat and beautiful.

6. The intelligent 3D model mapping method based on machine learning according to claim 5, characterized in that, The specific steps (6) are as follows: (6.1) Obtain the drawing sheet calculated in step (2), call the GetProperties2() function to obtain the drawing information, including the drawing boundary frame coordinates, so as to set the relative coordinate position of the BOM table; (6.2) Call the ActivateView(ViewName) function to activate the view of the BOM table to be output, and then use the InsertBomTable4() function to set the X and Y coordinate positions of the BOM table and the BOM table template to complete the automatic insertion of the BOM table.

7. A machine learning-based intelligent 3D model mapping system, wherein the system employs a machine learning-based intelligent 3D model mapping method as described in any one of claims 1-6, characterized in that, The system includes the following modules: Establish a 3D model and engineering drawing information database module: This module is used to statistically analyze and manage the large number of existing 3D models and related engineering drawing information of the enterprise, and to facilitate the matching and retrieval of component model information. Read Component Model Module: Used to obtain the relevant attributes of the 3D model required for generating engineering drawings; Parts model data preprocessing module: This module is used to deduplicate, remove stop words, and segment the data obtained from the parts model module. It also performs one-hot encoding on keywords to optimize and improve the data, thereby increasing the accuracy of matching with data in the database. The component model information calculation, matching, and prediction module is used to calculate and match the optimized data information from the component model data preprocessing module with the database information to obtain relevant information about similar models. Engineering drawing output module: This module is used to automatically output engineering drawings by utilizing information related to matched similar models, similarity retrieval technology, KNN algorithm, and SolidWorks API functions.

8. A computer storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements a machine learning-based intelligent mapping method for 3D models as described in any one of claims 1-6.

9. A computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements a machine learning-based intelligent mapping method for three-dimensional models as described in any one of claims 1-6.

Citation Information

Patent Citations

  • Method and system for automatically making engineering drawing

    CN102855350A

  • A method for automatically adjusting the view of a Solidworks 2D engineering drawing

    CN111767590B

  • Two-dimensional engineering drawing size mark self-adaptive adjustment method

    CN110148197A

  • Three-dimensional CAD model intelligent retrieval method based on double-layer depth residual network

    CN110245249A