Gcode and commands

本文深入解析了CNCSimulator中的G代码指令,包括G0、G1、G2、G3、G4等常用代码的含义、格式及应用实例,为用户提供全面的G代码知识指南。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

G codes

Parent Previous Next

The following tables will give a brief explanation to the various G, M and other codes recognized by the CNCSimulator interpreter. In the Format column, you will see the format expected by the program. If a code is written within brackets like this [X#] it means that the code is non obligatory and can be omitted if not needed. The # sign means that the CNCSimulator expects a number and the $ sign means that it is expecting a text string within quotation marks.


Let's show an example:

G12[X#][Y#]Z#R#Q#S#SA#AS#RA#H#


This means that the code G12 accepts X and Y coordinates but they are not obligatory and can be omitted. On the other hand, you must specify the Z,R,Q,S,SA,AS,RA and H codes to avoid an alarm at runtime.

G-code

(codes valid from V1.0.6.5)

Explanation

Format

Example

Machine type

G0 or G00

Go rapidly (with maximum traverse rate) to the X/Y/Z position. This code is used for position and not for actual machining.

G0 [X#][Y#][Z#]

G0 Z100

All machines

G1 or G01

Travel in a straight line using the programmed feed rate (F). This code is used for machining.

G1 [X#][Y#][Z#][F#]

G1 X2.5 Y4.1 F200

All machines

G2 or G02

XY-machines

Lathe

Circular/Helical Interpolation clockwise. It causes a clockwise circular movement at programmed feed rate (F). The motion can be 2-dimensional (flat) or 3-dimensional (helical). The default plane of the circular movement is the XY-plane (G17) but other planes can be used as well (see G17-G19). The center of the arc or circle is programmed using the I, J and K letters (R can also be used).

G2[X#][Y#][Z#]

[I#][J#][K#][R#][F#]

G2 X10 Y10 I10 J0 F200

All machines

G3 or G03

XY-machines

Lathe

Exactly like G2 but the circular motion is going counterclockwise.

G3[X#][Y#][Z#]
[I#][J#][K#][R#][F#]

G3 X10 Y10 I10 J0 F200

All machines

G4

Dwell in milliseconds. This will keep the axes unmoving for the period of timed specified by the P number.

G4 P#

G4 P2000 (Two seconds delay)

All machines

G12

Circular drilling canned cycle. Use to drill holes around the contour of a circle. R is starting plane and Z is total drill depth for each hole. Q is incremental depth (peck). SA is circle start angle (angle of first hole too) and AS is angle between holes. RA is circle radius and H specifies the number of holes to drill.

G12[X#][Y#]Z#
R#Q#S#SA#
AS#RA#H#

G12 X0 Y0 Z-20 R2 Q5 SA0 AS36 RA30 H10

Milling machines only

G17

Selects the XY plane for circular movements (see G2 and G3).

G17

G17

Milling machines only

G18

Selects the XZ plane for circular movements (see G2 and G3)

G18

G18

Milling machines only

G19

Selects the YZ plane for circular movements (see G2 and G3)

G19

G19

Milling machines only

G28

Return home command. This command will first go to the programmed position X/Y/Z and then to the Xmin Ymax Zmax of the machine axes. It can be a convenient way to end a program putting the machine table in a position to change workpiece.

G28[X#][Y#][Z#]

G28 Z10

Milling and turning machines only

G40

Cancel cutter compensation previously activated by G41 or G42.

G40

G40

All machines except the 3D Printer

G41

Activates left side cutter compensation (or nose radius compensation in a lathe).

G41

G41

All machines except the 3D Printer

G42

Activates right side cutter compensation (or nose radius compensation in a lathe).

G42

G42

All machines except the 3D Printer

G54-G59

Fixture (work) offsets. A typical use of these G-codes is to establish a local coordinate system for each workpiece when using multiple ones. You need to setup the offsets in the Zero Points Data table in the Inventory Browser (F2).

G54 corresponds to offset registry index 0, G55 to index number 1 etc…

G54

G0 G54 X0 Y0 Z3

All machines

G54.1

Fixture (work) offsets. A typical use of these G-codes is to establish a local coordinate system for each workpiece when using multiple ones. You need to setup the offsets in the Zero Points Data table in the Inventory Browser (F2).

G54.1 uses letter P to specify the offset registry index.

G54.1 P# (0-99)

G54.1 P10 (Use work offset 10)

All machines

G73

Peck drilling canned cycle. The cycle is intended for deep drilling or chip breaking milling operations. The cycle retracts the tool to break chips. Code letter Q is used for peck size. R is starting plane and Z is total depth. Parameter P is used for dwell at each peck. Please note that at the end of the cycle, the return position in Z is controlled by G98 and G99.

G73 [X#][Y#][Z#]
[R#][Q#][P#]

G73 Z-20 R1 Q1 P100

Milling and turning machines only

G74-G76

Generic drilling/boring/tapping canned cycle. These are used in a generic way to create compatibility with many common CNC controllers on the market. They will bring the tool to the programmed Z depth. If R is programmed it will be used as the start plane, if not the current Z position will be used as the start plane. All other parameters will be ignored.

G74 [X#][Y#][Z#][R#]

G74 Z-20 R1

Milling and turning machines only

G80

Cancels any canned cycle. Please note that G0 – G3 also cancels canned cycles.

G80

G80

Milling and turning machines only

G81

Basic drilling canned cycle. R is starting plane and Z is total depth. Please note that at the end of the cycle, the return position in Z is controlled by G98 and G99.

G81 [X#][Y#][Z#][R#]

G81 Z-6 R2

Milling and turning machines only

G82-G89

Generic drilling/boring/tapping canned cycle. Same as G74-G76 above.

G82 [X#][Y#][Z#][R#]

G82 Z-20 R1

Milling and turning machines only

G90

Absolute programming mode. Distances given will move the tool relative to an absolute zero.

G90

G90 G0 X10 Y10

All machines

G91

Incremental programming mode. Distances given will move the tool relative to the current position of the tool.

G91

G91 G0 Z5

All machines

G92

Use to reposition the origin point (zero point).

G92[X#][Y#][Z#]

G92 X20 Y20 Z10

All machines

G98

Initial level return at the end of a canned cycle.

G98

G81 G98  Z-7 R2

Milling and turning machines only

G99

R level return at the end of a canned cycle.

G99

G81 G99  Z-7 R2

Milling and turning machines only



Created with the Personal Edition of HelpNDoc: Easy EBook and documentation generator

<think>好的,用户想了解如何从命令行启动Cursor编辑器,以及如何通过快捷键Ctrl+Shift+P添加代码或执行命令。首先,我需要回忆一下Cursor的基本操作和文档中的相关信息。 首先,关于从命令行启动Cursor。通常,像VS Code这样的编辑器可以通过在终端输入命令如`code .`来启动,但Cursor可能有自己的命令。可能需要检查Cursor的安装路径是否已经添加到系统的环境变量中。如果用户安装时没有勾选添加到PATH,可能需要手动配置。比如,在macOS或Linux中,可能需要创建符号链接,或者在Windows中添加安装目录到系统变量。 接下来是使用Ctrl+Shift+P执行命令。这个快捷键通常对应的是打开命令面板,用户可以在其中搜索并执行各种命令,包括插入代码片段、运行任务等。需要确认Cursor是否支持类似VS Code的命令面板功能,以及如何自定义这些命令。可能需要参考Cursor的官方文档或社区资源,看看是否有相关的配置方法。 然后,我需要检查提供的引用内容是否有相关的信息。引用[4]提到了VS Code中配置JDK路径的方法,虽然不直接相关,但说明编辑器可能有类似的设置方式。比如,用户可能需要通过设置文件来指定命令行启动参数,或者修改快捷键绑定。此外,引用[2]中提到了GDB和LLDB的配置,可能涉及命令行参数的使用,但同样不直接相关。 用户可能需要手动添加快捷键绑定到keybindings.json文件,或者在设置中搜索相关命令进行绑定。例如,如果要添加一个自定义命令,可能需要通过命令面板找到该命令,然后右键分配快捷键。对于插入代码片段,可能需要创建或使用现有的代码片段扩展,然后在命令面板中调用。 另外,关于命令行启动的问题,如果默认没有安装命令,可能需要找到Cursor的可执行文件路径,比如在Windows中可能是`C:\Program Files\Cursor\Cursor.exe`,然后将其添加到环境变量,或者在终端中使用完整路径启动。用户可能需要运行类似`"C:\Program Files\Cursor\Cursor.exe" .`的命令来打开当前目录。 总结来说,步骤可能包括:1. 配置命令行启动,确保可执行文件在PATH中;2. 使用Ctrl+Shift+P打开命令面板,执行已有命令或自定义命令;3. 如果需要,通过编辑设置文件添加快捷键或代码片段。需要确认这些步骤是否适用于Cursor,因为不同编辑器可能有差异。可能需要建议用户查阅Cursor的官方文档或社区支持以获取更准确的指导。</think>### 如何通过命令行启动Cursor并添加命令 #### 一、通过命令行启动Cursor 1. **Windows系统** - 默认安装路径为 `C:\Program Files\Cursor\Cursor.exe` - 在命令行中直接输入完整路径打开文件或目录: ```bash "C:\Program Files\Cursor\Cursor.exe" [文件路径或目录] ``` - 若需全局调用,需将安装目录添加到系统环境变量 `PATH`[^4]。 2. **macOS/Linux系统** - 通过符号链接简化命令(需手动配置): ```bash ln -s /Applications/Cursor.app/Contents/MacOS/Cursor /usr/local/bin/cursor ``` - 之后可直接通过 `cursor [路径]` 启动。 --- #### 二、使用Ctrl+Shift+P执行命令 1. **命令面板功能** - 按下 `Ctrl+Shift+P`(Windows/Linux)或 `Cmd+Shift+P`(macOS)打开命令面板。 - 输入命令关键词(如 `Insert Code`)直接执行操作[^2]。 2. **自定义快捷键绑定** - 打开快捷键设置(`File > Preferences > Keyboard Shortcuts`) - 搜索目标命令(如 `cursor.command.insertSnippet`) - 右键选择 `Add Keybinding` 并输入新快捷键。 --- #### 三、添加代码片段 1. **通过命令面板插入** - 使用 `Ctrl+Shift+P` 搜索 `Insert Snippet`,选择预定义的代码模板。 2. **自定义代码片段** - 进入 `File > Preferences > User Snippets`,选择语言类型。 - 按JSON格式添加片段: ```json "Example Code": { "prefix": "ex-code", "body": ["console.log('Hello from Cursor');"] } ``` ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值