Method for g-code based artwork preview and motion simulation

By parsing G-code instructions into geometric paths and combining them with graphics rendering technology, G-code-based previewing and motion simulation of works have been achieved. This solves the problems of inaccurate previewing, lack of visualization, and insufficient cross-platform simulation capabilities in existing technologies, and improves the visualization and optimization efficiency of processing paths.

CN122154005APending Publication Date: 2026-06-05SHENZHEN ENFU ELECTRONICS TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
SHENZHEN ENFU ELECTRONICS TECH CO LTD
Filing Date
2026-03-09
Publication Date
2026-06-05

AI Technical Summary

Technical Problem

Existing technologies lack G-code-based real machining previews, the motion process is not visualized, path problems are difficult to identify, cross-platform simulation capabilities are weak, machining time cannot be accurately estimated, and there is a lack of effective differentiation and display of path and idle travel.

Method used

G-code instructions are parsed into geometric paths, and the machining path is visualized and the motion process is simulated through graphics rendering technology. WebGL technology is used for cross-platform implementation. The path is marked with color or grayscale by combining feed speed and power parameters, and the machining process is played dynamically to build motion simulation animation.

Benefits of technology

It achieves a preview that is highly consistent with the actual processing, dynamically visualizes the processing path, improves the efficiency of path optimization, supports cross-platform deployment, accurately estimates processing time, and significantly improves the visualization of the processing process and the path analysis capability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122154005A_ABST
    Figure CN122154005A_ABST
Patent Text Reader

Abstract

The application discloses a kind of works preview and motion simulation method based on G-code.It relates to numerical control processing and laser processing technical field.The method includes: obtaining G-code data sequence representing processing task, G-code data sequence is parsed, and the total time consumption of processing state parameter, processing path line segment and processing task is obtained;According to processing state parameter, attribute marking is carried out to processing path line segment, and attribute marking result is obtained;Based on processing path line segment and attribute marking result, data structure suitable for graphic rendering engine is constructed, and rendering data set is obtained;Rendering data set is loaded into graphic rendering engine, path rendering is executed, and the overall preview of processing path is obtained;According to the overall preview of processing path and the total time consumption of processing task, the motion simulation animation of processing process is constructed, and the motion state of simulation equipment in processing process is obtained.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the fields of CNC machining and laser processing technology, and more specifically to a method for previewing and simulating motion based on G-code. Background Technology

[0002] CNC equipment such as laser engraving machines and laser cutting machines typically use G-code as the underlying control command to describe the machine's motion trajectory, feed speed, and processing sequence. In existing laser processing workflows, users usually complete the graphic design in graphic editing software, and then CAM software generates the corresponding G-code file, which is directly sent to the equipment for processing.

[0003] However, the following problems are common in existing technologies: Lack of real-world processing previews based on G-code: Most existing preview functions are based on the original vector graphics (such as SVG, DXF, etc.) for display, rather than on the final generated G-code instructions. This results in a difference between the preview effect and the actual device running trajectory, and cannot accurately reflect the real processing process.

[0004] The movement process is not visualized: Existing systems can only statically display the processing path and cannot dynamically play the processing process according to the execution order of G-code. Users find it difficult to intuitively observe the movement process of the laser head, the path connection sequence, and the empty travel situation.

[0005] Path problems are difficult to detect in a timely manner: In actual processing, problems such as unreasonable path sequence, repeated tool passes, and excessively long idle strokes can easily lead to reduced processing efficiency or even processing defects. However, existing solutions make it difficult to intuitively identify and analyze the above problems before processing.

[0006] Lack of high-performance cross-platform simulation solutions: Traditional simulation systems often rely on local desktop software, resulting in high deployment costs and weak cross-platform capabilities, making it difficult to meet the needs of lightweight, real-time simulation based on the web.

[0007] Furthermore, existing technologies typically cannot accurately estimate the total processing time based on G-code instructions, making it difficult for users to know the actual completion time of their work before processing, which affects production planning and equipment scheduling.

