MechMate CNC Router Forum

MechMate CNC Router Forum (http://www.mechmate.com/forums/index.php)
-   Utility software (http://www.mechmate.com/forums/forumdisplay.php?f=17)
-   -   The simplest 4th Axis Wrapper and FREE (http://www.mechmate.com/forums/showthread.php?t=3177)

PEU Wed 24 November 2010 19:37

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
@REM Heavylifting (parsingby Daniel Sentinelli
@REM Ideamath and errorchecks by Pablo EUntroib (PEU)
@
REM
@REM USAGEwrapper <InputFile> <axis> <diameter> <OutputFile>

@echo 
off
@SETLOCAL  ENABLEEXTENSIONS

@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
)

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

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


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

  cat 
%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
:NoG2G3
   
echo.
   echo 
ERRORNo G2 or G3 movements allowed
   grep 
-i G[23] %1
   
goto :ProperSyntax

:WrongAxis
   
echo.
   echo 
ERRORAxis should be X or Y
   
goto :ProperSyntax

:MissingParameter
   
echo.
   echo 
ERRORMissing parameters
   
goto :ProperSyntax

:MissingInput
   
echo.
   echo 
ERRORMissing Input Filename
   
goto :ProperSyntax

:MissingOutput
   
echo.
   echo 
ERRORMissing Output Filename
   
goto :ProperSyntax

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

:success
   
echo.
   echo 
FILE: %4 successfully created!
   echo. 
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)


Enjoy!

Download Link: http://dl.dropbox.com/u/3624504/WrapperByPEU.zip (it contains all the needed GNUwin files)


Pablo


All times are GMT -6. The time now is 15:53.

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