CAM output text formatting?

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
Dacicusan
Active Member
Posts: 49
Joined: Sat Oct 14, 2017 1:44 am

CAM output text formatting?

Post by Dacicusan » Fri Jan 28, 2022 5:51 pm

Hi. I do need to write a new post-processor for a Morbidelli machine and I do need the following output format:

I want to change in the post.js (modified from the "EMC2.js") the following line:

Code: Select all

this.rapidMove = "G0 [X] [Y]";
to have this output:

Code: Select all

XG0 X=765 Y=5 Z=15.2 V=1500 S=18000 D=10 T=107 C=1 E=1
The problem is that I don'ow how to change the

Code: Select all

[X]
part to have as output:

Code: Select all

X=765
(765 is the value of X).

Unfortunately the documentation on how to create a new post-processor it is very scarce and I can't find a way how to get the desired output. Thank you.

CVH
Premier Member
Posts: 3416
Joined: Wed Sep 27, 2017 4:17 pm

Re: CAM output text formatting?

Post by CVH » Fri Jan 28, 2022 6:19 pm

Dacicusan wrote:
Fri Jan 28, 2022 5:51 pm
to have this output:
XG0 X=765 Y=5 Z=15.2 V=1500 S=18000 D=10 T=107 C=1 E=1
It can't be the idea that all traversing in G0 mode would go to (765.0,5.0) ... :roll:

this.rapidMove = "G0 [X] [Y]";
Means that all rapid moves will be coded as 'G0' literal and the parsed coordinate in X & Y with spaces in between.
With 'G0' in standard G-code meaning 'as fast as allowed'.

[X] & [Y] are placeholders for the X and the Y coordinate of the CAM output.
These variables are declared elsewhere.
The values may vary depending the path to follow.

For the rapid moves to start with 'XG0' literal instead of 'G0' literal:
this.rapidMove = "XG0 [X] [Y]";

For extra things just add them literal:
this.rapidMove = "XG0 X=[X] Y=[Y] Z=[Z] V=1500 ... and so on";

In this case for rapid moves: V will always be 1500, S always 18000, ...

Regards,
CVH

Dacicusan
Active Member
Posts: 49
Joined: Sat Oct 14, 2017 1:44 am

Re: CAM output text formatting?

Post by Dacicusan » Fri Jan 28, 2022 7:14 pm

CVH wrote:
Fri Jan 28, 2022 6:19 pm

For extra things just add them literal:
this.rapidMove = "XG0 X=[X] Y=[Y] Z=[Z] V=1500 ... and so on";
It is not working. I do get this:

Code: Select all

XG0 X=[] Y=[]
And I need the values of X and Y instead of the square brackets. Like this:

Code: Select all

XG0 X=765 Y=5

CVH
Premier Member
Posts: 3416
Joined: Wed Sep 27, 2017 4:17 pm

Re: CAM output text formatting?

Post by CVH » Sat Jan 29, 2022 4:21 am

Dacicusan wrote:
Fri Jan 28, 2022 7:14 pm
It is not working. I do get this:
"XG0 X=[] Y=[]"
Ok, so the "XG0" works out but the rest isn't ... :(
Dug a little deeper and I think I may see my mistake. :oops:

Look up where your variable is defined e.g.

Code: Select all

    //                    name,                  ID,                     always, prefix, decimals, options
    this.registerVariable("xPosition",           "X",                    false, "X", "DEFAULT", "DEFAULT");
Adapt the prefix
So that the placeholder '[X]' is replaced by the 'xPosition' with prefix 'X=' ...

Other literal things should work out. Are they?

Regards,
CVH

Dacicusan
Active Member
Posts: 49
Joined: Sat Oct 14, 2017 1:44 am

Re: CAM output text formatting?

Post by Dacicusan » Tue Feb 01, 2022 12:28 pm

Now I have:

Code: Select all

XG0 X=[xPosition] Y=[yPosition]
in the output

CVH
Premier Member
Posts: 3416
Joined: Wed Sep 27, 2017 4:17 pm

