Hello,
I am in the need of two variables that increment by 1, each time they are called up.
I am using the 'N' linenumber as as one of the variables.
I made another variable in the JS file, and called it eventnumber.
It does show in the post, but does not increment.
I have some screenshots attached for reference.
Thank you.
P.S. Sorry if these files are not well organized, or if I am missing out something that I should have included.
Running Windows 10, QCad/Cam version 3.25.2.4
[Solved] N line number increment
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.
[Solved] N line number increment
- Attachments
-
- Test Post.dxf
- (109.35 KiB) Downloaded 396 times
-
- PT4.js
- (826 Bytes) Downloaded 374 times
-
- GCode2AxisPT.js
- (10.81 KiB) Downloaded 383 times
-
- Eventnumber screenshot.jpg (30.66 KiB) Viewed 5586 times
-
- Thisrapidmove screenshot.jpg (43.39 KiB) Viewed 5586 times
-
- Eventnumber does not increment.jpg (59.1 KiB) Viewed 5586 times
Last edited by Daniel4 on Wed Feb 03, 2021 2:40 am, edited 1 time in total.
Re: N line number increment
You'd have to detect when [E] gets written and increment accordingly:
This is overly complicated and we will add a function to detect variable usage more easily. This will work with QCAD/CAM >= 3.25.2.11:
Code: Select all
GCode2AxisPT.prototype.writeBlockFromString = function(blockStrings) {
if (isNull(blockStrings)) {
return;
}
if (isString(blockStrings)) {
blockStrings = [ blockStrings ];
}
// detect usage of [E]
var incE = false;
for (var i=0; i<blockStrings.length; i++) {
// blockString
// e.g. "[N] G01 [X] [Y]"
var blockString = blockStrings[i];
if (blockString.contains("[E]")) {
// a block string contains variable [E], increment after writing
incE = true;
}
}
// write block strings:
CamExporterV2.prototype.writeBlockFromString.call(this, blockStrings);
if (incE) {
this.eventNumber+=this.eventNumberIncrement;
}
};
Code: Select all
GCode2AxisPT.prototype.variableUsed = function(id, value) {
if (id==="E") {
this.eventNumber+=this.eventNumberIncrement;
}
};
Re: [Solved] N line number increment
Wow Andrew!
I have no idea how you did that. it works perfect, thanks!
I could have never figured that out.
I have no idea how you did that. it works perfect, thanks!
I could have never figured that out.