[0008] Meanwhile, most existing path preview methods use a uniform style for display, which fails to reflect the differences in processing parameters such as movement speed and laser power between different processing paths, and also fails to effectively distinguish between processing paths and idle travel paths, making it difficult for users to intuitively judge the processing intensity, energy distribution, and invalid movement.

[0009] Therefore, there is an urgent need for a method that can directly preview works and perform motion simulation based on G-code instructions, so as to improve the visualization of the processing process and the efficiency of path optimization. Summary of the Invention

[0010] In view of this, the present invention provides a method for previewing and simulating motion based on G-code, which parses G-code instructions into geometric paths and uses graphics rendering technology to visualize the processing path and simulate the motion process. This method is applicable to the processing simulation and path optimization of laser engraving machines, laser cutting machines and other CNC equipment.

[0011] To achieve the above objectives, the present invention adopts the following technical solution: A method for previewing works and simulating motion based on G-code includes: Step 1: Obtain the G-code data sequence representing the processing task, parse the G-code data sequence to obtain the processing status parameters, processing path segments, and total processing time; Step 2: Based on the processing status parameters, mark the processing path segments with attributes to obtain the attribute marking results; Step 3: Based on the processing path segments and attribute marking results, construct a data structure suitable for the graphics rendering engine to obtain the rendering data set; Step 4: Load the rendering data set into the graphics rendering engine, perform path rendering, and obtain an overall preview of the processing path; Step 5: Based on the overall preview of the processing path and the total processing time, construct a motion simulation animation of the processing process to obtain the motion state of the simulated equipment during the processing.

[0012] Preferably, the parsing process in step 1 includes: Parse the motion instructions described in each G-code data sequence to obtain the corresponding spatial location points; Based on the positional relationship between adjacent motion commands, construct the path segments of the motion trajectory; Simultaneously analyze the feed rate, power parameters, or machining status parameters carried in each motion command; Calculate the motion time of each machining path segment based on its spatial length and corresponding feed rate parameters; The total time for processing tasks is obtained by summing up the motion time of all processing path segments.

[0013] Preferably, the attribute labeling result of step 2 is used to distinguish between the machining path and the idle travel path, and to assign color or grayscale attributes to the machining path to represent the machining intensity based on the feed rate and power parameters.

[0014] Preferably, step 3 specifically includes: The starting and ending coordinates of the processing path segment are converted into vertex data that the rendering engine can recognize; Convert the color or grayscale attribute corresponding to the processing path segment into color data associated with the vertex data; Based on the order of the processing path segments, the vertex data and color data are organized into a set of rendering data to represent multiple line segments; The rendering data set is used to draw in the graphics rendering engine as a set of line segments.

[0015] Preferably, step 4 specifically includes: Different paths are displayed differently based on the color or grayscale attribute of the processing path line segments; the processing path and the empty travel path are presented with different display features to achieve an overall preview of the processing path based on G-code.

[0016] Preferably, the process of constructing the motion simulation animation of the processing procedure in step 5 includes: Establish a corresponding timeline based on the total processing time of the aforementioned tasks; The processing path segments are divided into multiple time segments according to their execution order and duration on the time axis; During the simulation playback, the processing path segment or part of the processing path segment that should be displayed is determined based on the current time point; By periodically triggering the rendering update mechanism, the processing path segments are displayed step by step according to the timeline, thereby simulating the movement state of the equipment during the actual processing.

[0017] As can be seen from the above technical solution, compared with the prior art, the present invention discloses a method for previewing works and simulating motion based on G-code, which has at least the following beneficial effects: 1. The preview results are highly consistent with the actual processing: This invention directly parses and simulates based on the final generated G-code instructions, avoiding the deviation caused by the original graphic preview, and making the preview results closer to the real processing process.

[0018] 2. Dynamic visualization of processing path: By parsing G-code instructions into geometric line segments and playing them in the execution order, dynamic simulation of the processing process is realized, which significantly improves the user's understanding and control of the equipment's movement process.

