Giter Club home page Giter Club logo

appliedengdesign / vscode-gcode-syntax Goto Github PK

View Code? Open in Web Editor NEW
85.0 5.0 25.0 1.82 MB

G Code Language Extension for Visual Studio Code. Turn VSCode into a fully capable G-Code editor, including language support & more.

License: MIT License

TypeScript 88.96% nesC 1.83% JavaScript 4.07% HTML 3.33% SCSS 1.81%
visual-studio-code gcode gcode-syntax nc cam cnc-programming cnc vscode-gcode-syntax tree language-extension snippets machine visual-studio-code-extension typescript vscode g-code

vscode-gcode-syntax's Introduction

Version Installs Rating

GitHub Issues Github Stars Github Last Commit MIT License

Follow @appliedengdesign




VSCode G-Code Syntax is the premier extension for editing G-Code inside of VSCode. Going past the simple syntax highlighting, this extension aims to turn your editor into a full blown g-code management suite. Building on the features of VSCode like Intellisense, snippets, debugging and more, we are able to offer nearly all of the features you would see in very expensive proprietary editors.

Additionally, by editing your G-Code inside of VSCode, you can take advantage of source control using Git to manage your g-code file versions.

Screenshot

VSCode or Visual Studio Code is a FREE (as in beer), open source application for editing code of all kinds of programming languages. To make it even better, there is a great marketplace where you can download and add extensions to the application to support other languages, add features and more.

Support VSCode-G-Code-Syntax

G-Code Syntax is generously offered to everyone free of charge, if you find it useful, please consider supporting the project by becoming a sponsor, sharing it, and letting your friends know!

Also, please write a review, star me on GitHub, and follow me on Twitter or Instagram.

You can also subscribe to our videos over on YouTube.

Features

This extension adds language syntax for CNC G-Code, code snippets, and colorization.

Tree View

  • Tree View shows an overview of the operations in the G-Code Program

Tree Screenshot

Stats View

  • Stats View shows a number of stats like tool changes, runtime, etc.

Stats Screenshot

Hovers

  • Hovering over G/M codes will show a short description of the code
  • Descriptions for the codes are taken from the sister project: gcode-reference
  • Hovers are dependent on the machine type selected

Hovers Screenshot

Status Bars

  • G-Code adds three informative sections to the VSCode status bar area
    • Tree Status (Dirty or Up to Date) depending on Refresh needed
    • Current units as set by settings (Auto, Inch or Metric)
    • Machine Type as set by settings
    • Ok there's a little heart there too.

Status Bar Screenshot

Context Menu

  • G-Code adds several commands to the context menu when viewing g-code
    • Change selected code into a comment
    • Refresh Stats
    • Refresh Tree
    • Remove Comment from selected code

Context Menu Screenshot

Current Supported File Extensions

| .001   | .apt | .aptcl | .cls   | .cnc | .din | .dnc | .ecs |
| .eia   | .fan | .fgc   | .fnc   | .g   | .g00 | .gc  | .gcd |
| .gcode | .gp  | .hnc   | .knc   | .lib | .m   | .min | .mpf |
| .mpr   | .msb | .nc    | .ncc   | .ncd | .ncf | .ncg | .nci |
| .ncp   | .ngc | .out   | .pim   | .pit | .plt | .ply | .prg |
| .pu1   | .rol | .S     | .sbp   | .spf | .ssb | .sub | .tap |
| .xpi   |      |        |        |      |      |      |      |

If you would like another file extension supported by this extension, please open an issue.

Installation

Install from Extensions Marketplace or manually install the vsix file.

Usage

Install & activate extension. Extension activates when you open a file marked for the gcode language.

Tree view is enabled by default and can be access from the G icon on the activity bar.

G-Code Syntax Settings

G-Code Syntax is customizable and provides many configuration settings to allow the personalization of almost all features.

