Condition

Discussions around the CAM Add-On of QCAD.

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.

Post Reply
Claudiosp
Junior Member
Posts: 21
Joined: Tue Feb 11, 2020 4:17 pm

Condition

Post by Claudiosp » Sat Jul 16, 2022 12:07 pm

Hi I need some help
I need make a condicion IF on post

if toolname===AGGREGATE10
[N] PAN=[NUMBERTOOL] UT=1 XIN=[START_X] YIN=[START_Y-] TID=1 XFI=[END_X] YFI=[ENDY-] PRF=[-Z-] VT=[FP] VF=[F] INV=0 USC=0 RES=1 Z=PRK L=G102
ELSE

NORMAL CODE

User avatar
andrew
Site Admin
Posts: 9037
Joined: Fri Mar 30, 2007 6:07 am

Re: Condition

Post by andrew » Wed Jul 20, 2022 11:25 am

Do you already have a post processor and are you trying to add this to it? If so, please attach. Or are you starting from scratch? Thanks.

Claudiosp
Junior Member
Posts: 21
Joined: Tue Feb 11, 2020 4:17 pm

Re: Condition

Post by Claudiosp » Wed Jul 20, 2022 12:16 pm

Hi Andrew is this BIESSE.
Attachments
BIESSE.js
(4.53 KiB) Downloaded 272 times

User avatar
andrew
Site Admin
Posts: 9037
Joined: Fri Mar 30, 2007 6:07 am

Re: Condition

Post by andrew » Thu Jul 28, 2022 10:55 am

Thanks.

Is it the text block this.contourHeader that would be adjusted, depending on the tool?

In general, you would change the contents of that text block, depending on the tool before the text block is written to the file:

Code: Select all

BIESSE.prototype.writeBlock = function(name) {
    if (this.getCurrentToolName()==="AGGREGATE10") {
        // tool is AGGREGATE10
        this.contourHeader = [ "[N] PAN=..." ];
    }
    else {
        // tool is not AGGREGATE10
        this.contourHeader = [ "[N] PAN=1 ..." ];
    }

    // call base class to write the text block:
    GCodeBase.prototype.writeBlock.call(this, name);
};

Claudiosp
Junior Member
Posts: 21
Joined: Tue Feb 11, 2020 4:17 pm

Re: Condition

Post by Claudiosp » Thu Jul 28, 2022 4:55 pm

I have problem on tool correction
When is AGGREGATE10 IS SAW need tool compensation without G41/G42
And old BUG when I change tool direction I need close QCAD and Open again for do correct NC.
I use last Version o QCAD



BIESSE.prototype = new GCodeBase();

BIESSE.prototype.writeBlock = function(name) {
if (this.getCurrentToolName()==="AGGREGATE10") {
// tool is AGGREGATE10

this.registerVariable("xStartPosition", "X1", true, "", "DEFAULT", "DEFAULT");
this.registerVariable("yStartPosition", "Y1", true, "", "DEFAULT", "DEFAULT");
this.registerVariable("zStartPosition", "Z1", true, "", "DEFAULT", "DEFAULT");
this.registerVariable("xPosition", "X", false, "", "DEFAULT", "DEFAULT");
this.registerVariable("yPosition", "Y", false, "", "DEFAULT", "DEFAULT");
this.registerVariable("zPosition", "Z", false, "", "DEFAULT", "DEFAULT");

this.outputOffsetPath = true;
this.contourHeader = [ "[N] PAN=1 ST1=\"[T]\" L=PCUA",
"[N] PAN=1 UT=1 XIN=[X1] YIN=[Y1-] TID=1 XFI=[X] YFI=[Y-] PRF=[Z-] VT=[FP] VF=[F] INV=0 USC=0 RES=1 Z=PRK L=G102" ];
this.zPassFirstHeader = [];
this.zPassHeader = [];
this.firstLinearMove = [];
this.linearMove = [];
this.footer = ["%"];
this.contourFooter =[];
this.linearMoveCompensationLeft = [];
this.linearMoveCompensationRight = [];
this.linearMoveCompensationOff = [];
}
else {
// tool is not AGGREGATE10

this.outputOffsetPath = false;
this.contourHeader = [ "[N] PAN=1 ST1=\"[T]\" L=PCUA" ];
this.zPassFirstHeader = [ "[N] [X1] [Y1-] Z=PRK TP=1 PRF=[Z1-] F=[F] VF=[FP] G40 L=PON TRZ=0 M55"];
this.zPassHeader = [ "[N] [X1] [Y1-] Z=PRK TP=1 PRF=[Z-] F=[F] VF=[FP] G40 L=PON TRZ=0 M55 "];
this.firstLinearMove = [ "[N] G1 [X] [Y-]"];
this.linearMove = [ "[N] G1 [X] [Y-]"];
this.footer = [
"[N] G0 L=POFF",
"%"
];
this.contourFooter = ["[N] L=POFF",];
this.linearMoveCompensationLeft = [ "[N] G42 G69 [X] [Y-] G1 "];
this.linearMoveCompensationRight = ["[N] G41 G69 [X] [Y-] G1 "];
this.linearMoveCompensationOff = [
"[N] G40 [X] [Y-] G1 ",
"[N] L=PSU",
];

}

// call base class to write the text block:
GCodeBase.prototype.writeBlock.call(this, name);
};