Re: CAM output text formatting?

Post by CVH » Tue Feb 01, 2022 12:50 pm

Dacicusan wrote:
Tue Feb 01, 2022 12:28 pm
Now I have:

Code: Select all

XG0 X=[xPosition] Y=[yPosition]
in the output
:shock:
Please include your custom post processor in full.
As a *.js file or as code is fine.
And all related custom things like a test drawing with CAM profiles.
Or adapted base classes.

Regards,
CVH

Dacicusan
Active Member
Posts: 49
Joined: Sat Oct 14, 2017 1:44 am

Re: CAM output text formatting?

Post by Dacicusan » Tue Feb 01, 2022 1:04 pm

I just changed a post that already exists and smashing my head against the walls because I have no idea about programming.

This is the output from AlphaCAM:

Code: Select all

H DX=2440 DY=1220 DZ=15 -EH C=0 T=16973824 R=1 *MM /"DEF" BX=0 BY=0 BZ=6 V=0; BACKWALL_ALPHACAM
* Tool List Start
;Tool=107. Name=E07 10MM SPIRAL ,Diameter=8.2
;Tool=8. Name=E08 - 7.5MM DRILL RH ,Diameter=7.5
* Tool List End
;**
.OP1 ;Cut_Through
;**
XG0 X=765 Y=5 Z=15.2 V=1500 S=18000 D=10 T=107 C=1 E=1
XL2P X=5 Y=5 V=4000
XL2P X=5 Y=895
XL2P X=1525 Y=895
XL2P X=1525 Y=5
XL2P X=765 Y=5
;**
.OP2 ;Cut_Through(3)
;**
XG0 X=339 Y=177.5 Z=15.2 V=1500 S=18000 D=10 T=107 C=2 E=1
XL2P X=339 Y=165 V=4000
XL2P X=314 Y=165
XL2P X=314 Y=190
XL2P X=339 Y=190
XL2P X=339 Y=177.5
;**
.OP3 ;Drill_Through_7.5(12)
;**
XB X=316.652 Y=187.348 Z=0 T=8 V=4000 F=1
XB X=336.348 Y=187.348 Z=0 T=8 V=4000 F=1
XB X=336.348 Y=167.652 Z=0 T=8 V=4000 F=1
XB X=316.652 Y=167.652 Z=0 T=8 V=4000 F=1
XN X=612 Y=0

I just used a Milling bit (107) and a drilling one (8).
BZ=6 is the thickness of the spoilboard. The "DX=2440 DY=1220 DZ=15" are the raw material dimensions to cut from.
SCM.js
(1.91 KiB) Downloaded 446 times
_BackWall.dxf
(242.58 KiB) Downloaded 469 times
Last edited by Dacicusan on Tue Feb 01, 2022 1:12 pm, edited 1 time in total.

Dacicusan
Active Member
Posts: 49
Joined: Sat Oct 14, 2017 1:44 am

Re: CAM output text formatting?

Post by Dacicusan » Tue Feb 01, 2022 1:10 pm

And here is the output from SCM Maestro if I import the dxf file:

Code: Select all

