Layers and Offset codes.
Moderator: andrew
Forum rules
Always indicate your operating system and QCAD version.
Indicate the post processor used.
Attach drawing files and screenshots.
Post one question per topic.
Always indicate your operating system and QCAD version.
Indicate the post processor used.
Attach drawing files and screenshots.
Post one question per topic.
Layers and Offset codes.
Hi Andrew
The last few days I've been looking at the Cam-addon to replace my modified Cam expert.
I can't get any new Z codes when there is a layer change in a contour. i played with the config file to prove that it was reading the depth. It's not detecting the change.
Also how can we get the G40-42 codes on the closed contours?
I have some understanding of C++ so I can understand each function in the gcode.js. Understanding them all together I find difficult.
Again thanks for a great program.
Stephen
The last few days I've been looking at the Cam-addon to replace my modified Cam expert.
I can't get any new Z codes when there is a layer change in a contour. i played with the config file to prove that it was reading the depth. It's not detecting the change.
Also how can we get the G40-42 codes on the closed contours?
I have some understanding of C++ so I can understand each function in the gcode.js. Understanding them all together I find difficult.
Again thanks for a great program.
Stephen
Re: Layers and Offset codes.
Could you attach or e-mail an example drawing and example G-Code (e.g. from your CAM Expert installation)?
QCAD/CAM is a lot more flexible than CAM Expert in terms of configuration, but it might require some work to get it adjusted just right.
QCAD/CAM is a lot more flexible than CAM Expert in terms of configuration, but it might require some work to get it adjusted just right.
Re: Layers and Offset codes.
My Camexport config was for one long contour and I remember it to being very limited in what you could do.
I'm keen not to go back there!
I've fixed the change Z (layer change) in a contour by adding this line to the prepareForCutting function.
So I can add G40-42's, How can I tell that I have a closed contour and what direction its heading from GCode.js ?
Also should closed contours inside another be going in the opposite direction ?
Stephen
I'm keen not to go back there!
I've fixed the change Z (layer change) in a contour by adding this line to the prepareForCutting function.
Code: Select all
GCode.prototype.prepareForCutting = function() {
// force tool down before normal move:
if (this.toolPosition !== GCode.ToolPosition.Down) {
// force tool up before tool down:
if (this.toolPosition !== GCode.ToolPosition.Up) {
this.writeToolUp();
}
this.writeToolDown();
}
this.writeZMove(this.getToolDownLevel()); //SRL, Change Z in contour.
};
So I can add G40-42's, How can I tell that I have a closed contour and what direction its heading from GCode.js ?
Also should closed contours inside another be going in the opposite direction ?
Stephen
Re: Layers and Offset codes.
Do you have enough information in your drawing to make these choices fully automatically?
Or how did you previously tell CAM Expert in what orientation (CW, CCW) to cut a contour and what radius compensation to use (G41, G42)?
Is there some information encoded in layer names? Maybe you can provide a simple example drawing.
I'm currently working on tools to tag entities with additional information which can then be used for further processing. For example to tag a closed contour as 'orientation:clockwise', 'radius-compensation:left'. This will make it possible to control manually how contours should be processed. However, it also means that you would have to prepare your drawing before converting it to GCode. Does that sound like something that would make sense for your use case?
Or how did you previously tell CAM Expert in what orientation (CW, CCW) to cut a contour and what radius compensation to use (G41, G42)?
Is there some information encoded in layer names? Maybe you can provide a simple example drawing.
I'm currently working on tools to tag entities with additional information which can then be used for further processing. For example to tag a closed contour as 'orientation:clockwise', 'radius-compensation:left'. This will make it possible to control manually how contours should be processed. However, it also means that you would have to prepare your drawing before converting it to GCode. Does that sound like something that would make sense for your use case?
Re: Layers and Offset codes.
Hi Andrew
I've just finished my GCode.js last night. Well I thought I did as I already have some improvements of course.
I have used one long contour for both programs, but your standard use (without rapids) also now works fine except for direction and offset on inner closed cuts.
Of course I can't control the direction of inner closed contours which need to be the opposite of the outer. If you could automatically have inner closed contours sent in the opposite direction it would be great.
Sorry got to go to work.
srl
I've just finished my GCode.js last night. Well I thought I did as I already have some improvements of course.
I have used one long contour for both programs, but your standard use (without rapids) also now works fine except for direction and offset on inner closed cuts.
Of course I can't control the direction of inner closed contours which need to be the opposite of the outer. If you could automatically have inner closed contours sent in the opposite direction it would be great.
Sorry got to go to work.
srl
Re: Layers and Offset codes.
So Tags would work very well as you have suggested. Could you have a "start" tag for setting the first entity?
Tags could also have priority over the layer name for setting the Z depth.
Here is a sample of what I'm up to.
I now need to do some practical testing , and some error checking in parseFloats.
srl
Tags could also have priority over the layer name for setting the Z depth.
Here is a sample of what I'm up to.
Code: Select all
GCode.prototype.writeHeader = function() {
this.writeLine("G10 L1 P1 R.5");
var layers = this.document.queryAllLayers();
for (var l = 0; l < layers.length; ++l) {
var layer = this.document.queryLayer(layers[l]);
var lt = layer.getName();
var vz = lt.indexOf("#");
var nz = lt.indexOf("Z");
if (vz != -1 && nz != -1)
{
var vzs = parseInt(lt.slice(vz+1));
var nzs = parseFloat(lt.slice(nz+1));
this.writeLine("#" + vzs + " = " + nzs + " (layer " + lt + ")");
}
}
var cutz = parseFloat(this.document.getVariable("Cam/ZCutting", -1.0));
var safy = this.getSafetyZLevel();
var cler = this.getToolUpLevel();
this.writeLine("#20 = " + cutz + " (cut z manual write)");
this.writeLine("#19 = " + safy + " (safty manual write)");
this.writeLine("#18 = " + cler + " (clear manual write)");
this.writeRapidZMove(19);
this.toolPosition = GCode.ToolPosition.Clear;
};
srl
Re: Layers and Offset codes.
I've just got my config working on 3.4.2
This line in .getToolDownLevel has changed.
Now I need to get entity custom values to over-ride those set in the layer name.
Stephen.
This line in .getToolDownLevel has changed.
Code: Select all
var layerValue = layer.getCustomProperty("QCADCAM","Cam/ZCutting", docValue);
Stephen.
Re: Layers and Offset codes.
Here is my offering for setting most things by the layer names.
To test I use linuxcnc ruining on Virtual Box and a real machine.
Use with caution, as I found out again!
srl
To test I use linuxcnc ruining on Virtual Box and a real machine.
Use with caution, as I found out again!
/* This is my LinuxCNC Gcode config file for the Qcad Cam add-on, can I remind you that the QCad add-on's are not "free" but only a trial. You can purchase a full version licence from Andrew Mustun at qcad.org . Z safety and Z clear are set in the CAM Dialog and and asigned to variables #19 and #18. Other parameters are set in the layer names as in the following:- '#(int)' The Z value for this layer is linked to this variable. Different layers may use the same Z variable. Example layer name -servo_cuts#14 'Z(float)' This assigns a Z value to the # Variable set in the same layer. Each variable used must be assigned a Z value. Example main_cuts#14Z-3.4 'F(int)' Set or change feed rate. Example servo_cuts#14F800 'R' all rapid moves. None of the above settings are needed. Example Rapid_guides 'L' after a rapid will send the tool at a angle to Level '# ' which also must be set. Example layer name Leadin#15 'G41' 'G42' 'G40' Set tool diameter compensation. This will be set back to G40 at the next rapid move. Edit a line in GCodesrl.prototype.writeHeader = function() or the opening Gcode line ("G10 L1 P1 R5") to suit your tool diameter. Example servo_cuts#14G42 'End' this ends the resulting file, with a M30 of course, this is used with one long contour with rapids. All entites after this will be ignored. This file is added to the CamConfigurations directory as 'GCodesrl.js' along side a unchanged GCode.js. More features may be added later. Use, test and adjust to suit your needs. For more information go to srlfoamies.com and follow a blog link. */ include("GCode.js"); function GCodesrl(documentInterface, newDocumentInterface) { GCode.call(this, documentInterface, newDocumentInterface); this.os = 40; this.endc = 1; // this.globalOptions = "GCode"; this.layerOptions = undefined; } GCodesrl.prototype = new GCode(); GCodesrl.prototype.initGlobalOptionWidget = function(w) { switch (w.objectName) { case "ZSafety": w.addItems(["100", "75", "19", "50"]); w.setEditText("100"); break; case "ZClear": w.addItems(["10", "20", "30"]); w.setEditText("20"); break; case "ZCutting": w.addItems(["2.6", "6", "10"]); w.setEditText("2.6"); break; } }; GCodesrl.prototype.getFileExtensions = function() { return ["ngc"]; }; GCodesrl.prototype.getLineNumberCode = function() { var ret = sprintf("N%d", this.lineNumber); this.lineNumber += 10; return ret; }; GCodesrl.prototype.getZCode = function(value) { var v = value; if (this.getIncrementalXYZ()) { v -= this.zPrev; } return sprintf("Z#%.3f", v); }; GCodesrl.prototype.getSafetyZLevel = function() { return parseFloat(this.document.getVariable("Cam/ZSafety", 100.0)); //return 19; hack line }; GCodesrl.prototype.getToolUpLevel = function() { return parseFloat(this.document.getVariable("Cam/ZClear", 2.0)); //return 18; hack line }; GCodesrl.prototype.getToolDownLevel = function() { // document wide default value: var docValue = 20; var entity = this.getEntity(); if (isNull(entity)) { return docValue; } // layer specific value: var layerId = entity.getLayerId(); var layer = this.document.queryLayer(layerId); if (isNull(layer)) { return docValue; } //error checking to be done here var lt = layer.getName(); var vf = lt.indexOf("F"); if (vf != -1) this.f = parseInt(lt.slice(vf+1)); var idx = lt.indexOf("#"); if (idx!= -1){ return parseInt(lt.slice(idx+1)); } return docValue; }; GCodesrl.prototype.writeToolUp = function() { this.g = GCode.Mode.Rapid; this.z = 18; this.toolPosition = GCode.ToolPosition.Up; if (this.feedRateSet!==true) { this.writeLine(undefined, "F500"); this.feedRateSet=true; } else { this.writeLine(); } this.toolIsUp(); }; GCodesrl.prototype.writeBeforeRapidLinearMove = function(x, y) { if (this.sinlayname("G41") != -1){ if (this.os == 41) return; this.writeLine("G41"); this.os = 41; return; } if (this.sinlayname("G42") != -1){ if (this.os == 42) return; this.writeLine("G42"); this.os = 42; return; } else{ if (this.os == 40) return; } this.writeLine("G40"); this.os = 40; }; GCodesrl.prototype.writeAfterRapidLinearMove = function(x, y) { }; GCodesrl.prototype.prepareForCutting = function() { // force tool down before normal move: if (this.toolPosition !== GCode.ToolPosition.Down) { // force tool up before tool down: if (this.toolPosition !== GCode.ToolPosition.Up) { this.writeToolUp(); //on rapid and down } if (this.sinlayname("L")!=-1) { this.z = this.getToolDownLevel(); return; } } this.writeToolDown(); }; GCodesrl.prototype.sinlayname = function( s) { var entity = this.getEntity(); var layerId = entity.getLayerId(); var layer = this.document.queryLayer(layerId); var lt = layer.getName(); return (lt.indexOf(s)); }; // G01: GCodesrl.prototype.writeLinearMove = function(x, y) { if (this.sinlayname("R")!=-1){ this.writeRapidLinearMove(x, y); return; } if (this.sinlayname("End")!=-1){ this.writeFooter(); this.endc = 0; } GCode.prototype.writeLinearMove.call(this, x, y); }; GCodesrl.prototype.writeHeader = function() { this.writeLine("G10 L1 P1 R5"); var layers = this.document.queryAllLayers(); for (var l = 0; l < layers.length; ++l) { var layer = this.document.queryLayer(layers[l]); var lt = layer.getName(); var vz = lt.indexOf("#"); var nz = lt.indexOf("Z"); if (vz != -1 && nz != -1) { var vzs = parseInt(lt.slice(vz+1)); var nzs = parseFloat(lt.slice(nz+1)); this.writeLine("#" + vzs + " = " + nzs + " (layer " + lt + ")"); } } var cutz = parseFloat(this.document.getVariable("Cam/ZCutting", -1.0)); var safy = this.getSafetyZLevel(); var cler = this.getToolUpLevel(); this.writeLine("#20 = " + cutz + " (cut z manual write)"); this.writeLine("#19 = " + safy + " (safty manual write)"); this.writeLine("#18 = " + cler + " (clear manual write)"); this.writeRapidZMove(19); this.toolPosition = GCode.ToolPosition.Clear; }; GCodesrl.prototype.writeFooter = function() { this.writeToolUp(); this.writeRapidZMove(19); this.toolPosition = GCode.ToolPosition.Clear; this.writeLine("M30"); }; GCodesrl.prototype.writeLine = function(custom, append) { if (this.endc != 1) return; GCode.prototype.writeLine.call(this, custom, append); };
srl
- Attachments
-
- GCodesrl.js
- (6.48 KiB) Downloaded 1080 times
Re: Layers and Offset codes.
Thanks for posting this, I'll have to study it for a while.
Line numbers are not needed with LinuxCNC and IMHO make the resulting G code file harder to read.
BTW, are you on the LinuxCNC dot org forum? There is a topic over there on QCad CAM in the CAM section.
http://linuxcnc.org/index.php/english/f ... 5-qcad-cam
Do you mind if I post a copy of this on the LinuxCNC forum?
I went to http://www.srlfoamies.com and didn't see a link for your QCad project...
JT
Line numbers are not needed with LinuxCNC and IMHO make the resulting G code file harder to read.
BTW, are you on the LinuxCNC dot org forum? There is a topic over there on QCad CAM in the CAM section.
http://linuxcnc.org/index.php/english/f ... 5-qcad-cam
Do you mind if I post a copy of this on the LinuxCNC forum?
I went to http://www.srlfoamies.com and didn't see a link for your QCad project...
JT
Re: Layers and Offset codes.
Interesting - that means I wasn't the only one without any luck ...jthornton wrote:I went to http://www.srlfoamies.com and didn't see a link for your QCad project...
Re: Layers and Offset codes.
Just done two things.
'#int 'Variables in frozen layer names are no longer added.
'Z float' A plain Z level can now be used in a layer name.
I used it to cut some things yesterday so it works. No more Cam-Expert.
Right click and save as.
srl
'#int 'Variables in frozen layer names are no longer added.
'Z float' A plain Z level can now be used in a layer name.
I used it to cut some things yesterday so it works. No more Cam-Expert.
Right click and save as.
srl
My CAM config using layer names and variables
Here is my latest update for the new year.
I've changed "cut", "safety" and "clear" set in the opening dialog to named variables instead of #numbers. This will make the gcode easier to read as rapids will stand out.
Layers can still be assigned a number variable from #1 to #30.
Any unassigned visible layers will use the #<cut> level set in the dialog as a default.
To test I use Linuxcnc sim in VirturalBox. It saves going out to the shed.
Rename the below file to GCodesrl.js for it to work.
srl
I've changed "cut", "safety" and "clear" set in the opening dialog to named variables instead of #numbers. This will make the gcode easier to read as rapids will stand out.
Layers can still be assigned a number variable from #1 to #30.
Any unassigned visible layers will use the #<cut> level set in the dialog as a default.
To test I use Linuxcnc sim in VirturalBox. It saves going out to the shed.
Rename the below file to GCodesrl.js for it to work.
srl
- Attachments
-
- GCodesrl12.js
- CAM config using layer names v.12
- (7.36 KiB) Downloaded 1079 times
Re: Layers and Offset codes.
Still working on my config file. I've been working on a milling path for all the area of a closed contour all automatically generated at CAM time. An simple idea at first until i remembered there may be path compensation. So I now know all about Javascript arrays( push , pop)
srl
srl
- Attachments
-
- screen shot
- sc.png (61.84 KiB) Viewed 34958 times
Re: Layers and Offset codes.
Impressive, kudos!
Re: Layers and Offset codes.
Thanks Andrew
Here is v.15 with a compensation option for the spiral mill area.
Any feed back is welcomed here or at my website.
srl
Here is v.15 with a compensation option for the spiral mill area.
Any feed back is welcomed here or at my website.
srl
- Attachments
-
- GCodesrl.js
- v.15 GCodesrl.js
- (20.4 KiB) Downloaded 1045 times