MechMate CNC Router Forum

Go Back   MechMate CNC Router Forum > Computing, Software & Programming > Utility software
Register Options Profile Last 1 | 3 | 7 Days Search Today's Posts Mark Forums Read

Thread Tools
Old Wed 24 November 2010, 20:37
Just call me: Pablo
Buenos Aires
The simplest 4th Axis Wrapper and FREE

I just posted this at CNCzone, I'm sure it will be enjoyed here too

Here you go, the simplest 4th axis wrapper that does the conversion in just one line of piped code, it uses GNU commands, so any user with ANY operating system can use the wrapper.
Since I'm a windows user I used GNUwin version and made a batch file that does some validation on the input parameters, but the gist of the program is just ONE LINE!!!

How do you use it?

Simple: dump all the files in any folder, put the text file with the Gcode in the same folder and launch the wrapper.cmd file with these parameters:

PHP Code:
wrapper <InputFile> <axis> <diameter> <OutputFile
Do not expect fancy windows, this script runs from a DOS box (cmd)

Here is the code:

PHP Code:
@REM WRAPPER.CMD v1.0 2010-11-23 
@REM Heavylifting (parsingby Daniel Sentinelli
@REM Ideamath and errorchecks by Pablo EUntroib (PEU)
@REM USAGEwrapper <InputFile> <axis> <diameter> <OutputFile>


@REM Check if all required parameters are present
if [%1]==[] goto :MissingParameter
if [%2]==[] goto :MissingParameter
if [%3]==[] goto :MissingParameter
if [%4]==[] goto :MissingOutput

@REM Check for valid source file
if NOT EXIST %goto :MissingInput else 
REM Check for G2 or G3 movements (these are not allowed)
grep -iq G[23] %1
if errorlevel 1 goto :MoreChecks
goto :NoG2G3

@REM Check if axis is X or Y
if /[%2]==[Y] (goto :OkProcess) else goto :CheckX

if /[%2]==[X] (goto :OkProcess) else goto :WrongAxis

@REM Here we do the heavy lifting (parsingto replace X or Y

%tr [:lower:] [:upper:] | sed "s/\([A-Z]\)/ \1/g ; s/ \+/ /g ; s/^ //g" gawk "{ for (n=1 ; n<=NF ; n++) if (substr($n,1,1)==toupper(\"%2\")) {printf \"A%%f \",substr($n,2)*(114.59155902616464175359630962821/%3) } else {printf \"%%s \", $n}; print \"\" }" >%4
goto :success

@REM Error messages
ERRORNo G2 or G3 movements allowed
-i G[23] %1
goto :ProperSyntax

ERRORAxis should be X or Y
goto :ProperSyntax

ERRORMissing parameters
goto :ProperSyntax

ERRORMissing Input Filename
goto :ProperSyntax

ERRORMissing Output Filename
goto :ProperSyntax

echo Syntaxwrapper ^<InputFile^> ^<or Y^> ^<Diameter^> ^<OutputFile^>
goto :

FILE: %4 successfully created!
I tried many files directly out of CAM and they wrapped perfectly, no ARC movements are allowed (g2 or g3) so if your gcode is only g0 and g1 it will work for sure.

If you want to backplot the file in mach3 remember to set the A axis as angular in the general config section and in the settings screen (Alt-6) set the correct rotating radius (diameter/2)


Download Link: (it contains all the needed GNUwin files)

Reply With Quote

Register Options Profile Last 1 | 3 | 7 Days Search Today's Posts Mark Forums Read

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Setting the Y-axis square to the X-axis Gerald_D 20. Gantry 10 Fri 12 October 2012 01:44
Setting A-axis terminal as X2-axis in EMC2 KenC CNC motion control software 2 Wed 27 January 2010 06:40
Cheap wrapper for indexer normand blais CAM 0 Sun 24 January 2010 14:14
CNC Wrapper Software Quiff The Market Place 9 Thu 29 October 2009 10:12
Rotary axis (4th Axis) or Indexer software smreish Graphics & CAD 0 Tue 28 July 2009 07:02

All times are GMT -6. The time now is 22:17.

Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.