[0019] 3. Facilitates path optimization and efficiency improvement: Users can intuitively identify problems such as unreasonable path sequence and excessively long idle travel before processing, providing a reliable basis for path optimization and processing efficiency improvement.

[0020] 4. High performance and suitable for complex path scenarios: It adopts a WebGL-based graphics rendering method, which can efficiently process a large amount of path data and is suitable for complex works and high-precision processing scenarios.

[0021] 5. Cross-platform and already deployed: This invention is implemented based on the Web environment, without relying on a specific operating system or local software installation, and has good cross-platform compatibility and promotional value.

[0022] 6. By analyzing the motion parameters of G-code, the total processing time can be accurately estimated, which facilitates users in assessing processing time and arranging production plans.

[0023] 7. By displaying path grayscale based on speed and power, as well as differentiating and controlling idle travel paths, the processing intensity and ineffective motion are clearly visible, significantly improving the efficiency of path analysis and optimization. Attached Figure Description

[0024] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.

[0025] Figure 1 A preview image of the sculpted work provided for this invention.

[0026] Figure 2 Animated diagrams of the engraving process provided for this invention.

[0027] Figure 3 The diagram provided by this invention shows the red line running without a guide and the black line being processed.

[0028] Figure 4 The method flowchart provided by the present invention. Detailed Implementation

[0029] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0030] This invention aims to solve one or more of the following technical problems existing in the prior art: How to achieve a preview of the finished product that closely matches the actual processing procedure based on the final generated G-code instructions? How to parse motion instructions described in G-code into geometric path data that can be used for graphics rendering? How to dynamically play and simulate motion along the processing path according to the execution order of G-code? How to achieve efficient visualization of complex processing paths while ensuring rendering performance? How to provide intuitive and reliable simulation basis for path optimization and processing sequence analysis? How to accurately calculate the total time of the entire processing based on the motion parameters in G-code? How can we visualize and differentiate machining paths based on parameters such as speed and power in G-code to reflect different machining intensities? How to effectively distinguish between machining paths and idle paths, and support user control over the display and hiding of idle paths for path analysis and optimization? like Figure 4 As shown, this invention discloses a method for previewing works and simulating motion based on G-code, including: Step 1: Obtain the G-code data sequence representing the processing task, parse the G-code data sequence to obtain the processing status parameters, processing path segments, and total processing time; Step 2: Based on the processing status parameters, mark the processing path segments with attributes to obtain the attribute marking results; Step 3: Based on the processing path segments and attribute marking results, construct a data structure suitable for the graphics rendering engine to obtain the rendering data set; Step 4: Load the rendering data set into the graphics rendering engine, perform path rendering, and obtain an overall preview of the processing path; Step 5: Based on the overall preview of the processing path and the total processing time, construct a motion simulation animation of the processing process to obtain the motion state of the simulated equipment during the processing.

[0031] Specifically, the parsing process in step 1 includes: The motion instructions described in each G-code data sequence are parsed to obtain the corresponding spatial position points. The purpose of these spatial coordinate points is to draw the corresponding line segments based on the coordinate system. For example, G1 X100 Y100 controls the laser to move from its current position to a position at x100, y100. First, the G-code is parsed to obtain the coordinates of each motion point, and then the motion path is constructed from these points.

[0032] Based on the positional relationship between adjacent motion commands, construct the path segments of the motion trajectory; Simultaneously analyze the feed rate, power parameters, or machining status parameters carried in each motion command; Calculate the motion time of each machining path segment based on its spatial length and corresponding feed rate parameters; The total time for processing tasks is obtained by summing up the motion time of all processing path segments.

[0033] Preferably, the attribute labeling result of step 2 is used to distinguish between the machining path and the idle travel path, and to assign color or grayscale attributes to the machining path to represent the machining intensity based on the feed rate and power parameters.

[0034] Specifically, step 3 includes: The starting and ending coordinates of the processing path segment are converted into vertex data that the rendering engine can recognize; the coordinates are obtained from G-code.