User avatar
andrew
Site Admin
Posts: 9037
Joined: Fri Mar 30, 2007 6:07 am

Re: Condition

Post by andrew » Fri Jul 29, 2022 4:24 pm

You moved all the code from the constructor into writeBlock. This is not the idea (please see post above). writeBlock should only change the text blocks you want to change and call the base class to write the text block.

Claudiosp
Junior Member
Posts: 21
Joined: Tue Feb 11, 2020 4:17 pm

Re: Condition

Post by Claudiosp » Fri Jul 29, 2022 5:08 pm

I do this because they repete some code.
Show me how do this

Code: Select all

BIESSE.prototype = new GCodeBase();

BIESSE.prototype.writeBlock = function(name) {
if (this.getCurrentToolName()==="AGGREGATE10") {
// tool is AGGREGATE10

this.registerVariable("xStartPosition", "X1", true, "", "DEFAULT", "DEFAULT");
this.registerVariable("yStartPosition", "Y1", true, "", "DEFAULT", "DEFAULT");
this.registerVariable("zStartPosition", "Z1", true, "", "DEFAULT", "DEFAULT");
this.registerVariable("xPosition", "X", false, "", "DEFAULT", "DEFAULT");
this.registerVariable("yPosition", "Y", false, "", "DEFAULT", "DEFAULT");
this.registerVariable("zPosition", "Z", false, "", "DEFAULT", "DEFAULT");

this.outputOffsetPath = true;
this.contourHeader = [ "[N] PAN=1 ST1=\"[T]\" L=PCUA",
"[N] PAN=1 UT=1 XIN=[X1] YIN=[Y1-] TID=1 XFI=[X] YFI=[Y-] PRF=[Z-] VT=[FP] VF=[F] INV=0 USC=0 RES=1 Z=PRK L=G102" ];
this.zPassFirstHeader = [];
this.zPassHeader = [];
this.firstLinearMove = [];
this.linearMove = [];
this.footer = ["%"];
this.contourFooter =[];
this.linearMoveCompensationLeft = [];
this.linearMoveCompensationRight = [];
this.linearMoveCompensationOff = [];
}
else {
// tool is not AGGREGATE10

this.outputOffsetPath = false;
this.contourHeader = [ "[N] PAN=1 ST1=\"[T]\" L=PCUA" ];
this.zPassFirstHeader = [ "[N] [X1] [Y1-] Z=PRK TP=1 PRF=[Z1-] F=[F] VF=[FP] G40 L=PON TRZ=0 M55"];
this.zPassHeader = [ "[N] [X1] [Y1-] Z=PRK TP=1 PRF=[Z-] F=[F] VF=[FP] G40 L=PON TRZ=0 M55 "];
this.firstLinearMove = [ "[N] G1 [X] [Y-]"];
this.linearMove = [ "[N] G1 [X] [Y-]"];
this.footer = [
"[N] G0 L=POFF",
"%"
];
this.contourFooter = ["[N] L=POFF",];
this.linearMoveCompensationLeft = [ "[N] G42 G69 [X] [Y-] G1 "];
this.linearMoveCompensationRight = ["[N] G41 G69 [X] [Y-] G1 "];
this.linearMoveCompensationOff = [
"[N] G40 [X] [Y-] G1 ",
"[N] L=PSU",
];

}

// call base class to write the text block:
GCodeBase.prototype.writeBlock.call(this, name);
};

Post Reply

Return to “QCAD/CAM”