simCNC features, G-codes, Python - Questions & Answers

Created by CS-Lab Support, Modified on Mon, 23 Nov at 9:29 AM by Andrzej Rogozynski

Answers to questions we often get about simCNC, G-code and Python macros. Checked against simCNC 3.604.

How do I home the axes in a fixed order (Z first, then X) from a script?

Call the homing of each axis separately. Each call returns only when that axis has finished homing:

d.executeAxisHoming(Axis.Z)
d.executeAxisHoming(Axis.X)

The same from G-code uses G28.1 P<axis>, where P is a zero-based axis number (P0 = X, P1 = Y, P2 = Z):

G28.1 P2   (home Z)
G28.1 P0   (home X)
G28 is not homing G28 is a rapid move to the stored reference point 1; it does not search the home switches. Homing is G28.1 (and G30.1).

How do I set the current position as a temporary zero and return to the original later?

Use G92. G92 X10 Y20 Z30 shifts the coordinate system so that the current position becomes X10 Y20 Z30. Only the axes given are changed.

  • G92.1 cancels the shift and resets it to zero.
  • G92.2 cancels the shift but keeps its value; G92.3 activates the stored value again.

What is the syntax of G10? G10 P05 X100 Y100 Z200 gives a syntax error.

G10 sets the origin of a work offset in the offset table, which is handy for fixtures in repeated production. The syntax is:

G10 L2 P<index> X_ Y_ Z_ A_ B_ C_
  • L2 and P must be the first two words after G10.
  • P is the work offset index: 1–6 = G54–G59, 7–256 = G59.1–G59.250. simCNC has 256 work offsets.
  • At least one axis word must follow; only the axes given are changed. The values are machine coordinates in the machine base units (G20 is not applied).

For example, G10 L2 P5 X100 Y100 Z200 sets the origin of G58. G10 always overwrites the values in the offset table.

Does simCNC support GOTO, IF or WHILE?

No. For repeated parts of a program simCNC (3.600 and newer) has subprograms:

M98 P100 L3   (run subprogram 100 three times)
M30
O100
G91 G1 X10 F500
G90
M99

O<n> labels a subprogram, M98 P<n> L<repeats> calls it and M99 ends it; subprograms can be nested up to 10 levels. Decisions that depend on machine state belong in a Python macro (an M-code), which can read and set the # parameters used by the program.

Our machine has a cutting tool and a pen. How does simCNC know which tool is used?

Each tool in the tool table has its own offset for the X and Y axes (and the others), so several tools can be mounted next to each other. The M6 macro then lowers and raises the right tool. A tangential knife axis can be switched off from a macro (d.setTangentialAxisEnable(False)); it then does not rotate unnecessarily and does not limit the speed of the other axes.

See also

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article