[0035] Convert the color or grayscale attribute corresponding to the processing path segment into color data associated with the vertex data; Based on the order of the processing path segments, the vertex data and color data are organized into a set of rendering data to represent multiple line segments; The rendering data set is used to draw in the graphics rendering engine as a set of line segments.

[0036] Specifically, step 4 includes: Different paths are displayed differently based on the color or grayscale attribute of the processing path line segments; the processing path and the empty travel path are presented with different display features to achieve an overall preview of the processing path based on G-code.

[0037] Specifically, step 5, the process of constructing the motion simulation animation of the processing procedure, includes: Establish a corresponding timeline based on the total processing time of the aforementioned tasks; The processing path segments are divided into multiple time segments according to their execution order and duration on the time axis; During the simulation playback, the processing path segment or part of the processing path segment that should be displayed is determined based on the current time point; By periodically triggering the rendering update mechanism, the processing path segments are displayed step by step according to the timeline, thereby simulating the movement state of the equipment during the actual processing.

[0038] In one specific embodiment of the present invention, based on the points parsed from G-code, the final simulation image of the work is assembled by connecting these lines, such as... Figures 1-3 As shown.

[0039] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to the method section.

[0040] The above description of the disclosed embodiments enables those skilled in the art to make or use the invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the invention. Therefore, the invention is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A method for previewing works and simulating motion based on G-code, characterized in that, include: Step 1: Obtain the G-code data sequence representing the processing task, parse the G-code data sequence to obtain the processing status parameters, processing path segments, and total processing time; Step 2: Based on the processing status parameters, mark the processing path segments with attributes to obtain the attribute marking results; Step 3: Based on the processing path segments and attribute marking results, construct a data structure suitable for the graphics rendering engine to obtain the rendering data set; Step 4: Load the rendering data set into the graphics rendering engine, perform path rendering, and obtain an overall preview of the processing path; Step 5: Based on the overall preview of the processing path and the total processing time, construct a motion simulation animation of the processing process to obtain the motion state of the simulated equipment during the processing.

2. The method for previewing works and simulating motion based on G-code according to claim 1, characterized in that, The parsing process in step 1 includes: Parse the motion instructions described in each G-code data sequence to obtain the corresponding spatial location points; Based on the positional relationship between adjacent motion commands, construct the path segments of the motion trajectory; Simultaneously analyze the feed rate, power parameters, or machining status parameters carried in each motion command; Calculate the motion time of each machining path segment based on its spatial length and corresponding feed rate parameters; The total time for processing tasks is obtained by summing up the motion time of all processing path segments.

3. The method for previewing works and simulating motion based on G-code according to claim 2, characterized in that, The attribute labeling results of step 2 are used to distinguish between the machining path and the idle travel path, and to assign color or grayscale attributes to the machining path to represent the machining intensity based on the feed rate and power parameters.

4. The method for previewing works and simulating motion based on G-code according to claim 2, characterized in that, Step 3 specifically includes: The starting and ending coordinates of the processing path segment are converted into vertex data that the rendering engine can recognize; Convert the color or grayscale attribute corresponding to the processing path segment into color data associated with the vertex data; Based on the order of the processing path segments, the vertex data and color data are organized into a set of rendering data to represent multiple line segments; The rendering data set is used to draw in the graphics rendering engine as a set of line segments.

5. The method for previewing works and simulating motion based on G-code according to claim 4, characterized in that, Step 4 specifically includes: Different paths are displayed differently based on the color or grayscale attribute of the processing path line segments; the processing path and the empty travel path are presented with different display features to achieve an overall preview of the processing path based on G-code.

6. The method for previewing works and simulating motion based on G-code according to claim 4, characterized in that, The process of constructing motion simulation animation of the processing procedure in step 5 includes: Establish a corresponding timeline based on the total processing time of the aforementioned tasks; The processing path segments are divided into multiple time segments according to their execution order and duration on the time axis; During the simulation playback, the processing path segment or part of the processing path segment that should be displayed is determined based on the current time point; By periodically triggering the rendering update mechanism, the processing path segments are displayed step by step according to the timeline, thereby simulating the movement state of the equipment during the actual processing.