[solved] CAM output decimal places

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
rabtrfld
Newbie Member
Posts: 8
Joined: Tue Oct 13, 2020 2:06 pm

[solved] CAM output decimal places

Post by rabtrfld » Mon Nov 02, 2020 10:33 pm

My device only reads integers. How can I control the number of decimal places in CAM output?

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

Re: CAM output decimal places

Post by andrew » Tue Nov 03, 2020 10:10 am

This information applies to legacy CAM configuration files (in scripts/Cam/CamConfigurations).

Open the file "HPGL.js" and change:

Code: Select all

this.decimals = 4;
to:

Code: Select all

this.decimals = 0;
Alternatively, you can create your own configuration, base on HPGL.js (e.g. MyHPGL.js).

rabtrfld
Newbie Member
Posts: 8
Joined: Tue Oct 13, 2020 2:06 pm

Re: CAM output decimal places

Post by rabtrfld » Wed Nov 04, 2020 9:00 pm

Great, thanks! Editing HPGL.js worked to control the number of decimal places in CAM output.

Code: Select all

this.decimals = 0; // Was 4
But I tried saving the script as "HPGL-integer.js" and that didn't work. It showed up in the Configuration list but gave error
Configuration file does not provide a class named "HPGL-4digit".

I can probably figure this out myself but a little more help would be appreciated. I am struggling to use a laser running MSDOS and can't spend much "company time" on this. Old engraving jobs were done years ago but the software tools are long gone. The only way to input new jobs was a floppy disk, and we don't have any of those any more. So I partitioned the drive to boot Windows XP (!) just to copy files from a USB chip. Then reboot into MSDOS and see if it works. If it doesn't, run back upstairs to my desk and try something else. It took three days of this just to determine that the decimal point was a problem. So you saved me writing a post-processor... thanks again!

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

Re: CAM output decimal places

Post by andrew » Wed Nov 04, 2020 10:53 pm

The filename has to match the class in the file.

Ideally, you would derive your class from HPGL and only change the decimal places. This is an example for a file scripts/Cam/CamConfigurations/MyHPGL.js:

Code: Select all

include("HPGL.js");
  
function MyHPGL(documentInterface, newDocumentInterface) {
    HPGL.call(this, documentInterface, newDocumentInterface);

    this.decimals = 0;
}

MyHPGL.prototype = new HPGL();
Note that HPGL-integer is not a valid class name as this would evaluate into a mathematical expression in JavaScript. HPGLInteger or HPGL_Integer would both work tough.

rabtrfld
Newbie Member
Posts: 8
Joined: Tue Oct 13, 2020 2:06 pm

Re: CAM output decimal places

Post by rabtrfld » Thu Nov 05, 2020 4:40 pm

Thanks, again! Was looking for class declaration because I'm used to C++, seems like JS does it implicitly. So all the member names have to change, a simple edit.

BTW - How do I mark a thread as solved? This one is solved to my total satisfaction.

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

Re: CAM output decimal places

Post by andrew » Thu Nov 05, 2020 4:48 pm

Glad to hear it worked.
rabtrfld wrote:
Thu Nov 05, 2020 4:40 pm
BTW - How do I mark a thread as solved? This one is solved to my total satisfaction.
You can simply edit the first post and add [solved] to it at the front as I just did.

Post Reply

Return to “QCAD/CAM”