[solved] How to output scalable G-code?

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
cave.dweller
Junior Member
Posts: 10
Joined: Tue Jan 19, 2016 12:41 am

[solved] How to output scalable G-code?

Post by cave.dweller » Wed Feb 03, 2016 8:45 pm

When I launch LinuxCNC (Axis), I am greeted by an example gcode file - letters spelling LinuxCNC.
This file has an interesting feature I'd like to replicate in all of my files:

Code: Select all

#<depth>=2.0
#<scale>=1.0
G21 G90 G64 G40
G0 Z3.0
( engraving )
G17
M3 S10000
G0 X[1.75781*#<scale>] Y[0.5*#<scale>]
G1 F100.0 Z[-#<depth>]
G1 F400.0 X[5.95508*#<scale>] Y[20.54297*#<scale>]
G1 X[10.07031*#<scale>]
and so on...

I've learned how to modify Qcad-Cam's header to include the depth and scale fields (very much a beginner at this) but in the CAM configuration file (running Andrew's customized Spesmek config) , I don't know how I'd tell Qcad to output all x and y coordinates with that scale modifier (don't need the Z scale function - just running a plasma table).

Any hints?

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

Re: How to output scalable G-code?

Post by andrew » Wed Feb 03, 2016 8:55 pm

You'd have to override getXCode / getYCode in your configuration file:
MyConfiguration.prototype.getXCode = function(value) {
    var v = value;
    if (this.getIncrementalXYZ() && !isNull(this.xPrev)) {
        v -= this.xPrev;
    }
    return "X[" + this.formatNumber(v) + "*#<scale>]";
};
The implementation of getYCode would be the same with Y instead of X and this.yPrev instead of this.xPrev.
"MyConfiguration" would be replaced by the name of your configuration file (probably "Spesmek"?).

cave.dweller
Junior Member
Posts: 10
Joined: Tue Jan 19, 2016 12:41 am

Re: How to output scalable G-code?

Post by cave.dweller » Wed Feb 03, 2016 11:52 pm

Thanks for your quick reply, Andrew

I added the code as you suggested, saved Spesmek.js, exited and re-opened Qcad.
There is no difference for me in a gcode output using Spesmek.js with or without the getXcode and getYcode functions you described.

Here's what I added:

Code: Select all

/**
 * Adds scale factor to each X and Y coordinate
 */

Spesmek.prototype.getXcode = function(value) {
    var v = value;
    if (this.getIncrementalXYZ() && !isNull(this.xPrev)) {
        v -= this.xPrev;
    }
    return "X[" + this.formatNumber(v) + "*#<scale>]";
};

Spesmek.prototype.getYcode = function(value) {
    var v = value;
    if (this.getIncrementalXYZ() && !isNull(this.yPrev)) {
        v -= this.yPrev;
    }
    return "Y[" + this.formatNumber(v) + "*#<scale>]";
};
I've attached my config, in case it would be helpful. I tried inserting the code snippet in different places in the file (and saving, restarting qcad, retrying) just in case it needed to go before or after something else to have an effect, but didn't see any change in gcode generated.
Attachments
Spesmek.js
My configuration file, including getXcode and getYcode functions
(2.92 KiB) Downloaded 613 times

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

Re: How to output scalable G-code?

Post by andrew » Thu Feb 04, 2016 8:15 am

What version of QCAD/CAM do you have installed?

cave.dweller
Junior Member
Posts: 10
Joined: Tue Jan 19, 2016 12:41 am

Re: How to output scalable G-code?

Post by cave.dweller » Fri Feb 05, 2016 12:55 am

QCAD/CAM Professional Trial

Version:
3.12.5.0 (3.12.5)
Internet:
QCAD.org
Build Date:
Jan 11 2016
Revision:

Qt Version:
4.8.6
Architecture:
i386
Compiler:
gcc 4.4.3

Running on Debian GNU/Linux 7 (wheezy) - LinuxCNC build

cave.dweller
Junior Member
Posts: 10
Joined: Tue Jan 19, 2016 12:41 am

Re: How to output scalable G-code?

Post by cave.dweller » Fri Feb 05, 2016 1:13 am

Just updated to 3.12.6. Added Spesmek.js and .ui to the new CamConfigurations folder.
Opened Qcad, verified that I was running the new version.

Still no scalable gcode output.

(At the risk of saying it too many times, Thank you Thank you Thank you, Andrew. I love the software and am very happy with it, and hope to be able to purchase a license once/if I can start making money with my table. Meanwhile, I greatly appreciate your assistance.)

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

Re: How to output scalable G-code?

Post by andrew » Fri Feb 05, 2016 9:10 am

Please make sure that the prototype assignment comes before the function definitions. Also it's 'getXCode' and 'getYCode' (note capital 'C' in Code).
// keep this before assigning any functions (everything added to prototype before this point is removed here!)
Spesmek.prototype = new GCode();

// definition of function getXCode (note capital C in Code):
Spesmek.prototype.getXCode = function(value) {
    var v = value;
    if (this.getIncrementalXYZ() && !isNull(this.xPrev)) {
        v -= this.xPrev;
    }
    return "X[" + this.formatNumber(v) + "*#<scale>]";
};

// definition of function getYCode (note capital C in Code):
Spesmek.prototype.getYCode = function(value) {
    var v = value;
    if (this.getIncrementalXYZ() && !isNull(this.yPrev)) {
        v -= this.yPrev;
    }
    return "Y[" + this.formatNumber(v) + "*#<scale>]";
};

cave.dweller
Junior Member
Posts: 10
Joined: Tue Jan 19, 2016 12:41 am

Re: How to output scalable G-code?

Post by cave.dweller » Fri Feb 05, 2016 4:24 pm

That did it! Thanks for your time, Andrew.
- David

Post Reply

Return to “QCAD/CAM”