Name Description
gcode.general.hovers.enabled Enable or Disable the hovers to show G-Code information
gcode.general.machineType Choose the machine type for extension (Mill is default)
gcode.general.statusBars.enabled Enable or Disable the G-Code status bars
gcode.general.statusbars.alignment Choose the alignment of the status bars (Left is default)
gcode.general.units Choose the units for the file. Options are Auto, Inch or Metric
gcode.general.outputLevel Configure Output level for debugging purposes
gcode.lineNumberer.addSpaceAfter Add space after line number
gcode.lineNumberer.defaultIncrement Default Line Numberer Increment
gcode.lineNumberer.defaultStart Default Line Numberer Start
gcode.lineNumberer.enableQuickPick Enable or Disable Input for the Line Numberer (Will use above defaults)
gcode.lineNumberer.frequency Frequency of line number additions (Every Line or at Tool Changes)
gcode.lineNumberer.ignoreBlank Ignore Blank lines when numbering
gcode.lineNumberer.ignoreComments Ignore Comments when numbering
gcode.lineNumberer.ignoreExtra Additional characters to ignore (Beginning of Line, Default is %)
gcode.lineNumberer.ignoreProgramNumbers Ignore Program numbers, e.g. O12345
gcode.lineNumberer.matchLineNumber When numbering, match the N number to file's line number. (Default is off)
gcode.views.maxAutoRefresh Value for limiting the autoRefresh maximum lines
gcode.views.navTree.autoRefresh Tree auto-refreshes as changes are made to the g-code. ( Disabled by default )
gcode.views.stats.autoRefresh Auto-refresh the stats view when changes are made to the g-code. (Disabled by default)
gcode.views.webviews.enabled Enable or disable the webviews

Settings Screenshot

Known Issues

Please visit our GitHub Issues page for any open issues.

TODO

  • Add more snippets
  • Add additional tree items.
  • Machining Calculator
  • More Statistics
  • G-Code Debugging
  • Backplotter
  • Semantic Highlighting
  • Programmatic Language Server

Visit our projects page for future roadmaps.

Changelog

Latest Version: v0.7.7

Please refer to our CHANGELOG doc.

Contributing

If you work like to help contribute to the code or this project, please fork away and submit pull requests!

For more information on contributing, please refer to the CONTRIBUTING doc.

Contributors

About Applied Eng & Design

We are a full service engineering and design firm, specializing in CAD/CAM, CNC milling, rapid prototyping, training and more. We also like to dabble in Arudino / RaspberryPi projects, electronics, drones and robotics projects! Subscribe to our YouTube channel for videos on our projects, screencast tutorials, and more!

Follow us on Twitter & Instagram, and like our Facebook Page!

License

This extension is licensed under the MIT License.

vscode-gcode-syntax's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

vscode-gcode-syntax's Issues

