586,089 active members*
3,862 visitors online*
Register for free
Login
IndustryArena Forum > Community Club House > G-code utility program
Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2013
    Posts
    1

    G-code utility program

    Hi Everyone,

    I thought I'd post a little program I've written that I hope might be useful for people who like to write g-code manually in an environment (like Mach3) that doesn't support flow-of-control statements (other than cumbersome subroutine calls).

    The basic idea is that it's a preprocessor that takes a file with a name like "CAM.txt" and converts it to a modified "CAM.out.txt" in the same directory. CAM.txt can contain standard g-code, enhanced with special for-loop statements. The output file CAM.out.txt will have these statements translated into an explicit form that Mach3 or any other standard interpreter can handle. Here's an example: If CAM.txt contains the following code:

    for z, -.1, -.25, -.1
    G1Z#z
    G1X1
    G0X0
    end

    then the output file will have these lines converted as follows:

    G1Z-.1
    G1X1
    G0X0
    G1Z-.2
    G1X1
    G0X0

    The explicit rules:

    1. The word "for" (lower-case) is followed first by a variable name, which must consist of lower-case letters and digits, starting with a lower-case letter. Within the loop, the variable is referred to by using #, followed by the name. The preprocessor replaces each such reference with a number.

    2. The "for" is followed by a starting value, an end value, and a step, separated by commas. The loop progresses towards the end value, but does not include that value itself. Hence "for x, 1, 2, .5" will cover x=1 and x=1.5 only.

    3. After the step value, one may optionally add an additional, final value, that gets included after all the other values are hit. Accordingly "for x, 1, 2, .5, 1.75" covers x=1, x=1.5, and x=1.75.

    4. A line containing the word "end" brings the block of code to a close. These loops may nest.

    5. The version of Visual Studio this was written with does not permit your original file name to contain spaces (sorry).

    Hope a few people find this useful!

  2. #2
    Join Date
    Jun 2013
    Posts
    4
    Quote Originally Posted by cptpublic View Post
    Hi Everyone,

    I thought I'd post a little program I've written that I hope might be useful for people who like to write g-code manually in an environment (like Mach3) that doesn't support flow-of-control statements (other than cumbersome subroutine calls).

    The basic idea is that it's a preprocessor that takes a file with a name like "CAM.txt" and converts it to a modified "CAM.out.txt" in the same directory. CAM.txt can contain standard g-code, enhanced with special for-loop statements. The output file CAM.out.txt will have these statements translated into an explicit form that Mach3 or any other standard interpreter can handle. Here's an example: If CAM.txt contains the following code:

    for z, -.1, -.25, -.1
    G1Z#z
    G1X1
    G0X0
    end

    then the output file will have these lines converted as follows:

    G1Z-.1
    G1X1
    G0X0
    G1Z-.2
    G1X1
    G0X0

    The explicit rules:

    1. The word "for" (lower-case) is followed first by a variable name, which must consist of lower-case letters and digits, starting with a lower-case letter. Within the loop, the variable is referred to by using #, followed by the name. The preprocessor replaces each such reference with a number.

    2. The "for" is followed by a starting value, an end value, and a step, separated by commas. The loop progresses towards the end value, but does not include that value itself. Hence "for x, 1, 2, .5" will cover x=1 and x=1.5 only.

    3. After the step value, one may optionally add an additional, final value, that gets included after all the other values are hit. Accordingly "for x, 1, 2, .5, 1.75" covers x=1, x=1.5, and x=1.75.

    4. A line containing the word "end" brings the block of code to a close. These loops may nest.

    5. The version of Visual Studio this was written with does not permit your original file name to contain spaces (sorry).

    Hope a few people find this useful!
    Thanks for the information mate. It is really helpful. i am new in CNC machine business and love to get more and more information.



    Cariblue | Strategic Planning Consultant

Similar Threads

  1. CNC utility/program? discs- Magnaturn 1220
    By pete S in forum Want To Buy...Need help!
    Replies: 2
    Last Post: 02-17-2022, 10:48 PM
  2. Mazatrol Program into a G Code Program
    By fuzzman in forum Mazak, Mitsubishi, Mazatrol
    Replies: 15
    Last Post: 09-25-2012, 04:27 PM
  3. Does anyone have a utility for this?
    By BFHammer in forum Fanuc
    Replies: 4
    Last Post: 07-25-2011, 10:15 PM
  4. fanuc program code vs. Haas code
    By sixty8frbrd in forum Fanuc
    Replies: 6
    Last Post: 03-11-2011, 04:05 AM
  5. Need a Utility
    By grumpy74 in forum FeatureCAM CAD/CAM
    Replies: 2
    Last Post: 03-11-2006, 04:56 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •