Pipe cutting simulation method based on SolidWorks secondary development
1. A pipe cutting simulation method based on SolidWorks secondary development is characterized by comprising the following steps:
step S1: analyzing the profile of the file of the pipe part through a pipe section and profile analysis module;
step S2: generating tool path information through a tool path information generating module;
step S3: and (4) performing pipe cutting simulation according to the cutter path information generated in the step (S2) by a pipe cutting simulation module.
2. The pipe cutting simulation method according to claim 1, wherein the step S1 includes the following steps:
step S1.1: creating a new part design document in SolidWorks, carrying out pipe model design to generate a part document, or directly opening an existing part document;
step S1.2: analyzing the section and the profile of the pipe, and analyzing the size parameters of the pipe; the section types comprise circle, rectangle, ellipse, triangle, oval, hexagon, L shape, I shape and groove shape; the geometric elements of the outline comprise a surface, a closed outline and an edge; the dimensional parameters include length, width, height, radius of circle, radius of chamfer.
Step S1.3: and caching the pipe part model parameter information output in the step S1.2.
3. The pipe cutting simulation method according to claim 1 or 2, wherein the cutter path information generating module in the step S2 generates the cutter path information by combining the analysis result of the step S1 with the parameters set by the user; and in the step S3, the whole cutting process of the pipe is simulated and displayed by the pipe cutting simulation module according to the cutter path information generated in the step S2 and the simulation parameters for setting.
4. The pipe cutting simulation method according to claim 1 or 2, wherein the step S3 includes the steps of:
step S3.1: loading simulation configuration in SolidWorks;
step S3.2: acquiring the cutter path information generated in the step S2, and copying and loading the generated cutter path information into an internal memory;
step S3.3: circularly processing the nth closed contour according to the cutter path information data generated in the step S2 or the cutter path information data stored in the memory and generated in the step S2, wherein n is more than or equal to 1 and is less than or equal to the total number of the contours;
if the contour is processed, go to step S3.11;
otherwise, executing step S3.4;
step S3.4: judging whether the contour to be processed currently has an edge to be processed;
if so, step S3.5 is performed,
if not, making n equal to n +1 and executing step S3.3, processing the (n + 1) th closed contour;
step S3.5: circularly processing the mth edge of the current contour, wherein m is more than or equal to 1 and less than or equal to the total number of the edges of the current contour;
if m > the total number of the current contour edges, the edge has been processed, so that n is equal to n +1, execute step S3.3, process the contour in the (n + 1) th closed contour;
otherwise, executing step S3.6;
step S3.6: according to the simulation configuration information, performing transformation processing on the display coordinates of the simulation part;
step S3.7: loading the information of the laser head and the chuck into a memory for storage;
step S3.8: judging whether all the contours are simulated or not;
if the contour is processed, go to step S3.13;
otherwise, executing step S3.9;
step S3.9: acquiring a real-time speed value set by a user, and executing the step S3.10 after acquiring the speed value;
step S3.10: judging whether the user inputs an exit button or not;
if the user has an exit operation, executing step S3.13;
otherwise, executing step S3.11;
step S3.11: performing matrix transformation on display information of the laser head and the chuck according to the current Z profile information, wherein Z is more than or equal to 1 and less than or equal to the total number of profiles;
if the matrix transformation of the current Z profile information to the display information of the laser head and the chuck is finished, executing the step S3.12;
otherwise, matrix change of information displayed by the laser head and the chuck is carried out;
step S3.12: performing matrix transformation on the display information of the simulation part according to the current Z profile information;
if the matrix transformation processing of the display information of the simulation part is completed by the current Z-profile information, so that Z is equal to Z +1, executing step S3.8;
otherwise, executing the display coordinate change of the simulation part, calling a SolidWorks part display interface to display the simulation part, and drawing the simulation track by utilizing OpenGL;
step S3.13: and ending the simulation process.
5. The pipe cutting simulation method according to claim 4, wherein the configuration information of the simulation configuration comprises chuck position, dead zone length, laser head position.
6. The pipe cutting simulation method according to claim 4, wherein the simulation speed is optimized in the simulation display process of step S3, and the optimization processing step comprises:
a1. loading laser head information into a memory;
a2. combining the laser head and the simulation part, and changing the position display information of the laser head according to the contour Loop information of the simulation part;
a3. dynamically loading the Loop information of each cutting profile, and only changing the positions and postures of the current part profile Loop and the laser head before cutting;
a4. fusing the cutter assembly at the lowest part of the laser head with the normal vector generated in the cutter path information of the step S2, and performing corresponding matrix transformation;
a5. in the dynamic simulation process, after the simulation of the current contour Loop is processed, the matching relation characteristic of the current contour Loop is deleted, the cutting normal vector data of the next contour Loop is calculated, and the matching relation is reestablished;
a6. and completing the simulation process after the circulation is finished to the cutting end point.
7. The pipe cutting simulation method according to claim 4, wherein the matrix transformation process in the step a4 is as follows:
a 4.1: reading the value of the position (X, Y, Z) of the cutting point in the cutter path information, and then solving the attitude B, C of the laser head through the position (X, Y, Z) of the cutting point at the cutting point and the direction (i, j, k) of the laser beam:
from the above equation, the following B, C values can be obtained
Wherein, the lambda represents the curve parameter of the cutting point along the curve obtained by parameterizing the curve by adopting a chord length method for the NURBS curve;
a 4.2: and (3) matrix transformation is carried out:
converting the set array into a MathTransform object, wherein the array comprises 16 elements, and the corresponding relation between the element sequence and the homogeneous matrix is as follows:
wherein the first 9 elements (ArrayData [0] to ArrayData [8]) form a3 × 3 rotator matrix, the next 3 elements (ArrayData [9] to ArrayData [11]) represent translation vectors, the next 1 element (ArrayData [12]) is a scale factor, and μ represents the three-dimensional vector of laser head motion; theta represents a three-dimensional vector of a motion normal, omega represents a cross product of the two vectors, p is a translation vector of motion, w is a scale factor, and the default value is 1; the definition of the elements of the rotation sub-matrix and the translation vector is consistent with that of the elements in the homogeneous matrix, and the matrix transformation of the cutting simulation is generated by the rotation sub-matrix, the translation vector and the scale factor.
8. The pipe cutting simulation method according to claim 1, wherein a programming language used for programming the cutting simulation method is one or more of a C language, a C + + language, a C # language, and a Basic language.
Background
SolidWorks is a three-dimensional CAD system developed based on Windows under the Dassault systems (Dassault systems) flag, and has powerful functions and various components.
The SolidWorks uses Windows OLE technology, visual design technology, advanced parasolid kernel and good integration technology with third-party software, and has a large market share in the world.
Because solid works is mainly concentrated on Computer Aided Design (CAD), the tool path processing is not related much in the aspect of Computer Aided Manufacturing (CAM), particularly, the tool path processing plug-ins for the laser pipe cutting machine are quite few, while the traditional tool path generation software needs to generate the tool path by carrying out a large amount of calculation on parts designed for the solid works, the efficiency is low, the judgment is not accurate in the aspect of processing lines, particularly on arcs, the simulation quality generated according to the tool path is poor, the actual cutting operation process cannot be simulated really, and when complex parts are simulated, the simulation speed is slow, and the working efficiency is influenced. .
Therefore, a pipe cutting simulation method based on the SolidWorks secondary development is required to be provided to assist the production and machining process of the laser cutting pipe.
Disclosure of Invention
In order to solve the technical problems, the invention aims to provide a pipe cutting simulation method based on the SolidWorks secondary development, which uses a two-shot development interface provided by SolidWorks software to carry out simulation processing on generated tool path information of a pipe part, can simulate and display the whole process of pipe cutting, and enables a user to visually watch the whole cutting process, thereby facilitating the user to control and verify the cutting process. Meanwhile, a part of simulation flow is optimized, the problem that the simulation speed of the complex part is low is solved, the simulation speed of the complex part is improved, and the working efficiency is improved.
In order to achieve the purpose, the technical scheme adopted by the invention is as follows:
a pipe cutting simulation method based on SolidWorks secondary development comprises the following steps:
step S1: analyzing the profile of the file of the pipe part through a pipe section and profile analysis module;
step S2: generating tool path information through a tool path information generating module;
step S3: and (4) performing pipe cutting simulation according to the cutter path information generated in the step (S2) by a pipe cutting simulation module.
Preferably, the step S1 includes the following steps:
step S1.1: creating a new part design document in SolidWorks, carrying out pipe model design to generate a part document, or directly opening an existing part document;
step S1.2: analyzing the section and the profile of the pipe, and analyzing the size parameters of the pipe; the section types comprise circle, rectangle, ellipse, triangle, oval, hexagon, L shape, I shape and groove shape; the geometric elements of the outline comprise a surface, a closed outline and an edge; the dimensional parameters include length, width, height, radius of circle, radius of chamfer.
Step S1.3: and caching the pipe part model parameter information output in the step S1.2.
Preferably, the tool path information generating module in step S2 generates the tool path information by combining the analysis result in step S1 with the parameters set by the user; and in the step S3, the whole cutting process of the pipe is simulated and displayed by the pipe cutting simulation module according to the cutter path information generated in the step S2 and the simulation parameters for setting.
Preferably, the step S3 includes the following steps:
step S3.1: loading simulation configuration in SolidWorks;
step S3.2: acquiring the cutter path information generated in the step S2, and copying and loading the generated cutter path information into an internal memory; the subsequent operation is convenient;
step S3.3: circularly processing the nth closed contour according to the cutter path information data generated in the step S2 or the cutter path information data stored in the memory and generated in the step S2, wherein n is more than or equal to 1 and is less than or equal to the total number of the contours;
if the contour is processed, go to step S3.11;
otherwise, executing step S3.4;
step S3.4: judging whether the contour to be processed currently has an edge to be processed;
if so, step S3.5 is performed,
if not, making n equal to n +1 and executing step S3.3, processing the (n + 1) th closed contour;
step S3.5: circularly processing the mth edge of the current contour, wherein m is more than or equal to 1 and less than or equal to the total number of the edges of the current contour;
if m > the total number of the current contour edges, the edge has been processed, so that n is equal to n +1, execute step S3.3, process the contour in the (n + 1) th closed contour;
otherwise, executing step S3.6;
step S3.6: according to the simulation configuration information, performing transformation processing on the display coordinates of the simulation part;
step S3.7: loading the information of the laser head and the chuck into a memory for storage;
step S3.8: judging whether all the contours are simulated or not;
if the contour is processed, go to step S3.13;
otherwise, executing step S3.9;
step S3.9: acquiring a real-time speed value set by a user, wherein the speed value is a real-time speed value of laser head movement and can directly influence the speed of the simulation speed, and executing the step S3.10 after acquiring the speed value;
step S3.10: judging whether the user inputs an exit button or not;
if the user has an exit operation, executing step S3.13;
otherwise, executing step S3.11;
step S3.11: performing matrix transformation on display information of the laser head and the chuck according to the current Z profile information, wherein Z is more than or equal to 1 and less than or equal to the total number of profiles;
if the matrix transformation of the current Z profile information to the display information of the laser head and the chuck is finished, executing the step S3.12;
otherwise, matrix change of information displayed by the laser head and the chuck is carried out;
step S3.12: performing matrix transformation on the display information of the simulation part according to the current Z profile information;
if the matrix transformation processing of the display information of the simulation part is completed by the current Z-profile information, so that Z is equal to Z +1, executing step S3.8;
otherwise, executing the display coordinate change of the simulation part, calling a SolidWorks part display interface to display the simulation part, and drawing the simulation track by utilizing OpenGL;
step S3.13: and ending the simulation process.
More preferably, the step of transforming the display coordinates of the dummy part in step S3.6 includes: drawing a tool path coordinate system in the part document, calculating a transformation matrix of the tool path coordinate system relative to a world coordinate system, and mapping the designed simulation part model into the tool path coordinate system according to the transformation matrix.
Preferably, the configuration information of the simulation configuration comprises a chuck position, a dead zone length and a laser head position.
Preferably, in the simulation display process of step S3, the optimization processing is performed on the simulation speed, and the optimization processing step includes:
a1. loading laser head information into a memory; therefore, the information of the laser head is loaded only once in the simulation process, and the problem that the speed is reduced due to the waste of resources caused by frequent reading of the information of the laser head by a program is solved. The laser head comprises a tool shoulder assembly, a tool arm assembly and a tool assembly, wherein the tool assembly is located at the lowest part and directly moves above a tool path track during simulation. The combination of the tool shoulder assembly, the tool arm assembly and the tool assembly simulates the real shape of the laser head and can be replaced by a simple graphic file stored in advance;
a2. combining the laser head and the simulation part, and changing the position display information of the laser head according to the contour Loop information of the simulation part; the information of the outline Loop mainly comprises information of each edge in the outline, lead-in lead-out line information, information of whether the edge is a common edge or not, corner information, information of whether the edge is a first or last outline or not and compensation information;
a3. dynamically loading the Loop information of each cutting profile, and only changing the position and the posture of the current part profile Loop and the laser head before cutting to achieve the purpose of quick change;
a4. fusing the cutter assembly at the lowest part of the laser head with the normal vector generated in the cutter path information of the step S2, and performing corresponding matrix transformation;
a5. in the dynamic simulation process, after the simulation of the current contour Loop is processed, the matching relation characteristic of the current contour Loop is deleted, the cutting normal vector data of the next contour Loop is calculated, and the matching relation is reestablished;
a6. and completing the simulation process after the circulation is finished to the cutting end point.
Preferably, the matrix transformation process in step a4 is as follows:
a 4.1: reading the value of the position (X, Y, Z) of the cutting point in the cutter path information, and then solving the attitude B, C of the laser head through the position (X, Y, Z) of the cutting point at the cutting point and the direction (i, j, k) of the laser beam:
from the above equation, the following B, C values can be obtained
Wherein, the lambda represents the curve parameter of the cutting point along the curve obtained by parameterizing the curve by adopting a chord length method for the NURBS curve;
a 4.2: and (3) matrix transformation is carried out:
converting the set array into a MathTransform object, wherein the array comprises 16 elements, and the corresponding relation between the element sequence and the homogeneous matrix is as follows:
wherein the first 9 elements (ArrayData [0] to ArrayData [8]) form a3 × 3 rotator matrix, the next 3 elements (ArrayData [9] to ArrayData [11]) represent translation vectors, the next 1 element (ArrayData [12]) is a scale factor, and μ represents the three-dimensional vector of laser head motion; theta represents a three-dimensional vector of a motion normal, omega represents a cross product of the two vectors, p is a translation vector of motion, w is a scale factor, and the default value is 1; the definition of the elements of the rotation sub-matrix and the translation vector is consistent with that of the elements in the homogeneous matrix, and the matrix transformation of the cutting simulation is generated by the rotation sub-matrix, the translation vector and the scale factor.
In the SolidWorks, the array transformation matrix cannot be directly used to complete the homogeneous transformation of the components, so when in use, a set array needs to be converted into a MathTransform object, and the MathTransform object is an object after mathematical transformation. The last three elements (ArrayData [13] to ArrayData [15]) are not used in the present invention.
Preferably, the programming language for programming the cutting simulation method is one or more of C language, C + + language, C # language and Basic language.
More preferably, the programming language used to program the method is the C + + language.
Preferably, the step S2 includes the following steps:
step S2.1: loading a tool path configuration in SolidWorks, wherein the tool path configuration comprises interpolation step length and tolerance;
step S2.2: setting a normal direction of cutting of a cutter path, wherein the direction comprises a surface normal and 5-axis cutting;
step S2.3: reading the parameter information data of the pipe part model cached in the pipe section and contour analysis module, and circularly processing the nth closed contour, wherein n is more than or equal to 1 and less than or equal to the total number of the contours;
if n > the total number of contours, the contours are processed, and step S2.11 is executed;
otherwise, executing step S2.4;
step S2.4: judging whether the contour to be processed currently is an outer contour:
if yes, executing step S2.5;
otherwise, n is n +1 and step S2.3 is performed;
step S2.5: circularly processing the mth edge of the current contour, wherein m is more than or equal to 1 and less than or equal to the total number of the edges of the current contour;
if m > the total number of the current contour edge, the edge is processed, and if n is equal to n +1, executing step S2.3;
otherwise, executing step S2.6;
step S2.6: judging the type of the current line, wherein the line type is analyzed and calculated in the pipe section and contour analysis module, and the line type comprises a straight line, a regular circular arc and a B spline curve;
if the line type is a straight line, executing the step S2.7;
if the line type is a regular arc, executing the step S2.8;
if the line type is a B spline curve, executing the step S2.9;
step S2.7: calculating and caching the coordinates of the starting point of the straight line;
step S2.8: calculating the center coordinates and the radius of the circular arc;
step S2.9: dispersing lines by a B-spline curve interpolation method;
step S2.10: generating a current discrete node coordinate and a corresponding tool vector, wherein m is m +1, and executing the step S2.5;
step S2.11: sequencing the outlines of the generated nodes by taking the length X direction of the part as a main direction;
step S2.12: reading the lead configuration and generating a lead for each contour, wherein the lead comprises a lead-in wire and a lead-out wire;
step S2.13: displaying a tool path track and a tool normal in the pipe part model;
step S2.14: and serializing and storing the tool path data.
Preferably, said step S2.4 comprises the steps of:
step S2.4.1: all the surfaces of the part are obtained by utilizing a SolidWorks secondary development interface and are put into an array, and the array is sorted according to the area of the surfaces from large to small to obtain the listFace of the array;
step S2.4.2: performing cycle analysis on each surface of the array list face to separate the inner surface and the outer surface, wherein the specific method comprises the following steps:
step S2.4.2.1: taking the ith face (i), wherein i is more than or equal to 0 and less than the size of the face array, and taking any point of the face;
step S2.4.2.2: taking the normal of the surface at the point;
step S2.4.2.3: traversing other faces 1, and judging whether the face1 is parallel to the analyzed face listFace [ i ] or not through a SolidWorks secondary development interface:
if the normal line is parallel and also passes through the face1, the face1 face and the analyzed face listFace [ i ] are considered to be matched inner and outer faces;
step S2.4.2.4: if the area of the face1 surface is smaller than the analysis face i, the face1 surface is an inner surface, and the analysis face i is an outer surface;
step S2.4.3: and acquiring the contour of each surface by utilizing a SolidWorks secondary development interface, wherein if the surface where the contour is located is an outer surface, the contour is an outer contour, and otherwise, the contour is an inner contour.
Compared with the prior art, the invention has the beneficial technical effects that:
the method for simulating the pipe cutting based on the SolidWorks secondary development is characterized in that a two-generation development interface provided by SolidWorks software is used, C + + is adopted as an optimal development language, the whole pipe cutting process is simulated and displayed according to the generated tool path information of the pipe, and a user can conveniently master the whole cutting process. By carrying out simulation on the optimized cutter path information, the full control of the cutting process can be effectively improved, and the working efficiency is improved. The occurrence of cutting error conditions in the production environment is effectively avoided. Meanwhile, under the condition of simulating complex parts, the system reading overhead is reduced, and the mode of loading calculated amount every time is reduced through multiple times of loading, so that the simulation speed is improved, and the working efficiency is improved.
Drawings
FIG. 1 is a functional block diagram of the operation of the modules in the pipe cutting simulation method according to the embodiment of the present invention;
FIG. 2 is a schematic block diagram of step S2 in an embodiment of the present invention;
FIG. 3 is a functional block diagram of step S3 in an embodiment of the present invention;
fig. 4 is a schematic block diagram of the simulation optimization process in step S3 in the embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is further described in detail with reference to the following embodiments, but the scope of the present invention is not limited to the following embodiments.
Examples
Referring to fig. 1, the embodiment discloses a pipe cutting simulation method based on solid works secondary development, and referring to fig. 1, a pipe section and contour analysis module, a tool path information generation module and a simulation processing module are adopted.
Preferably, the programming language for programming the pipe cutting simulation method is C language, C + + language, C # language or Basic language.
Preferably, the programming language for programming the pipe cutting simulation method is C + + language.
The pipe cutting simulation method based on the SolidWorks secondary development comprises the following steps:
step S1: analyzing the profile of the file of the pipe part through a pipe section and profile analysis module;
step S2: generating tool path information through a tool path information generating module;
step S3: and (4) performing pipe cutting simulation according to the cutter path information generated in the step (S2) by a pipe cutting simulation module.
Specifically, the step S1 includes the following steps:
step S1.1: creating a new part design document in SolidWorks, carrying out pipe model design to generate a part document, or directly opening an existing part document;
step S1.2: analyzing the section and the profile of the pipe, and analyzing the size parameters of the pipe; the section types comprise circle, rectangle, ellipse, triangle, oval, hexagon, L shape, I shape and groove shape; the geometric elements of the outline comprise a surface, a closed outline and an edge; the dimensional parameters include length, width, height, radius of circle, radius of chamfer.
Step S1.3: and caching the pipe part model parameter information output in the step S1.2.
The tool path information generating module in the step S2 generates tool path information by combining the analysis result of the step S1 with the parameters set by the user; and in the step S3, the whole cutting process of the pipe is simulated and displayed by the pipe cutting simulation module according to the cutter path information generated in the step S2 and the simulation parameters for setting.
Specifically, referring to fig. 2, the step S2 includes the following steps:
step S2.1: loading a tool path configuration in SolidWorks, wherein the tool path configuration comprises interpolation step length and tolerance;
step S2.2: setting a normal direction of cutting of a cutter path, wherein the direction comprises a surface normal and 5-axis cutting;
step S2.3: reading the parameter information data of the pipe part model cached in the pipe section and contour analysis module, and circularly processing the nth closed contour, wherein n is more than or equal to 1 and less than or equal to the total number of the contours;
if n > the total number of contours, the contours are processed, and step S2.11 is executed;
otherwise, executing step S2.4;
step S2.4: judging whether the contour to be processed currently is an outer contour:
if yes, executing step S2.5;
otherwise, n is n +1 and step S2.3 is performed;
step S2.5: circularly processing the mth edge of the current contour, wherein m is more than or equal to 1 and less than or equal to the total number of the edges of the current contour;
if m > the total number of the current contour edge, the edge is processed, and if n is equal to n +1, executing step S2.3;
otherwise, executing step S2.6;
step S2.6: judging the type of the current line, wherein the line type is analyzed and calculated in the pipe section and contour analysis module, and the line type comprises a straight line, a regular circular arc and a B spline curve;
if the line type is a straight line, executing the step S2.7;
if the line type is a regular arc, executing the step S2.8;
if the line type is a B spline curve, executing the step S2.9;
step S2.7: calculating and caching the coordinates of the starting point of the straight line;
step S2.8: calculating the center coordinates and the radius of the circular arc;
step S2.9: dispersing lines by a B-spline curve interpolation method;
step S2.10: generating a current discrete node coordinate and a corresponding tool vector, wherein m is m +1, and executing the step S2.5;
step S2.11: sequencing the outlines of the generated nodes by taking the length X direction of the part as a main direction;
step S2.12: reading the lead configuration and generating a lead for each contour, wherein the lead comprises a lead-in wire and a lead-out wire;
step S2.13: displaying a tool path track and a tool normal in the pipe part model;
step S2.14: and serializing and storing the tool path data.
Preferably, said step S2.4 comprises the steps of:
step S2.4.1: all the surfaces of the part are obtained by utilizing a SolidWorks secondary development interface and are put into an array, and the array is sorted according to the area of the surfaces from large to small to obtain the listFace of the array;
step S2.4.2: performing cycle analysis on each surface of the array list face to separate the inner surface and the outer surface, wherein the specific method comprises the following steps:
step S2.4.2.1: taking the ith face (i), wherein i is more than or equal to 0 and less than the size of the face array, and taking any point of the face;
step S2.4.2.2: taking the normal of the surface at the point;
step S2.4.2.3: traversing other faces 1, and judging whether the face1 is parallel to the analyzed face listFace [ i ] or not through a SolidWorks secondary development interface:
if the normal line is parallel and also passes through the face1, the face1 face and the analyzed face listFace [ i ] are considered to be matched inner and outer faces;
step S2.4.2.4: if the area of the face1 surface is smaller than the analysis face i, the face1 surface is an inner surface, and the analysis face i is an outer surface;
step S2.4.3: and acquiring the contour of each surface by utilizing a SolidWorks secondary development interface, wherein if the surface where the contour is located is an outer surface, the contour is an outer contour, and otherwise, the contour is an inner contour.
Specifically, referring to fig. 3, the step S3 includes the following steps:
step S3.1: loading simulation configuration in SolidWorks, wherein configuration information of the simulation configuration comprises a chuck position, a dead zone length and a laser head position;
step S3.2: acquiring the cutter path information generated in the step S2, and copying and loading the generated cutter path information into an internal memory; the subsequent operation is convenient;
step S3.3: circularly processing the nth closed contour according to the cutter path information data generated in the step S2 or the cutter path information data stored in the memory and generated in the step S2, wherein n is more than or equal to 1 and is less than or equal to the total number of the contours;
if the contour is processed, go to step S3.11;
otherwise, executing step S3.4;
step S3.4: judging whether the contour to be processed currently has an edge to be processed;
if so, step S3.5 is performed,
if not, making n equal to n +1 and executing step S3.3, processing the (n + 1) th closed contour;
step S3.5: circularly processing the mth edge of the current contour, wherein m is more than or equal to 1 and less than or equal to the total number of the edges of the current contour;
if m > the total number of the current contour edges, the edge has been processed, so that n is equal to n +1, execute step S3.3, process the contour in the (n + 1) th closed contour;
otherwise, executing step S3.6;
step S3.6: according to the simulation configuration information, performing transformation processing on the display coordinates of the simulation part;
step S3.7: loading the information of the laser head and the chuck into a memory for storage;
step S3.8: judging whether all the contours are simulated or not;
if the contour is processed, go to step S3.13;
otherwise, executing step S3.9;
step S3.9: acquiring a real-time speed value set by a user, wherein the speed value is a real-time speed value of laser head movement and can directly influence the speed of the simulation speed, and executing the step S3.10 after acquiring the speed value;
step S3.10: judging whether the user inputs an exit button or not;
if the user has an exit operation, executing step S3.13;
otherwise, executing step S3.11;
step S3.11: performing matrix transformation on display information of the laser head and the chuck according to the current Z profile information, wherein Z is more than or equal to 1 and less than or equal to the total number of profiles;
if the matrix transformation of the current Z profile information to the display information of the laser head and the chuck is finished, executing the step S3.12;
otherwise, matrix change of information displayed by the laser head and the chuck is carried out;
step S3.12: performing matrix transformation on the display information of the simulation part according to the current Z profile information;
if the matrix transformation processing of the display information of the simulation part is completed by the current Z-profile information, so that Z is equal to Z +1, executing step S3.8;
otherwise, executing the display coordinate change of the simulation part, calling a SolidWorks part display interface to display the simulation part, and drawing the simulation track by utilizing OpenGL;
step S3.13: and ending the simulation process.
More preferably, the step of transforming the display coordinates of the dummy part in step S3.6 includes: drawing a tool path coordinate system in the part document, calculating a transformation matrix of the tool path coordinate system relative to a world coordinate system, and mapping the designed simulation part model into the tool path coordinate system according to the transformation matrix.
If the features of the simulation part are more in the simulation process, the simulation speed may be slower. Referring to fig. 4, the simulation module related to step S3 is optimized for this case, and the optimization processing step includes:
a1. loading laser head information into a memory; therefore, the information of the laser head is loaded only once in the simulation process, and the problem that the speed is reduced due to the waste of resources caused by frequent reading of the information of the laser head by a program is solved. The laser head comprises a tool shoulder assembly, a tool arm assembly and a tool assembly, wherein the tool assembly is located at the lowest part and directly moves above a tool path track during simulation. The combination of the tool shoulder assembly, the tool arm assembly and the tool assembly simulates the real shape of the laser head and can be replaced by a simple graphic file stored in advance;
a2. combining the laser head and the simulation part, and changing the position display information of the laser head according to the contour Loop information of the simulation part; the information of the outline Loop mainly comprises information of each edge in the outline, lead-in lead-out line information, information of whether the edge is a common edge or not, corner information, information of whether the edge is a first or last outline or not, compensation information and the like;
a3. dynamically loading the Loop information of each cutting profile, and only changing the position and the posture of the current part profile Loop and the laser head before cutting to achieve the purpose of quick change;
a4. fusing the cutter assembly at the lowest part of the laser head with the normal vector generated in the cutter path information of the step S2, and performing corresponding matrix transformation;
a5. in the dynamic simulation process, after the simulation of the current contour Loop is processed, the matching relation characteristic of the current contour Loop is deleted, the cutting normal vector data of the next contour Loop is calculated, and the matching relation is reestablished;
a6. and completing the simulation process after the circulation is finished to the cutting end point.
Preferably, the matrix transformation process in step a4 is as follows:
a 4.1: reading the value of the position (X, Y, Z) of the cutting point in the cutter path information, and then solving the attitude B, C of the laser head through the position (X, Y, Z) of the cutting point at the cutting point and the direction (i, j, k) of the laser beam:
from the above equation, the following B, C values can be obtained
a 4.2: and (3) matrix transformation is carried out:
wherein, the lambda represents the curve parameter of the cutting point along the curve obtained by parameterizing the curve by adopting a chord length method for the NURBS curve;
converting the set array into a MathTransform object, wherein the array comprises 16 elements, and the corresponding relation between the element sequence and the homogeneous matrix is as follows:
wherein the first 9 elements (ArrayData [0] to ArrayData [8]) form a3 × 3 rotator matrix, the next 3 elements (ArrayData [9] to ArrayData [11]) represent translation vectors, the next 1 element (ArrayData [12]) is a scale factor, and μ represents the three-dimensional vector of laser head motion; theta represents a three-dimensional vector of a motion normal, omega represents a cross product of the two vectors, p is a translation vector of motion, w is a scale factor, and the default value is 1; the definition of the elements of the rotation sub-matrix and the translation vector is consistent with that of the elements in the homogeneous matrix, and the matrix transformation of the cutting simulation is generated by the rotation sub-matrix, the translation vector and the scale factor.
In the SolidWorks, the array transformation matrix cannot be directly used to complete the homogeneous transformation of the components, so when in use, a set array needs to be converted into a MathTransform object, and the MathTransform object is an object after mathematical transformation. The last three elements (ArrayData [13] to ArrayData [15]) are not used in the present invention.
By carrying out simulation on the optimized cutter path information, the full control of the cutting process can be effectively improved, and the working efficiency is improved. The occurrence of cutting error conditions in the production environment is effectively avoided. Meanwhile, under the condition of simulating complex parts, the system reading overhead is reduced, and the mode of loading calculated amount every time is reduced through multiple times of loading, so that the simulation speed is improved, and the working efficiency is improved.
Variations and modifications to the above-described embodiments may occur to those skilled in the art, which fall within the scope and spirit of the above description. Therefore, the present invention is not limited to the specific embodiments disclosed and described above, and some modifications and variations of the present invention should fall within the scope of the claims of the present invention. Furthermore, although specific terms are employed herein, they are used in a generic and descriptive sense only and not for purposes of limitation.