Exception in the debug console: `rejected promise not handled within 1 second: TypeError: Cannot read property 'substr' of undefined

Describe the bug
In Visual Studio Code I'm currently developing an extension for processing GCode files.
When the extension is launched a new instance of VSCode opens where two gcode files are opened by default.
The moment I click on the gcode file that is not active the exception shown below is shown in the host VSCode instance debug console. See attached screenshot.

Expected behavior
The extension should be able to highlight the GCode without throwing the errors in the debug console.

Environment / Version:

  • OS Version: Windows 10
  • VSCode Version: 1.62
  • Extension Version: 0.6.2

Additional context
Stacktrace from the debug console:
rejected promise not handled within 1 second: TypeError: Cannot read property 'substr' of undefined stack trace: TypeError: Cannot read property 'substr' of undefined at x.parseLine (c:\Users\Allan\.vscode\extensions\appliedengdesign.vscode-gcode-syntax-0.6.2\dist\extension.js:1:17709) at x.getBlocks (c:\Users\Allan\.vscode\extensions\appliedengdesign.vscode-gcode-syntax-0.6.2\dist\extension.js:1:12527) at new x (c:\Users\Allan\.vscode\extensions\appliedengdesign.vscode-gcode-syntax-0.6.2\dist\extension.js:1:12336) at E.parseTree (c:\Users\Allan\.vscode\extensions\appliedengdesign.vscode-gcode-syntax-0.6.2\dist\extension.js:1:22213) at E.refresh (c:\Users\Allan\.vscode\extensions\appliedengdesign.vscode-gcode-syntax-0.6.2\dist\extension.js:1:22010) at E.onDocumentChanged (c:\Users\Allan\.vscode\extensions\appliedengdesign.vscode-gcode-syntax-0.6.2\dist\extension.js:1:21198) at c:\Users\Allan\.vscode\extensions\appliedengdesign.vscode-gcode-syntax-0.6.2\dist\extension.js:1:9526 at l.fire (c:\Users\Allan\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:66:1712) at I.$acceptModelChanged (c:\Users\Allan\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:94:152916) at n._doInvokeHandler (c:\Users\Allan\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:98:13802) at n._invokeHandler (c:\Users\Allan\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:98:13486) at n._receiveRequest (c:\Users\Allan\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:98:12148) at n._receiveOneMessage (c:\Users\Allan\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:98:10826) at c:\Users\Allan\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:98:8922 at l.fire (c:\Users\Allan\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:66:1712) at s.fire (c:\Users\Allan\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:74:15990) at c:\Users\Allan\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:113:30625 at l.fire (c:\Users\Allan\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:66:1712) at s.fire (c:\Users\Allan\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:74:15990) at f._receiveMessage (c:\Users\Allan\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:74:21260) at c:\Users\Allan\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:74:18138 at l.fire (c:\Users\Allan\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:66:1712) at w.acceptChunk (c:\Users\Allan\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:74:13351) at c:\Users\Allan\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:74:12699 at Socket.m (c:\Users\Allan\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:113:13575) at Socket.emit (events.js:315:20) at addChunk (internal/streams/readable.js:309:12) at readableAddChunk (internal/streams/readable.js:284:9) at Socket.push (internal/streams/readable.js:223:10) at Pipe.onStreamRead (internal/stream_base_commons.js:188:23)

Screenshot
Exception

Wrong "Tool Changes" count

"M6" in comments is counted as tool change. This is problematic in some code cause "M6" also means metric 6 mm thread - for example in the description of a tool.

Leads to "Tool Changes" count being wrong.

ToolChange Improvements on Tree

Hi everyone!!

I am new at all here and I dont know so much of programming... sorry in advance!
I installed the extension to see lathe gcode:

  • In lathes, we call a tool just saying ex. T1212. Without the M06 used on Mills. So the ToolChange does not appear in the Tree.
  • In addition, it would be great if the comment (many people as me use to put after the T____ , to describe the tool) also appeared in the Tree. ex. T1212 (Ext. Rough)
  • Also the possibility to hide from the tree the G0/1's.

Congratulations for the great extension and job done.
Best regards

Typo in CONTRIBUTING

Describe the bug
In CONTRIBUTING.md is typo in line

Submit a pull request tot he development branch of the vscode-gcode-syntax respository.

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://github.com/appliedengdesign/vscode-gcode-syntax/blob/master/CONTRIBUTING.md.
  2. Scroll down to line

Submit a pull request tot he development branch of the vscode-gcode-syntax respository.

  1. See error

Expected behavior
This line should be:

Submit a pull request to the development branch of the vscode-gcode-syntax respository.

or maybe better:

Submit a pull request to the development branch of the vscode-gcode-syntax respository.

.ngc file support for LinuxCnc

Natively, the LinuxCnc files have .ngc extension
Can you please add suport for this extension too?
I've renamed a file to have .nc extension and it works fine, just that the .ngc files are not recognized by default.
Thanks for the great work!

Incorrect Tree view names.

Describe the bug
Tree view has incorrect names for settings.

To Reproduce
Open VSCode.
Set the machine type to 3d printer.
Open a 3d printer gcode file.
Go to the gcode syntax tab on the left side.
Open Tree.
See G1 commands referred to as cut, and G0 commands as Rapid.

Expected behavior
I expected the commands to be labeled Move, or similar

Environment / Version:

  • OS Version: Windows 10
  • VSCode Version: 1.79.2
  • Extension Version: 0.7.7

Add support for Siemens Sinumerik codes

First thank you veeeery much for this excellent extension !

As I'm working on a Siemens Sinumerik (840d) driven machine, I'd love to see this NC's specific codes better supported for ".mpf" and ".spf" files, mainly for syntax highlighting.

For example blocks like:

  • WORKPIECE(,,,,,,,,): for stock definition
  • MSG(""): for operator messages
  • T="TOOL_BY_NAME": for tool names
  • TRANS/ATRANS, ROT/AROT...: for transformations
  • CYCLExxx(): for positionning and machining cycles
  • MCALL: for modal sub-program calling
  • ...

WIth a little guidance, I'd gladly help for this.

Thanks again. Keep the good stuff coming

Highlighting inconsistency with macro variables & control functions

First off, thanks for all the work that's been put into this! Really happy with it overall.

I ran into a couple highlighting issues while working on a macro. Please see the screenshot below. Things that seem "off" in the screenshot:

  • DO and GOTO are being highlighted inconsistently (this seems to be the case on their own line as well)
  • The last closing ] on the IF line does not match the opening bracket in the same way that it does on the WHILE line

image

.anc Support

Hi,

Is there any way can get a .anc support so it highlights the code?
thanks
Symon

Important color coding

Add an option for color coding where lines on-after G0 turns red, G1 turns green, G2,3 turns blue. Very important and useful feature for inspecting program. Thank you

cimco

color highlighting

Describe the bug
Here is a screenshot of a few more of those highlighting anomalies reported in Issue #40.

Screen Shot 2022-08-26 at 9 00 50 AM

To Reproduce
Download the surfacing macro from duet3d forum here:
https://forum.duet3d.com/topic/26762/surfacing-macro?loggedin=true

; Constants
var Debug = false;
var ProbeThickness = 15.5;
var CoordSystem	= 20;
var StepOver = 10;
var DepthOfCut = 0.2;
var FeedRate = 8000;
var ZClearanceHeight = 25;
 
; Variables
var StartX = 0;			; The X starting position
var StartY = 0;			; The Y starting position
var EndX = 0;			; The X ending position
var EndY = 0;			; The Y ending position
var YDir = 0;			; The direction to go in Y
var YDist = 0;			; The distance to go in Y
var YPos = 0;			; The position in Y to move to
var YDistLeft = 0;		; How much we have left to move in Y
var ZDepth = 0;			; How far down we should be in Z
var XSorE = "End"		; Whether X should move towards the start or the end position
 
; If the printer hasn't been homed, home it
if !move.axes[0].homed || !move.axes[1].homed || !move.axes[2].homed
	G28
 
; Adjust probe for low speed probing
M558 K0 P8 C"!io3.in" H20 F120 T300					; Z probe number - Z probe switch type - probe recovery 1s probe speed and travel speed
G31 K0 P500 X0 Y0 Z0								; Set trigger value - set offset and trigger height - Z probe number
 
M291 P"Insert your surfacing bit into your spindle and position it above the probe plate" R"Probing" S3 X1 Y1 Z1
 
; Set bit above center of probe
G91																			; relative positioning
 
; Probe Z component
G38.2 Z{move.axes[2].userPosition - (var.ProbeThickness + 2.25)}			; seek until the probe circuit is closed Z-axis 25 mm
G0 Z{var.ZClearanceHeight}													; rapid move Z axis 5 mm
 
G10 P1 L{var.CoordSystem} Z{var.ProbeThickness + var.ZClearanceHeight}		; store relative probe offset for coordinates system 1
 
G90																			; Absolute positioning
 
M291 P"Move to the starting X Y position for surfacing" R"Start Position" S3 X1 Y1 Z0
set var.StartX = move.axes[0].userPosition;
set var.StartY = move.axes[1].userPosition;
 
if var.Debug
	M118 P0 S{"StartX = " ^ var.StartX} L2
	M118 P0 S{"StartY = " ^ var.StartY} L2
 
M291 P"Move to the ending X Y position for surfacing" R"End Position" S3 X1 Y1 Z0
set var.EndX = move.axes[0].userPosition;
set var.EndY = move.axes[1].userPosition;
 
if var.Debug
	M118 P0 S{"EndX = " ^ var.EndX} L2
	M118 P0 S{"EndY = " ^ var.EndY} L2
 
M291 P"Are you ready to begin surfacing?" S3 X0 Y0 Z0
 
; Figure out which direction in Y we are going
if var.EndY < var.StartY
	set var.YDir = -1;
elif var.EndY > var.StartY
	set var.YDir = 1;
else
	set var.YDir = 0;
 
if var.Debug
	M118 P0 S{"YDir = " ^ var.YDir} L2
 
 
set var.YDist = {abs(var.StartY - var.EndY)};
if var.Debug
	M118 P0 S{"YDist = " ^ var.YDist} L2
 
; Begin surfacing loop
while true
	if var.Debug
		M118 P0 S"Begin Layer Loop" L2;
 
	set var.ZDepth = {var.ZDepth - var.DepthOfCut};
	set var.YDistLeft = {var.YDist};
 
	; go to the start X and Y position then down to Z Depth
	if var.Debug
		M118 P0 S{"Move to start X" ^ var.StartX ^ ",Y" ^ var.StartY} L2
	G0 X{var.StartX} Y{var.StartY}
	if var.Debug
		M118 P0 S{"Move to start Z" ^ var.ZDepth} L2
	G1 Z{var.ZDepth}
 
	; we should be at the Start X position so move to the End X position
	if var.Debug
		M118 P0 S{"Move to X" ^ var.EndX} L2
	G1 X{var.EndX} F{var.FeedRate}
	set var.XSorE = "Start"
 
	while var.YDistLeft > var.StepOver
		if var.Debug
			M118 P0 S"Begin Y Loop" L2
 
		; move in Y by StepOver
		set var.YPos = {move.axes[1].userPosition + (var.StepOver * var.YDir)}
		if var.Debug
			M118 P0 S{"Move to Y" ^ var.YPos} L2
		G1 Y{var.YPos} F{var.FeedRate}
		set var.YDistLeft = {var.YDistLeft - var.StepOver}
 
		if var.XSorE == "Start"
			; move X to the start position
			if var.Debug
				M118 P0 S{"Move to X" ^ var.StartX} L2
			G1 X{var.StartX} F{var.FeedRate}
			set var.XSorE = "End"
		else
			; move X to the end position
			if var.Debug
				M118 P0 S{"Move to X" ^ var.EndX} L2
			G1 X{var.EndX} F{var.FeedRate}
			set var.XSorE = "Start"
 
	; move in Y the rest of the distance left
	set var.YPos = {move.axes[1].userPosition + (var.YDistLeft * var.YDir)}
	if var.Debug
		M118 P0 S{"Move to Y" ^ var.YPos} L2
	G1 Y{var.YPos} F{var.FeedRate}
 
	; one last move in X
	if var.XSorE == "Start"
		; move X to the start position
		if var.Debug
			M118 P0 S{"Move to X" ^ var.StartX} L2
		G1 X{var.StartX} F{var.FeedRate}
		set var.XSorE = "End"
	else
		; move X to the end position
		if var.Debug
			M118 P0 S{"Move to X" ^ var.EndX} L2
		G1 X{var.EndX} F{var.FeedRate}
		set var.XSorE = "Start"
 
	G0 Z{var.ZClearanceHeight}					; get out of the way
	M400 										; wait for the movement buffer to catch up
	M291 P"Surface another layer?" S3 X0 Y0 Z0	; then prompt the user if they want to do another layer

Environment / Version:
macOS 12.5.1
VSCode 1.69.2
Extension 0.7.4

Question: How to add an extension?

For a French CNC Machines builder, they need a .PRG extension to recognize the G-Code file. What would I need to do to add this extension to those already recognized?

I saw they are listed in package.json, but I guess adding an extension there might not be enough?

Thanks for your help,
Bernard

Add or Remove Line Numbers Error following V0.7.5 Update

Commands
G-Code: G-Code: Remove Line Numbers
G-Code: G-Code Add Line Numbers
These commands result in errors and will not add or remove line numbers.

Steps to reproduce the behavior:
With a g-code file open, (whether .txt, .nc)

  1. Go to 'Command Palette.'
  2. Click on 'G-Code: G-Code Add Line Numbers'
  3. Error is made known by a pop-up presenting you with a phrase letting the user know the command did not work.

When the command is selected it should either remove or add line numbers.

  • OS Version: Windows_NT x64 10.0.22000
  • VSCode Version:1.71.2
  • Extension Version: V0.7.5

On older Extension Version: V0.7.4 both commands work as expected.

Some features are not working

Describe the bug

Hi, first time user. Maybe i don't know how to use the extension properly.

After opening a gcode file in Visual Studio Code, although the syntax are colour coded, there is nothing shown under TREE. Do I need to do something like compiling or running? Since it is not a program for the PC, it may not work.

As for Hovers, sometimes it works but sometimes it doesn't. For example, moving the cursor over G90 shows "G90: Absolute Positioning". However, moving the cursor over M73, M862, M299, M292, M140, etc. shows nothing. Moving over G1 just shows "G1:"

Environment / Version:

  • OS Version: Windows 10
  • VSCode Version: 1.60.0
  • Extension Version: 0.6.2

Additional context
Add any other context about the problem here.

Add Support for Okuma G116 Tool Change

I'm trying to add line numbers to tool-change commands in an Okuma file, but GCode-Syntax doesn't recognize the G116 code that Okuma uses for tool changes, so nothing happens. Thanks!

Support for Open VSX

It would be great if you could publish your plugin to Open VSX as well, as the VSCoduim-Project moved to this repository as it's default source of extensions and there for you need workarounds to use your extension.

According to the documentation, it seems to be pretty easy to do and would improve the usability and maybe the reach of the extension.

RunTime Stats Error

Bug in the Run time calculation. Circular interpolation causes NaN and fails to load the Stats Tree.

Custom descriptions

It would be really nice if this extension supported the ability to add custom commands like this extension does.

This would be very useful for me as I'm working with a Bambu Labs X1 which has a lot of custom gcode commands and I'd like to be able to create my own definition library for them.

auto update not working

Describe the bug
I am not sure if you are aware but the latest version showing in the VSCode is 0.7.0 but I see there have been a few updates since then and the current version is 0.7.4.

Highlighting not working properly

Describe the bug
Highlighting is applied on letters only in whole words for a LinuxCNC g-code file.

For example:
o sub
Both letters "t" are highlited blue and should not.

To Reproduce
Steps to reproduce the behavior:

  1. Simply open a g-code file and view.

Expected behavior
No highting should normally happen for these words.

Screenshots
Capture

Environment / Version:
Version : 1.68.1
Validation : 30d9c6cd9483b2cc586687151bcbcd635f373630
Date : 2022-06-14T12:48:58.283Z
Electron : 17.4.7
Chromium: 98.0.4758.141
Node.js : 16.13.0
V8 : 9.8.177.13-electron.0
Système d’exploitation : Windows_NT x64 10.0.19044

Additional context
g-code file from this site: https://www.projectsbybrian.tech/s/PrintNC.zip
open file from "macros" folder.

Incorrect highlighting for DO / END

This code shows incorrect highlighting for DO/ENDDO
()
WHILE[1.EQ1.]DO1(MAIN*LOOP)
(
)
#3004=0
#28=0(LOOPCHECKING)
WHILE[ABS[#[#5+7.]]LT0.1]DO2(WAIT
FOR*OPCODE)
G04X#[#31+10.]
#28=#28+1
IF[#28 LT 5000] GOTO300
#33=78
GOTO9000
N300
END2

image

You will see that the While statement's "DO2" highlights the "O2" and the END2 Statement has the "D2" portion highlighted.

Enhancement: Support for square brackets

Please see in this screenshot how square brackets are used for complex variable assingment and for logic evaluation:

image

It would be useful to have the brackets/content highlighed and also when used in complex variable assignments clearly depicted as variables

.gcode Generated by Prusa Slicer Not Recognized

Describe the bug
G-Code files produced by PrusaSlicer are not recognized or highlighted by extension. They are .gcode file extensions.

To Reproduce
Steps to reproduce the behavior:

  1. Generate G-Code file using PrusaSlicer
  2. Save file to Desktop
  3. Open file in VS Code
  4. Confirm file is not recognized as G-Code

Expected behavior
Expect the file type to be recognized and highlighted properly. VS code seems to recognize that it is a gcode language but extension does not (see screenshot below),

Screenshots
SNAG-0044

Environment / Version:

  • OS Version: Windows 10
  • VSCode Version: 1.55.2
  • Extension Version: v0.5.1

Additional context
I might be missing a step in the process here as the extension is working properly if I make a blank .gcode file and type some commands in.
I have also copied all the text from the PrusaSlicer generated file and pasted into the user-made file and correct highlighting occurs

Let me know if this should be moved, tagged, or deleted.

add *.S file extension

Good morning

Thanks for this extension , it's very useful. Could you add the .S file extension? In my work we use that and it would be very useful

Thank you

Сolorization of the G-code with a dot

If the G-code is with a dot, the colorization of the G-code does not work.
For example G68.2
(used in FANUC Series 30i/300i/300is-MODEL A, FANUC Series 31i/310i/310is-MODEL A, FANUC Series 32i/320i/320is-MODEL A)
image

Markup issue with division symbol

There is an issue with the markup associated with the division symbol caused by block commenting.
Please see the attached photo.
Really love your extension for managing CNC code - nice work!

DivisionSymbolMarkup

My regexes

Hi,
I noticed that coordinates X10.01 lose highlight-colors after the dot, so here are the regexes I have been using:

"coords": {
    "patterns": [
        {
            "match": "(?i)([\\,]?[XUIYVJZWKACR][ \\t]*[\\-\\+]?[0-9]++(?!\\.))",
            "name": "invalid.gcode"
        },
        {
            "match": "(?i)[XUI]?[ \\t]*[\\-\\+]?[0-9\\.]+",
            "name": "axis.x.gcode"
        },
        {
            "match": "(?i)[ZWK]?[ \\t]*[\\-\\+]?[0-9\\.]+",
            "name": "axis.z.gcode"
        },
        {
            "match": "(?i)[CH]?[ \\t]*[\\-\\+]?[0-9\\.]+",
            "name": "axis.c.gcode"
        }
    ]
},

invalid.gcode warns about coordinates without a decimal point like "X100". It works together with settings.json in the .vscode folder of the workspace.

"editor.tokenColorCustomizations": {
	"textMateRules": [
		{
			"name":"invalid",
			"scope": "invalid.gcode",
			"settings": {
				"foreground": "#F00",
				"fontStyle": "underline",
			}
		},
		]
	}

I hope these are useful to the project!

syntax highlighting error

hi everyone
The g-code with 'C' can't match more than 4 digits like this:

C8 X13.98488889 Z0.89909369
C8.2 X13.98488611 Z0.89920968
C8.4 X13.98488333 Z0.89930708
C8.6 X13.98488056 Z0.89938586
C8.8 X13.98487778 Z0.89944604
C9 X13.98487500 Z0.89948762
C9.2 X13.98487222 Z0.89951058
C9.4 X13.98486944 Z0.89951494
C9.6 X13.98486667 Z0.89950069
C9.8 X13.98486389 Z0.89946783
C10 X13.98486111 Z0.89941636
C10.2 X13.98485833 Z0.89934629
C10.4 X13.98485556 Z0.89925761
C10.6 X13.98485278 Z0.89915032
C10.8 X13.98485000 Z0.89902445
C11 X13.98484722 Z0.89887992
C11.2 X13.98484444 Z0.89871696
C11.4 X13.98484167 Z0.89853579
C11.6 X13.98483889 Z0.89837779
C11.8 X13.98483611 Z0.89837531
C12 X13.98483333 Z0.89855660
C12.2 X13.98483056 Z0.89873516
C12.4 X13.98482778 Z0.89889525
C12.6 X13.98482500 Z0.89903688
C12.8 X13.98482222 Z0.89915987
C13 X13.98481944 Z0.89926428
C13.2 X13.98481667 Z0.89935007
C13.4 X13.98481389 Z0.89941726
2022-11-04 145543

"Command 'gcode.gcodeTree.refresh" not found"

In the past, the extension has worked fine for me, but up until recently when I had to write another program, the gcode tree would just appear blank. Clicking the refresh button gave me the "Command 'gcode.gcodeTree.refresh" not found" message. Uninstalling/installing it did not seem to do anything, so I'm curious as to what I can do to get the gcode tree to show all my commands.

Also, whenever i open a gcode file, in the output it just gets stuck on "loading tree view".
Version is v0.4.1

image

Support for .g files.

Support for .g files

Additional context
The plug doesnt seem to support .g files. Firmware such as reprapfirmware use .g files for the configs of the duet boards. Would be handy to have it recognise this as gcode.

.mpr support

Files that are .mpr don't work properly, they don't get colored and the tree is wrong
image

Tree view does not show file commands

Describe the bug
Tree view does not display file commands even after manually refreshing.

Runtime status also shows following error:

Cannot read properties of undefined (reading 'slice')

To Reproduce
Open file for viewing in VSCode.

Expected behaviour
Tree view shows file commands

Screenshots

Screenshot 2023-01-18 at 5 12 05 pm

Screenshot 2023-01-18 at 5 13 10 pm

Environment / Version:

  • OS Version: MacOS Ventura 13.1
  • VSCode Version: Version: 1.74.3 (Universal)
  • Extension Version: G-Code Syntax v0.7.7

Additional context
Syntax highlighting is okay, Manually refreshing the stats windows shows estimated runtime.

Some commands are not correctly highlighted in editor which may or may not be related

For example globally setting feed rate...

F100

Or spindle speeds...

S500 M3

Also some Mcodes...

M101
M102
M103

Code Folding in Tree if 3dp and Layer Comments in file

Suggest a Feature you'd like to see

I wish that my 3d printing gcode files would load in treeview happily. I don't think it serves much purpose, so maybe it could just be disabled instead in 3d printing mode.

The files I use are silly sizes (line count) and include a comment that is a base64 encoded image (64kb) so also silly line length.
I wondered while reading the closed issue #23 if it couldn't be more gracefully handled if the file contains Layer markers as comments. If that was the case then the tree could collapse the commands under sections based on layer number.

Additional context
It's worth noting that octoprint (or maybe one of its plugins) has a couple of regular expressions to match the majority of slicers / gcode flavours regarding layer comments.

Sample file header (from Luban i.e. Cura) and first few lines of skirt / layer zero:

;Header Start

;FLAVOR:Marlin
;TIME:6666
;Filament used: 0m
;Layer height: 0.24
;MINX:2.14748e+06
;MINY:2.14748e+06
;MINZ:2.14748e+06
;MAXX:-2.14748e+06
;MAXY:-2.14748e+06
;MAXZ:-2.14748e+06


;header_type: 3dp
;tool_head: singleExtruderToolheadForSM2
;machine: A350
;thumbnail: data:image/png;base64,iVBORw0KGgoAAAANg+KikMEREAEREA*****TRUNCATED_64K*****IgAiIgAiIgAj0QeD/AAcGNfSAwHBtAAAAAElFTkSuQmCC
;file_total_lines: 67331
;estimated_time(s): 7364.81
;nozzle_temperature(°C): 245
;nozzle_1_temperature(°C): -1
;nozzle_0_diameter(mm): 0.4
;nozzle_1_diameter(mm): -1
;build_plate_temperature(°C): 60
;work_speed(mm/minute): 3600
;max_x(mm): 499.5
;max_y(mm): 499.5
;max_z(mm): 999
;min_x(mm): -499.5
;min_y(mm): -499.5
;min_z(mm): 0
;layer_number: 145
;layer_height: 0.24
;matierial_weight: 8.335360984415162
;matierial_length: 2.79471
;nozzle_0_material: PLA-LW
;nozzle_1_material: null

;Header End

; G-code for 3dp engraving
; Generated by Snapmaker Luban 4.4.0
; Sat Oct 01 2022 14:1:12

T0
M82 ;absolute extrusion mode
;Start GCode begin
M104 S165
M140 S60
G28 ;home
G90 ;absolute positioning
G1 X-10 Y-10 F3000
G1 Z0 F1800
M190 S60
M104 S245
M190 S65
M109 S245;Wait for Hotend Temperature
G92 E0
G1 E20 F200
G92 E0
;Start GCode end
G92 E0
G92 E0
;LAYER_COUNT:145
;LAYER:0
M107
G0 F1296 X134.252 Y139.045 Z0.28
;TYPE:SKIRT
G1 F1080 X134.836 Y138.524 E0.01749
G1 X135.276 Y138.205 E0.02964
G1 X136.038 Y137.727 E0.04974

Warning spam

When I'm working on more than 10K lines files (all the time) the extension send an warning saying something may not work.

that's OK, I click in the "continue" button to continue working anyway, but the warning pops up every time I make any changes to the file, every time I type a character it pops up... It's annoying, I think it would be better if it showed the warning just once when I opened the file.

image

add the .P-3 file extension

Good morning

Thanks for this extension , it's very useful. Could you add the .P-3 file extension? In my work we use that and it would be very useful

Thank you

Add support for RepRapFirmware meta G-code keywords

First of all, thank you very much for this extension - it looks great and if possible, I would really like to use the syntax highlighting from this project with Monaco in a web application to provide a nicer G-code editor.

What I've been missing is briefly mentioned in #44: Syntax highlighting for RepRapFirmware G-code keywords and expressions.

With RepRapFirmware it is possible to use variables (var, global, set), conditional code flow (if, elif, else, while, abort, break), to output generic messages (echo), and to use dynamic expression parameters (e.g. G1 X{100 * 0.3}, everything in curly braces is evaluated on execution). The set of keywords is relatively small and well-documented here: https://docs.duet3d.com/en/User_manual/Reference/Gcode_meta_commands

Is there any way this could be added to a future version or can you point me to the right bits that need to be changed?

Add a new type of machine

Is it possible to add a new type of machine with the new m and g code associated with it

coordinate grinding i'll link the g and m code related to the machine it will be in french i can make the translation for you in english if you want
M code.pdf
G code.pdf

File Extensions for Okuma OSP controls

You have .min (main program) extension for OSP control but there are a few other commonly used extensions when programming for the OSP as well:

.ssb (System Sub Program)
.sub (User Sub Program)
.lib (Library Program)

Would it be possible to add these in as well?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.