- GCode and Part Programs
- CAD CAM
- PostProcessor or ISO a script to insert M0 for "Z" (Linuxcnc & BobCad v23)
PostProcessor or ISO a script to insert M0 for "Z" (Linuxcnc & BobCad v23)
- new2linux
- Offline
- Platinum Member
-
Less
More
- Posts: 711
- Thank you received: 9
03 Jun 2017 23:19 #94041
by new2linux
PostProcessor or ISO a script to insert M0 for "Z" (Linuxcnc & BobCad v23) was created by new2linux
Many thanks for any help.
I am using (I have a dongle, for convenience) BobCad v23 (it is what it is) and would like to have a pause for change in "Z", this is manually set, on a mill. I have read about "creating a script" and a few other links below, and copied a "EMC2" post processor to the correct place in the bobcad file location (and can select this option, in the list with other postprocessor inside Bobcad), but still not complete.
Any suggested reading or other links. Suggestions would be warmly welcomed. If I have not understood the issue please clue me in. I have read about line 26 set to debug "on", when trying to test/debug posts.
My hope it should be possible to create a script that could automatically insert an M0 code to pause the machine where ever there is a change in Z depth.
(how to modify Bobcad postprocessor)
bash.cyberciti.biz/guide/Hello,_World!_Tutorial (To create a shell script)
Many, many Thanks!
I am using (I have a dongle, for convenience) BobCad v23 (it is what it is) and would like to have a pause for change in "Z", this is manually set, on a mill. I have read about "creating a script" and a few other links below, and copied a "EMC2" post processor to the correct place in the bobcad file location (and can select this option, in the list with other postprocessor inside Bobcad), but still not complete.
Any suggested reading or other links. Suggestions would be warmly welcomed. If I have not understood the issue please clue me in. I have read about line 26 set to debug "on", when trying to test/debug posts.
My hope it should be possible to create a script that could automatically insert an M0 code to pause the machine where ever there is a change in Z depth.
(how to modify Bobcad postprocessor)
bash.cyberciti.biz/guide/Hello,_World!_Tutorial (To create a shell script)
Many, many Thanks!
Please Log in or Create an account to join the conversation.
- Badger
-
- Offline
- Senior Member
-
Less
More
- Posts: 51
- Thank you received: 21
05 Jun 2017 16:32 #94106
by Badger
Replied by Badger on topic PostProcessor or ISO a script to insert M0 for "Z" (Linuxcnc & BobCad v23)
I'm not totally sure but I think that you may be able to just open up your gcode file in a text editor, not a word processor, and do a "search and replace" of the Z lines and replace with M0. You would have to do it for each file but if it works it would only take seconds.
The following user(s) said Thank You: new2linux
Please Log in or Create an account to join the conversation.
- andypugh
-
- Offline
- Moderator
-
Less
More
- Posts: 23279
- Thank you received: 4933
06 Jun 2017 12:24 #94144
by andypugh
Replied by andypugh on topic PostProcessor or ISO a script to insert M0 for "Z" (Linuxcnc & BobCad v23)
It should also be possible to do it automatically as an input filter.
(have Bobcad create files with, for example, a .bob suffix, then LinuxCNC can convert to .ngc)
linuxcnc.org/docs/2.7/html/config/ini-co...html#_filter_section
(have Bobcad create files with, for example, a .bob suffix, then LinuxCNC can convert to .ngc)
linuxcnc.org/docs/2.7/html/config/ini-co...html#_filter_section
The following user(s) said Thank You: new2linux
Please Log in or Create an account to join the conversation.
- new2linux
- Offline
- Platinum Member
-
Less
More
- Posts: 711
- Thank you received: 9
09 Jun 2017 11:43 #94330
by new2linux
Replied by new2linux on topic PostProcessor or ISO a script to insert M0 for "Z" (Linuxcnc & BobCad v23)
andypugh, many thanks, you for the advise!
I have read the link several times is it possible to have something to start with, like a pattern or do I use the example from the link?
This is from the link:
"" #! /usr/bin/env python
import sys
def main(argv):
openfile = open(argv[0], 'r')
file_in = openfile.readlines()
openfile.close()
file_out = []
for line in file_in:
# print line
if line.find('Z') != -1:
words = line.rstrip('\n')
words = words.split(' ')
newword = ''
for i in words:
if i[0] == 'Z':
newword = 'W'+ i[1:]
if len(newword) > 0:
words.append(newword)
newline = ' '.join(words)
file_out.append(newline)
else:
file_out.append(line)
for item in file_out:
print "%s" % item
if __name__ == "__main__":
main(sys.argv[1:]) ""
I have been reviewing some linuxcnc examples like the "nc_files/holecircle.py" (a python script MIME .type of file) and others like the "Skeleton.ngc". The python code was in several colors, is that from the type of file it is or the way it was written? The hal file has the "png=image-to-gcode" plus several other lines under the [FILTER] area of the file, close to the top of page.
As per Bobcad suffix it is a .MILLPST post processor type of file.
many thank, all comments suggestions are warmly welcomed.
I have read the link several times is it possible to have something to start with, like a pattern or do I use the example from the link?
This is from the link:
"" #! /usr/bin/env python
import sys
def main(argv):
openfile = open(argv[0], 'r')
file_in = openfile.readlines()
openfile.close()
file_out = []
for line in file_in:
# print line
if line.find('Z') != -1:
words = line.rstrip('\n')
words = words.split(' ')
newword = ''
for i in words:
if i[0] == 'Z':
newword = 'W'+ i[1:]
if len(newword) > 0:
words.append(newword)
newline = ' '.join(words)
file_out.append(newline)
else:
file_out.append(line)
for item in file_out:
print "%s" % item
if __name__ == "__main__":
main(sys.argv[1:]) ""
I have been reviewing some linuxcnc examples like the "nc_files/holecircle.py" (a python script MIME .type of file) and others like the "Skeleton.ngc". The python code was in several colors, is that from the type of file it is or the way it was written? The hal file has the "png=image-to-gcode" plus several other lines under the [FILTER] area of the file, close to the top of page.
As per Bobcad suffix it is a .MILLPST post processor type of file.
many thank, all comments suggestions are warmly welcomed.
Please Log in or Create an account to join the conversation.
- Todd Zuercher
-
- Offline
- Platinum Member
-
Less
More
- Posts: 4987
- Thank you received: 1455
09 Jun 2017 13:13 - 09 Jun 2017 13:16 #94340
by Todd Zuercher
Replied by Todd Zuercher on topic PostProcessor or ISO a script to insert M0 for "Z" (Linuxcnc & BobCad v23)
The colors are from the text editor that was used to view it. (Some have filters geared towards programming languages.)
I have a bash script that uses sed to automatically convert ordinary XYZ g-code to XYZW code on loading for a two headed carving machine. (It also inserts a pre- and post- amble.)
I have a bash script that uses sed to automatically convert ordinary XYZ g-code to XYZW code on loading for a two headed carving machine. (It also inserts a pre- and post- amble.)
#!/bin/bash
echo "G92.1 G54 G49"
echo "M111"
echo "G53 G0 Z0 W0"
echo "G90"
echo "G64 P0.005"
echo "F80"
echo "M3 S18000"
echo
# The main part
sed 's|Z\([-.0-9]*\)|Z\1 W\1|g' "$1"
echo
echo "G53 G0 Z0 W0"
echo "G53 G0 X0 Y65"
echo "G49 G92.1"
echo "M5"
echo "M30"
echo "%"
Last edit: 09 Jun 2017 13:16 by Todd Zuercher.
The following user(s) said Thank You: new2linux
Please Log in or Create an account to join the conversation.
- new2linux
- Offline
- Platinum Member
-
Less
More
- Posts: 711
- Thank you received: 9
09 Jun 2017 17:10 #94366
by new2linux
Replied by new2linux on topic PostProcessor or ISO a script to insert M0 for "Z" (Linuxcnc & BobCad v23)
Todd,Thanks, so good to here from you!
I have my sheet of g code commands and see how they reflect to the "x,y,z" like g53 (just an example). Am I looking for the bash script, to understand your "echo" or "sed" part? I am looking at bash script now, any other suggested reading?
many thanks
I have my sheet of g code commands and see how they reflect to the "x,y,z" like g53 (just an example). Am I looking for the bash script, to understand your "echo" or "sed" part? I am looking at bash script now, any other suggested reading?
many thanks
Please Log in or Create an account to join the conversation.
- Todd Zuercher
-
- Offline
- Platinum Member
-
Less
More
- Posts: 4987
- Thank you received: 1455
09 Jun 2017 18:07 #94372
by Todd Zuercher
Replied by Todd Zuercher on topic PostProcessor or ISO a script to insert M0 for "Z" (Linuxcnc & BobCad v23)
The echo lines are just inserted at the beginning or end of the file.
The sed line does all the work. finding all of the Z commands and adding an identical W command after it.
I have to be honest I did not write that miraculous line of sed code. Someone else here on the list wrote it for me.
But I have since used some other sed scripts to convert code made for one machine to run on another.
Here is a good tutorial.
www.grymoire.com/Unix/Sed.html
The s in the sed line designates a search and replace, what is between the 1st two pipes (|) is what is searched for, between the 2nd and 3rd pipe is what is replaced back. The parenthesis designates a varialbe in this case a string how ever long of containing 0-9, . and -. The /1 means to insert 1st variable string that was found. The little g at the end designates that it is a global command.
Save the script as a filename.sh and put it in the path called in your ini file.
The script above I have set up to be automatically ran on any file I open with Linuxcnc with the extention ngczw.
The sed line does all the work. finding all of the Z commands and adding an identical W command after it.
I have to be honest I did not write that miraculous line of sed code. Someone else here on the list wrote it for me.
But I have since used some other sed scripts to convert code made for one machine to run on another.
Here is a good tutorial.
www.grymoire.com/Unix/Sed.html
The s in the sed line designates a search and replace, what is between the 1st two pipes (|) is what is searched for, between the 2nd and 3rd pipe is what is replaced back. The parenthesis designates a varialbe in this case a string how ever long of containing 0-9, . and -. The /1 means to insert 1st variable string that was found. The little g at the end designates that it is a global command.
Save the script as a filename.sh and put it in the path called in your ini file.
The script above I have set up to be automatically ran on any file I open with Linuxcnc with the extention ngczw.
The following user(s) said Thank You: new2linux
Please Log in or Create an account to join the conversation.
- Todd Zuercher
-
- Offline
- Platinum Member
-
Less
More
- Posts: 4987
- Thank you received: 1455
09 Jun 2017 18:39 #94374
by Todd Zuercher
Replied by Todd Zuercher on topic PostProcessor or ISO a script to insert M0 for "Z" (Linuxcnc & BobCad v23)
A sed script for your purpose might look something like this
#!/bin/bash
sed 's|\(.*\)Z\([-,0-9,\.]*\)|M0 \1(Z\2)|g' "$1"
The following user(s) said Thank You: new2linux
Please Log in or Create an account to join the conversation.
- new2linux
- Offline
- Platinum Member
-
Less
More
- Posts: 711
- Thank you received: 9
14 Jun 2017 16:37 #94507
by new2linux
Replied by new2linux on topic PostProcessor or ISO a script to insert M0 for "Z" (Linuxcnc & BobCad v23)
Many Thanks for all the great advise!
I have read many parts of the of (www.grymoire.com/Unix/Sed.html) link, thank you Todd! As a complete newbie to "scripts" I am offering my very 1st effort. All constructive comments warmly welcomed.
[FILTER]
PROGRAM_EXTENSION = .png,.gif,.jpg Greyscale Depth Image
PROGRAM_EXTENSION = .py Python Script
png = image-to-gcode
gif = image-to-gcode
jpg = image-to-gcode
py = python
###################################################
#!/bin/bash
echo "G92.1 G54 G49"
echo "M111"
echo "G53 G0 Z0 W0"
echo "G90"
echo "G64 P0.005"
echo "F80"
echo "M3 S18000"
echo
# The main part
sed 's|\(.*\)Z\([-,0-9,\.]*\)|M0 \1(Z\2)|g' "$1"
echo
echo "G53 G0 Z0 W0"
echo "G53 G0 X0 Y65"
echo "G49 G92.1"
echo "M5"
echo "M30"
echo "%"
#################################################
I tried this with the sample "g code" and all worked except the "z" did not pause. I have read there may need to be some permissions "granted" so the file is loaded. The very top part was in the .hal file all ready.
Many thanks!
I have read many parts of the of (www.grymoire.com/Unix/Sed.html) link, thank you Todd! As a complete newbie to "scripts" I am offering my very 1st effort. All constructive comments warmly welcomed.
[FILTER]
PROGRAM_EXTENSION = .png,.gif,.jpg Greyscale Depth Image
PROGRAM_EXTENSION = .py Python Script
png = image-to-gcode
gif = image-to-gcode
jpg = image-to-gcode
py = python
###################################################
#!/bin/bash
echo "G92.1 G54 G49"
echo "M111"
echo "G53 G0 Z0 W0"
echo "G90"
echo "G64 P0.005"
echo "F80"
echo "M3 S18000"
echo
# The main part
sed 's|\(.*\)Z\([-,0-9,\.]*\)|M0 \1(Z\2)|g' "$1"
echo
echo "G53 G0 Z0 W0"
echo "G53 G0 X0 Y65"
echo "G49 G92.1"
echo "M5"
echo "M30"
echo "%"
#################################################
I tried this with the sample "g code" and all worked except the "z" did not pause. I have read there may need to be some permissions "granted" so the file is loaded. The very top part was in the .hal file all ready.
Many thanks!
Please Log in or Create an account to join the conversation.
- Todd Zuercher
-
- Offline
- Platinum Member
-
Less
More
- Posts: 4987
- Thank you received: 1455
14 Jun 2017 17:56 - 14 Jun 2017 18:02 #94508
by Todd Zuercher
Replied by Todd Zuercher on topic PostProcessor or ISO a script to insert M0 for "Z" (Linuxcnc & BobCad v23)
Did you add the above to your ini file?
What you need to do is save the bash script as a file (file_name.sh). Save it in a good place (such as your machine's config folder)
After you've moved the file where it goes, in a file manager, right click on the script file, select properties, then permissions, and click the box for "Allow this file to run as a program".
Then in your ini file under the [FILTER] section add a line referencing it.
For example if your script is saved as "z-pause.sh" in your config dir and your config dir is called "my_mill" you would add this line to run the script on all files you open with Linuxcnc that end with the extension ".ngc"You can also control what files the script is ran on by the extension. Lets say you want all ngc files to be opened normally, but want all files with the extension ".ncz" to be opened using the script.
Make your [FILTER] section look like this.
Also, does your machine have an M111 custom m-code configured? If not you'll need to take that out.
And that particular script won't quite work on the default file that opens with Linuxcnc. The problem is that parameter values are used for the Z depth in many places, and those won't be replaced by that script.
But it should work fine for most "normal" files that just have a number for Z moves.
What you need to do is save the bash script as a file (file_name.sh). Save it in a good place (such as your machine's config folder)
After you've moved the file where it goes, in a file manager, right click on the script file, select properties, then permissions, and click the box for "Allow this file to run as a program".
Then in your ini file under the [FILTER] section add a line referencing it.
For example if your script is saved as "z-pause.sh" in your config dir and your config dir is called "my_mill" you would add this line to run the script on all files you open with Linuxcnc that end with the extension ".ngc"
[FILTER]
PROGRAM_EXTENSION = .png,.gif,.jpg Greyscale Depth Image
PROGRAM_EXTENSION = .py Python Script
png = image-to-gcode
gif = image-to-gcode
jpg = image-to-gcode
py = python
ngc = ~/linuxcnc/configs/my_mill/z-pause.sh
Make your [FILTER] section look like this.
[FILTER]
PROGRAM_EXTENSION = .png,.gif,.jpg Greyscale Depth Image
PROGRAM_EXTENSION = .py Python Script
PROGRAM_EXTENSION = .ngc,.ncz G-Code
png = image-to-gcode
gif = image-to-gcode
jpg = image-to-gcode
py = python
ncz = ~/linuxcnc/configs/my_mill/z-pause.sh
Also, does your machine have an M111 custom m-code configured? If not you'll need to take that out.
And that particular script won't quite work on the default file that opens with Linuxcnc. The problem is that parameter values are used for the Z depth in many places, and those won't be replaced by that script.
But it should work fine for most "normal" files that just have a number for Z moves.
Last edit: 14 Jun 2017 18:02 by Todd Zuercher.
The following user(s) said Thank You: new2linux
Please Log in or Create an account to join the conversation.
- GCode and Part Programs
- CAD CAM
- PostProcessor or ISO a script to insert M0 for "Z" (Linuxcnc & BobCad v23)
Time to create page: 0.109 seconds