H DX=2440.000 DY=1220.000 DZ=15.000 -EH C=0 T=16973824 R=1 *MM /"def" BX=0.000 BY=0.000 BZ=6.000 V=0
;
; >> Definizione di variabili ed espressioni
;**
; >> Post P. Release...
;Versione : 1.00.015.1010;
; >> Descrizione del programma...
; Data di creazione: 2/1/2022 12:07:47 PM
;
; >> Utensili utilizzati...
;
; >> Inizio Programma...
;**
;Setup del pezzo Piece sulla fase Setup
REF DX=2440.000 DY=1220.000 DZ=15.000 FLD=EH BX=0.000 BY=0.000 BZ=0.000
;**
;**
.OP1 ;Cut_Through
;**
F=1
O X=0.000 Y=0.000 Z=0.000 F=1 ;ChangePlane
SET ZFAST=20.000
XG0 X=765.000 Y=325.000 Z=15.200 T=107 P=0 D=20 C=1 E=1 s=0
XL2P X=5.000 Y=325.000 Z=15.200 V=4000
XL2P X=5.000 Y=1215.000 Z=15.200 V=4000
XL2P X=1525.000 Y=1215.000 Z=15.200 V=4000
XL2P X=1525.000 Y=325.000 Z=15.200 V=4000
XL2P X=765.000 Y=325.000 Z=15.200 V=4000
;**
.OP2 ;Cut_Through(1)
;**
XG0 X=326.500 Y=1030.000 Z=15.200 T=107 P=0 D=20 C=1 E=1 s=0
XL2P X=339.000 Y=1030.000 Z=15.200 V=4000
XL2P X=339.000 Y=1055.000 Z=15.200 V=4000
XL2P X=314.000 Y=1055.000 Z=15.200 V=4000
XL2P X=314.000 Y=1030.000 Z=15.200 V=4000
XL2P X=326.500 Y=1030.000 Z=15.200 V=4000
;**
.OP3 ;Drill_Through_7.5
;**
XB X=316.652 Y=1032.652 Z=15.200 T=008 G=1 V=4000.000 S=8000.000
;**
.OP4 ;Drill_Through_7.5(1)
;**
XB X=336.348 Y=1032.652 Z=15.200 T=008 G=1 V=4000.000 S=8000.000
;**
.OP5 ;Drill_Through_7.5(2)
;**
XB X=336.348 Y=1052.348 Z=15.200 T=008 G=1 V=4000.000 S=8000.000
;**
.OP6 ;Drill_Through_7.5(3)
;**
XB X=316.652 Y=1052.348 Z=15.200 T=008 G=1 V=4000.000 S=8000.000
PARK S=0
;**
.END
;**
;FINEPROG

CVH
Premier Member
Posts: 3416
Joined: Wed Sep 27, 2017 4:17 pm

Re: CAM output text formatting?

Post by CVH » Tue Feb 01, 2022 2:04 pm

Line 12 should read:

Code: Select all

    this.registerVariable("xPosition", "X", false, "X=", "DEFAULT", "DEFAULT");
add also:

Code: Select all

    this.registerVariable("yPosition", "Y", false, "Y=", "DEFAULT", "DEFAULT");
    this.registerVariable("zPosition", "Z", false, "Z=", "DEFAULT", "DEFAULT");
That should export XYZ values as X=... Y=... and so on.

I also see that standard G-code F for feed isn't used ...
So also include:

Code: Select all

    this.registerVariable("feedRate",            "F",                    false, "V=", 0);
    this.registerVariable("plungeRate",          "FP",                   false, "V=", 0);
Feeds would than be exported as V=....
Look up in GCodeBase.js what can by 'translated' further.
Don't edit that file, include it in yours :!:

Line 35-36 should read:

Code: Select all

    this.rapidMove =                 "XG0 [X] [Y]";
    this.rapidMoveZ =                 "XG0 [Z]";
That uses your 'XG0' format instead of the standard 'G0'.
The prefixes for XYZ are handled above. :wink:

It is not common to do a G0 move to a coordinate with Z.
One usually moves up to safety height and then moves in the XY plane.
Plunging down is usually a G1 move or a combination of G0 and G1.

But in fact, what you need is not standard G-code at all.
I can't help you with what 'XL2P' would be.
'XB' looks like drilling. In G-code that is G0 to XY, G0 to clearance level, G1 to drill, G0 to withdraw ...
Or using canned cycles e.g. G81/82 ...

Bottom line ... Your machine is programmed using macros.
These macros are internally translated in G-codes. :wink:

Can it handle G-codes in direct :?:
Probably it will ... 8)

Regards,
CVH

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

Re: CAM output text formatting?

Post by Claudiosp » Sat Sep 10, 2022 1:32 pm

HI
Look this.
Attachments
SCM.js
(2.89 KiB) Downloaded 326 times

Post Reply

Return to “QCAD/CAM”