Can I use the post to insert a user defined line in the Gcode outputfile?

Can I use the post to insert a user defined line in the Gcode outputfile?

zigzag2015
Advocate Advocate
487 Views
7 Replies
Message 1 of 8

Can I use the post to insert a user defined line in the Gcode outputfile?

zigzag2015
Advocate
Advocate

Hi,

I have recently started to use a four axis Mach4 post and I have found need to insert a single line of code into the Gcode file, either at the top or near so. I have tried putting in a comment, an option within the post, and that does

insert a line, but in parentheses as a comment. Is there a means of inserting a line but without the parentheses?

 

Thanks

Craig

0 Likes
Accepted solutions (3)
488 Views
7 Replies
Replies (7)
Message 2 of 8

a.laasW8M6T
Mentor
Mentor
Accepted solution

you can add the pass through  function to your postprocessor:

pass through.png

 

then use  pass through in the manual NC command:

passythru.png

 

But if this line needs to be added to your program everytime it would be better to hard code it into the post processor so it does it automatically.

 

What line of code do you need to add?

0 Likes
Message 3 of 8

zigzag2015
Advocate
Advocate

Hi,

thanks for the reply.

 

In the first instance I will try the Pass Through command.

 

Do I understand correctly that I need to place the function  in the post....and then the function  will become available in the drop down menu?

 

The code I wish to insert in the Gcode file is very simple:

m199()

Just the one line, it calls a macro within Mach4 to populate some registers that correspond to a safe location in relation to the part. My intention is that it will be in every four axis Gcode file I produce and would probably be best handled by a modification to the post such that it's included automatically.

 

In the first instance however I think using the manual Pass Through might be better at least until I understand the implications of it, and maybe refine the code somewhat.

0 Likes
Message 4 of 8

a.laasW8M6T
Mentor
Mentor
Accepted solution

The pass through option is always there for manual NC, but if it isn't implemented in the post if just won't do anything.

 

You just add that section of code to the very bottom of the post and then pass through will work, note the warnings about pass through though(it will put ANYTHING you write in the code which could inadvertently cause a crash)

 

 

You could add something like 

if(!is3D()){
    writeBlock("M199()");
}

 

and add that to the appropriate place in the onOpen function to place it where you want.

 

3d.png

 

that will only add the M199 line to multiaxis programs

and 3 axis will not have it

0 Likes
Message 5 of 8

zigzag2015
Advocate
Advocate

Hi,

kool, I'll try it out tomorrow.

 

I've never had to really deal with any code in a post. Is there a primer for how the post is composed and maybe some of the syntax used?

 

Thanks

Craig

0 Likes
Message 6 of 8

a.laasW8M6T
Mentor
Mentor
0 Likes
Message 7 of 8

zigzag2015
Advocate
Advocate

Holy Snapping Duck **** Batman.....I asked and I got! That'll keep me occupied for a week minimum.

 

Craig

0 Likes
Message 8 of 8

zigzag2015
Advocate
Advocate
Accepted solution

Hi, 

the function onPassThrough(text) works a treat. Thanks.

 

The link to the Post Processor Training Guide is also excellent.

 

Thanks Craig

0 Likes