@rem = '--*-Perl-*-- @echo off if "%OS%" == "Windows_NT" goto WinNT perl -x -S "%0" %1 %2 %3 %4 %5 %6 %7 %8 %9 goto endofperl :WinNT perl -x -S "%0" %* if NOT "%COMSPEC%" == "%SystemRoot%\system32\cmd.exe" goto endofperl if %errorlevel% == 9009 echo You do not have Perl in your PATH. if errorlevel 1 goto script_failed_so_exit_with_non_zero_val 2>nul goto endofperl @rem '; #!/usr/bin/perl #line 16 #### #### All Code by Steve Michel #### $StartOld = "temp"; $DestOld = "temp"; $dxfFile = $ARGV[0]; my @split_dxfFile = split(/\\/, $dxfFile); my $dxfFileName = $split_dxfFile[$#split_dxfFile]; my @split_dxfFile2 = split(/\./, $dxfFile); my $dxfFileRoot = $split_dxfFile2[0]; my $path = join("\\", @split_dxfFile[0 .. ($#split_dxfFile-1)]); print ("opening file... " . $path . "\\" . $dxfFileName . "\n" ); print ("writing file... " . $dxfFileRoot . "_G-code.txt\n\n\n" ); print ("more " . $dxfFileRoot . "_G-code.txt\n" ); open (FILEHANDLE, $dxfFile); while () { push(@lines,$_) } #print join("\n", @lines); $listNum = @lines; #print ($listNum); open (FILE, ">" . $dxfFileRoot . "_G-code.txt"); print FILE ("{dakcnc3.0} \n"); print FILE ($dxfFile . "\n"); print FILE ($dxfFileRoot . "_G-code.txt\n"); print FILE ("{program start} \n"); print FILE ("G70 \n"); for ($Loop = 0; $Loop <= $listNum; $Loop++){ chomp ($lines[$Loop]); } for ($Loop = 0; $Loop <= $listNum; $Loop++){ # print FILE ($lines[$Loop]); $TEMP = $lines[$Loop]; # print FILE ($TEMP); if ($TEMP eq "LINE"){ $Xs = $lines[$Loop + 6]/.025400 ; $Ys = $lines[$Loop + 8]/.025400 ; $Zs = $lines[$Loop + 10]/.025400 ; $Xs = int($Xs * 1000); $Ys = int($Ys * 1000); $Zs = int($Zs * 1000); $Xs = $Xs / 1000; $Ys = $Ys / 1000; $Zs = $Zs / -1000; $Xd = $lines[$Loop + 12]/.025400 ; $Yd = $lines[$Loop + 14]/.025400 ; $Zd = $lines[$Loop + 16]/.025400 ; $Xd = int($Xd * 1000); $Yd = int($Yd * 1000); $Zd = int($Zd * 1000); $Xd = $Xd / 1000; $Yd = $Yd / 1000; $Zd = $Zd / -1000; $Start = "X" . $Xs . " Y" . $Ys . " Z". $Zs; $Dest = "X" . $Xd . " Y" . $Yd . " Z". $Zd; if ($Start ne $DestOld){ $Start1 = "X" . $Xs . " Y" . $Ys; print FILE ("G01 Z0.1 \n"); print FILE ("G01 " . $Start1 . "\n"); print FILE ("G01 Z" . $Zs . "\n"); } print FILE ("G01 " . $Dest . "\n"); $StartOld = $Start; $DestOld = $Dest; } } print FILE ("G01 Z0.1 \n"); print FILE ("G01 X0.0000 Y0.0000 \n"); print FILE ("M02 ;EOF \n"); print FILE ("{program end} \n"); close FILE; __END__ :endofperl