Raw Code Preview & Calling External Processors

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
mechatronic
Junior Member
Posts: 22
Joined: Wed Nov 08, 2023 11:24 am

Raw Code Preview & Calling External Processors

Post by mechatronic » Wed Nov 08, 2023 11:34 am

Hi,

I've been using QCAD for the last 10 years now, but having bought a laser cutter with no modern driver support, I've ended up moving over to QCAD-CAM.

Long story short, I've had to figure out HPGL/2 (and PCL/HPRTL), and built my own post processor that can create files that the machine can use. QCAD being one of a very short list of apps that produces clean HPGL (via the HPPlotter processor with comments removed - the old HPGL processor doesn't quite work).

At present I have to send the exported file using LPR (in raw mode) on the command line. That's simple enough, but could be replaced by a UI button easily enough.

To clean up the workflow, I'm happy enough to have a shell or Ruby/Python script etc that will do that, provided a path is passed to it. The CAM config knows the path, so calling the script or even LPR directly with the file path is easy enough. I have no idea about the structure of QCAD (yet :/ ) so not sure what the best approach is. It's really only applicable to my post processor, so I'm hoping I can add it into the code for that and only have it appear on the UI when it's selected? That or a generic UI button that does nothing when a variable in the post processor (like the resolved command and path) is empty. Is there any scope to add extra fields etc in the CAM configuration menu for extra stuff to be passed? Would be nice to set the printer name or path there. I'm not adverse though to an external script, as then I can point Fusion 360 at it (I'll probably build a processor for that too).

Second, I'd really love a text preview as well within QCAD of the raw output of the post processor. I don't know if this is available in form of debug tools already or what, but as another button enabled feature that allows me to quickly scan over the code for gremlins before hitting 'upload' would be great.

Any tips/advice would be much welcome. I'm doing this on the side of my normal stuff, so as many shortcuts and hacks as possible are welcome :D

Jon

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

Re: Raw Code Preview & Calling External Processors

Post by andrew » Wed Nov 08, 2023 3:18 pm

I would reimplement the writeFile function in your post processor and do all the things you want to do as soon as the file had been written.

Code: Select all

MyExporter.prototype.writeFile = function(fileName) {
    // call implementation of base class (assuming your base class is CamExporterV2):
    CamExporterV2.prototype.writeFile.call(this, fileName);

    // show a dialog displaying the file and allowing the user to send it to the machine:
    // ...
};
The sky is the limit as you have full access to the whole Qt and QCAD/CAM API.

You can find a lot of example code at:
https://github.com/qcad/qcad/tree/master/scripts

Here's an example to run a command line command from QCAD using QProcess:
https://github.com/qcad/qcad/blob/maste ... Process.js

This should work to create a button that calls LPR from your post processor.

mechatronic
Junior Member
Posts: 22
Joined: Wed Nov 08, 2023 11:24 am

Re: Raw Code Preview & Calling External Processors

Post by mechatronic » Mon Nov 13, 2023 3:35 pm

Thanks Andrew

Is there any documentation for CamExportV2? I've found the tutorial (https://qcad.org/en/qcad-cam-postprocessor) which has the variables available, constructor options and the process block, but can't see or find the list of options for each block and command?

The HPGL/2 (I've used the HPPlotter processor as that's more advanced) is absolute, and I want to try a relative version to see if the machine works with it. Mostly, as it's starting at the bed origin, so I'm losing a key function which is being able to physically move the head (with laser pointer) to a start position before cutting. The machine doesn't have a zero'ing/homing function to set a start point, so I think it relies upon relative instructions (I believe, or maybe there's something hidden inside of the HPGL/2 spec I've not found), and not reseting the home position (or using absolutes) at the beginning of the instruction set.

If I want more options in the CAM config, can it be done via the post-processor script? For example storing the path to the print queue, additional machine config etc?

Thanks
Jon

[edit] as meant CamExportV2 not GCodeBase.js

Post Reply

Return to “QCAD/CAM”