garciasa / grbl-drills-cambam Goto Github PK
View Code? Open in Web Editor NEWdrills for grbl
drills for grbl
There are a number of different methods in which a user could use the script, it has not been made clear where the script is to be used. Are you creating a macro with the script, are you importing the scrip into Cambam via the root script folder or are you replacing the Drill GCode operation within the post processor - OR does it run as a stand alone script somehow. Some more information would be most valuable.
It didn't parse it correctly so I corrected it and then I added some updates to it. I coded it in c# since that's easier for me:
static void Main(string[] args)
{
String noCutSpeed = "300";
String noCutDepth = "2.0";
String cutSpeed = "80";
String cutDepth = "-2.0";
String markDepth = "-0.01";
String inputfile = "";
String outputfile = "";
bool justMark = false;
for(int i = 0; i < args.Length; i++)
{
String arg = args[i];
switch(arg)
{
case "-h":
// exit
break;
case "-i":
case "--ifile":
inputfile = args[i+1];
break;
case "-o":
case "--ofile":
outputfile = args[i+1];
break;
case "-m":
case "--justMark":
justMark = true;
break;
default:
Console.WriteLine("unhandled option");
break;
}
}
if(File.Exists(inputfile))
{
StreamReader fin = new StreamReader(inputfile);
StreamWriter fout = new StreamWriter(outputfile);
do
{
String line = fin.ReadLine();
bool modified = false;
String temp = "";
String[] commands = line.Split(' ');
if (commands[0] == "G81")
{
// Start conversion
if (justMark)
temp = "G1 Z" + markDepth + " F" + noCutSpeed + "\n";
else
{
temp = "G1 ";
for (int i = 1; i < commands.Length; i++)
if (commands[i].Contains('X') ||
commands[i].Contains('Y'))
temp += commands[i] + " ";
else if (commands[i].Contains('Z'))
temp += "Z" + noCutDepth + " ";
temp += "F" + noCutSpeed + "\n";
}
modified = true;
}
if(commands[0] == "G98")
modified = true;
if(commands[0] == "G80")
{
temp = "G1 Z" + noCutDepth + "\n";
modified = true;
}
if(modified)
fout.WriteLine(temp);
else
fout.WriteLine(line);
if (commands[0] == "G81")
{
fout.WriteLine("G1 Z" + cutDepth + " F" + cutSpeed);
fout.WriteLine("G1 Z" + noCutDepth + " F" + noCutSpeed);
}
}
while (fin.Peek() != -1);
fin.Close();
fout.Close();
}
else
{
printUsage();
}
}
public static void printUsage()
{
Console.WriteLine("convertCamBamDrills.exe -i <inputfile> -o <outputfile> [-m]");
Console.WriteLine("\t-i or --ifile\t<inputfile> File with cambam gcodes");
Console.WriteLine("\t-o or --ofile\t<outputfile> Outfile with drills converted");
Console.WriteLine("\t-m or --justMark\tJust mark the hole");
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.