Disclosure of Invention
Aiming at the problems in the prior art, the invention provides an assembly constraint inheritance method based on SolidWorks, and the method is characterized in that when a model is drawn in SolidWorks, the constraint information of the model is subjected to lightweight processing, the constraint information is stored in an sfx lightweight format, and when the model is introduced into MakeReal3D software, the constraint information of the model is obtained by analyzing a lightweight format file, so that the step of redefining the constraint information of the model in MakeReal3D is omitted, the labor intensity is greatly reduced, and the working efficiency is improved.
In order to achieve the purpose, the invention adopts the technical scheme that:
an assembly constraint inheritance method based on SolidWorks comprises the following steps:
s1, creating a three-dimensional model by utilizing SolidWorks software, defining constraint information corresponding to the three-dimensional model, and carrying out lightweight processing on the three-dimensional model;
s2, directly calling the API of the SolidWorks constraint module by using the secondary development interface of the SolidWorks software;
s3, acquiring the constraint information of the defined three-dimensional model in SolidWorks through the API, firstly, defining the information format of sfx format, carrying out sfx formatting on the acquired three-dimensional model and the constraint information according to the analysis and explanation rules, reading the three-dimensional model and the constraint information through the agreed sfx format, and then storing the three-dimensional model and the constraint information as a model file of sfx format, wherein the stored model file of sfx format reserves the constraint information of the three-dimensional model;
s4, importing the sfx lightweight format file through MakeReal3D software, and analyzing the sfx lightweight format file to obtain the constraint information;
and S5, automatically creating constraints corresponding to the three-dimensional model in the MakeReal3D according to the constraint information, and obtaining the three-dimensional model with complete constraint information.
Specifically, in step S1, the method of performing the weight reduction processing on the constraint information specifically includes: when a parameterized model is drawn in SolidWorks software, firstly triangularizing the parameterized model in a reduction mode to obtain a renderable three-dimensional model; and then analyzing the three-dimensional model into OpenGL or DirectX for drawing, inheriting and exporting parameter characteristic information, and finally displaying on a screen.
Specifically, in step S3, the defined constraint information includes a parent object of the constraint, a child object, a constraint type, and a reference location of the constraint.
Further, in step S4, after importing the sfx lightweight format file into MakeReal3D, development needs to be performed through a secondary development interface of MakeReal3D, so that the sfx format data import format is increased.
Further, in step S4, after importing the sfx lightweight format file into MakeReal3D, the sfx format model file is analyzed based on the parameterized structure tree, points, lines, planes, assembly relationships, seats, measurements, and states to obtain the three-dimensional model that inherits the model constraint information.
Further, after the constraint information is obtained through analysis, the parameterized features are analyzed in depth, and the parameterized associated identification features are subjected to composite analysis, so that the obtained constraint information is ensured to be complete.
Compared with the prior art, the invention has the beneficial effects that: according to the method, the constraint information of the model drawn in the SolidWorks software is subjected to light weight processing, the API of the SolidWorks constraint module is directly called by using the secondary development interface of the SolidWorks software, the defined constraint information is obtained and stored in the sfx light weight format, and when the model is led into the MakeReal3D software, the constraint information of the model can be obtained by analyzing the sfx light weight format file, so that the step of redefining the model constraint information in the MakeReal3D is omitted, the labor intensity is greatly reduced, and the working efficiency is improved.
Detailed Description
The technical solutions of the present invention will be described clearly and completely with reference to the accompanying drawings, and it is obvious that the described embodiments are only some embodiments of the present invention, not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Because the CAD digital prototype model of the power plant is modeled by Solidworks software, the model is more detailed, the data volume is very large, generally speaking, the CAD digital prototype model is a model file of a plurality of G, the number of triangular panels is as high as five to sixty thousand, and certain challenges are brought to virtual reality simulation software such as Makereal 3D. Model import or loading is the first step of virtual reality simulation, if the problem of data lightweight and import is not solved in this step, great workload is brought to subsequent programming development, rendering efficiency is also influenced, and customer experience is reduced. Therefore, the lightweight technology of the CAD model is particularly important in the project and is also a difficulty.
As shown in fig. 1, the present embodiment provides an assembly constraint inheritance method based on SolidWorks, which specifically includes the following steps:
s1, creating a three-dimensional model by utilizing SolidWorks software, defining constraint information corresponding to the three-dimensional model, and carrying out lightweight processing on the three-dimensional model;
s2, directly calling the API of the SolidWorks constraint module by using the secondary development interface of the SolidWorks software;
s3, acquiring the constraint information of the defined three-dimensional model in SolidWorks through the API, firstly, defining the information format of sfx format, carrying out sfx formatting on the acquired three-dimensional model and the constraint information according to the analysis and explanation rules, reading the three-dimensional model and the constraint information through the agreed sfx format, and then storing the three-dimensional model and the constraint information as a model file of sfx format, wherein the stored model file of sfx format reserves the constraint information of the three-dimensional model;
s4, importing the sfx lightweight format file through MakeReal3D software, and analyzing the sfx lightweight format file to obtain the constraint information;
and S5, automatically creating constraints corresponding to the three-dimensional model in the MakeReal3D according to the constraint information, and obtaining the three-dimensional model with complete constraint information.
Specifically, in step S1, the method of performing the weight reduction processing on the constraint information specifically includes: when a parameterized model is drawn in SolidWorks software, firstly triangularizing the parameterized model in a reduction mode to obtain a renderable three-dimensional model; and then analyzing the three-dimensional model into OpenGL or DirectX for drawing, inheriting and exporting parameter characteristic information, and finally displaying on a screen.
Further, triangularization of the parameterized model is specifically to convert the parameterized model into a triangular patch, in order to ensure the accuracy of analysis of the parameterized model, the parameterized shape is accurately converted into the triangular patch, and the parameterized data is not lost by means of the rendering function of the three-dimensional CAD software; the SolidWorks reduction mode has the advantages that the attribute information and the characteristic information of all models are contained when the models are opened, but the opening speed is very slow and about 50 minutes is needed; and after the file is opened, performing model format conversion by using an sfx converter, wherein the format of the final model file is a platform proprietary format.
Further, the triangle patch simplification algorithm of the model may adopt the following algorithm:
the first algorithm is to distribute a certain number of points on the original mesh, then to use the new vertex and old vertex to generate an intermediate mesh, finally to delete the old vertex in the intermediate mesh, and to perform local triangulation on the generated polygonal area to form a triangular mesh with the new point as the vertex. The new points are distributed by adopting a repulsive force algorithm, namely, the new points are randomly distributed at first, then repulsive force between the new points is calculated, and the new points are moved on the grid according to the repulsive force so as to be redistributed. The magnitude of the repulsive force is related to the distance between the new points, the curvature and the area of the triangle in which the new points are located.
The second algorithm searches coplanar or nearly coplanar patches on the initial mesh and merges them into a larger polygon, and then re-triangulates to fewer patches. Selecting a seed triangular surface, combining surrounding triangles into a larger surface according to a certain criterion, straightening the boundary, and triangularizing the boundary. The algorithm expands the near-plane merging algorithm through wired errors and more accurate local triangulation, and can perform automatic region segmentation when encountering polygons like holes and islands so as to generate a triangulated three-dimensional model without the holes and the islands.
Further, for the three-dimensional model obtained by the algorithm, the number of vertices of the three-dimensional model is compressed before further operation, namely triangular banding is carried out; in the three-dimensional model obtained by the algorithm, most of the triangular patches are separated, namely three vertexes represent a triangle; however, many triangles all have common edges, so that a basis is provided for triangle striping, N triangles are represented, 3N vertices need to be saved in a representation method using three vertices of each triangle, and only N +2 vertices need to be saved for representation in storage of the striped triangles, so that triangle patches of the model are greatly simplified.
Specifically, in step S3, the defined constraint information includes a parent object of the constraint, a child object, a constraint type, and a reference location of the constraint.
Further, in step S4, after importing the sfx lightweight format file into MakeReal3D, development needs to be performed through a secondary development interface of MakeReal3D, so that the sfx format data import format is increased.
Further, in step S4, after importing the sfx lightweight format file into MakeReal3D, the sfx format model file is analyzed based on the parameterized structure tree, points, lines, planes, assembly relationships, seats, measurements, and states to obtain the three-dimensional model that inherits the model constraint information.
Further, after the constraint information is obtained through analysis, the parameterized features are analyzed in depth, and the parameterized associated identification features are subjected to composite analysis, so that the obtained constraint information is ensured to be complete.
The MakeReal3D three-dimensional model local import supports mainstream CAD parameterized simulation model import (including CATIA V5 and other software output formats). After the model is imported, the integrity and the effectiveness of data in the conversion process can be ensured; and information such as a structure tree, geometric information, material information, assembly relation, assembly position and the like in the digital-analog is completely reserved in the data importing process.
The MakeReal3D platform can be well compatible with Solidworks model data, a Solidworks model file is generated into a model sfx file format in a local import mode and then is imported into a platform scene, characteristics and attribute information of the model can be reserved, and cognition of the equipment model is facilitated during roaming browsing.
Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that changes, modifications, substitutions and alterations can be made in these embodiments without departing from the principles and spirit of the invention, the scope of which is defined in the appended claims and their equivalents.