GCAdapter
Introduction
Overview
The GCAdapter is a highly customizable post that works inside of Mach 4 to modify incorrect GCode to correct GCode. This manual will describe how to use the GCAdapter.
Word Parlance
block - whole single line of GCode EX: "G01 X12 Y32 Z1"
word - the whole, correct GCode instruction EX: "G01", "M06", "X12"
code - the letter part of a word EX: "G","X","M"
value - the number part of a word EX: "23","01"
Mach Commands
These are commands Mach can call from CMDS on the Service screen

Adapt GCode
Opens a file dialog allowing the user to select a GCode file to run through GCAdapter. Loads GCode into Mach when done.
Load from GCode screen automatically calls this command
Adapt Folder
Opens a dialogue to select a folder and then converts all GCode files in that folder. If the selected folder has other folders in it, will step into the folders to convert files in them.
Adapt Folder Test
Same as Adapt Folder but will wait a few seconds to allow the user to view the tool path.
Adapt GCode Settings
Opens a settings menu which allows the user to change the settings of the GCAdapter
-
Addition to Adapted Filenames:
- Adds whatever is here to the end of file that have been converted by GCAdapter
-
Default File Extensions:
- These extensions are what is allowed for GCAdapter to convert
- Only files with these extensions will show when looking for a file to load
- If All Files(*) is present, all files are allowed to be converted
- If adding a new extension make sure to follow format of other extensions or add from Post
-
Default Output Directory:
- Click Browse to look through folders. The selected folder is where converted files will be put
-
Default Post Processor:
- Opens a drop down menu to select the Post file for the Adapter to use
- Pulls posts from the PostFiles folder in the Mach directory
-
Max Length of File:
- The number here is the max number of lines a file is allowed to have
- Make sure there are no commas in the number
- Be careful allowing files much larger than 260,000
-
Number of digits after decimal point:
- Changes the number of decimal places in certain GCode words
- The number after the decimal point is how many digits will be in the decimals place of certain GCode words
- When changing make sure to leave decimal point and only change the number
-
Show modifications:
- If YES, when converting, will write modifications made by GCAdapter to the top of the converted file
- If NO, won't write modifications to the top of converted file
Block Functions
These functions either modify or compare a block of GCode.
TableToString()
- Returns a formatted string that can be printed to see data of block
Comparator Functions
has( passed_word, close_to, thresh )
- Looks for passed_word in block, returning true if found or false if not found
- passed_word can be either full word, "X32", or just a code "G"
- close_to is an optional parameter and if passed looks within range of thresh
- If thresh isn't passed set to default value 10E-6
- Examples:
- block:has("G53")
- block:has("G")
- block:has("M06" , "true" , .0006)
without( passed_word )
- Looks for passed_word in block, returning false if found or true if not found
- passed_word can be either full word, "Y21", or just a code "F"'
- Examples:
- block:without("T2")
- block:without("Z")
lessThan( passed_word )
- Looks for a matching word with a values less than passed_word in block
- Return true if a matching word is found, otherwise returns false
- passed_word must be a full word
- Examples:
- block:lessThan("T100")
- block:lessThan("M7")
greaterThan( passed_word )
- Looks for a matching word with a value greater than passed_word in block
- Return true if a matching word is found, otherwise returns false
- passed_word must be a full word
- Examples:
- block:greaterThan("G01")
- block:greaterThan("X10")
withinRange( code, low_val, high_val )
- Looks for a word that starts with code and is between low_val and high_val
- Returns true if a matching word is found otherwise returns false
- code is a code, low_val and high_val are values
- Examples:
- block:withinRange("T",1,99)
- block:withinRange("X",-23,23)
getBlockBefore()
- returns the block on the line above the current block
- Example: block:getBlockBefore()
getBlockAfter()
- returns the block on the line below the current block
- Example: block:getBlockAfter()
getBlockAt( line_number )
- returns the block at line_number
- Example: block:getBlockAt(23)
Modifier Functions
ModWord( self, old_word, new_word )
- Replaces old_word with new_word in current block
- self refers to block calling ModWord. Passed implicitly when called
- old_word and new_word can be either a word or a code (They must be the same)
- If they are a code be careful because depending on where you call Modword, will replace all instances of that code
- Examples:
-
block:ModWord("M02","M30")
- block:ModWord("G43.4","G43")
- block:ModWord("R","P")
-
DeleteWord( self, target, codes )
- Deletes target along with codes (if provided) from current block
- self refers to block calling DeleteWord. Passed implicitly when called
- target is a word and codes is a list of parameters belonging to target that should be deleted with it
- Examples:
- block:DeleteWord("G53.1")
- block:DeleteWord("G5.1",{"Q","R"})
AddWord( self, new_word )
- Adds new_word onto the end of the current block
- self refers to block calling AddWord. Passed implicitly when called
- new_word needs to be a word
- Examples:
- block:AddWord("G83")
- block:AddWord("M06")
CommentWord( self, target )
- Comments out target in the current block
- self refers to block calling CommentWord. Passed implicitly when called
- target is a word
- Examples:
- block:CommentWord("M29")
- block:CommentWord("G53")
InsertBlockBefore( new_block )
- Inserts new_block on the line above the current block
- new_block is a block of GCode
- Examples:
- block:InsertBlockBefore("G00 X2 Y6.77 Z0")
- block:InsertBlockBefore("M6 T05")
InsertBlockAfter( new_block )
- Inserts new_block on the line after the current block
- new_block is a block of GCode
- Examples:
- block:InsertBlockAfter("G00 X2 Y6.77 Z0")
- block:InsertBlockAfter("M6 T05")
InsertBlockAtLine( new_block, new_index)
- Inserts new_block at new_index(Pushes previous block at index down)
- new_block is a block of GCode and new_index is the line number of where to insert
- Examples:
- block:InsertBlockAtLine("G83 P12 Q32", 32)
- block:InsertBlockAtLine("M6 T25",46)
DeleteBlock( self, str )
- Deletes entire block that has an exact match with str and match isn't a comment
- self refers to block calling DeleteBlock. Passed implicitly when called
- str is a string that will be looked for in the block
- Examples:
- block:DeleteBlock("G83 R54")
- block:DeleteBlock("L_Parkz")
DeleteCurrentBlock()
- Deletes the current block
- Example:
- block:DeleteCurrentBlock()
DeleteBlockAt( del_index )
- Deletes block at del_index
- del_index is the line number of the block to be deleted
- Example:
- block:DeleteBlockAt(3)
CommentBlock( self, str )
- Comments entire block that has an exact match with str and match isn't a comment
- self refers to block calling CommentBlock. Passed implicitly when called
- str is a string that will be looked for in the block
- Examples:
- block:CommentBlock("G02 X12")
- block:CommentBlock("M04")
CommentCurrentBlock()
- Comments out the current block
- Example:
- block:CommentCurrentBlock()
JoinBlock( loc )
- Takes block from either before, after or at an index, adds words in block to end of current block then deletes block at loc
- loc is either a string ("BEFORE" or "AFTER"), or a number corresponding to the line number of the block to pull from
- Example:
- block:JoinBlock("BEFORE")
- block:JoinBlock("AFTER")
- block:JoinBlock(54)
Post
The post consists of 3 different post files but the user will only need to interact with the final user specific Post
Modifier Tables
These tables will automatically call the modifier functions and are a helpful way to make simple modifications to GCode files. When adding to the tables, copy and paste the examples and replace what you want to easily keep the correct format.
Examples:
WordsToReplace




