Jump to content

Welcome to eMastercam

Register now to participate in the forums, access the download area, buy Mastercam training materials, post processors and more. This message will be removed once you have signed in.

Use your display name or email address to sign in:

Split up O-9999 programs on Fanuc


Corey Hampshire
 Share

Recommended Posts

Good morning all. I was wondering if any one had a better way to do this. I needed to backup a machine today, and punched out O-9999 to dump all the files. Process creates one single file with all of the programs listed in one file. 

Does anyone know of any apps or programs that can take the O-9999 file and split the individual files out and create separate files?  I find it very time consuming and tedious to punch them all out one by one. There has to be a way to dump them all out together and split them out on my pc.

Link to comment
Share on other sites

I do it manually as well, but when you are backing up 89 programs (today) it sure would be nice to have an automated solution for this. The other way around it is copy them out one by one and save them individually. Pick your poison I guess....stand at the machine and do them one by one, or walk back to the office and do them one by one on the pc.

Link to comment
Share on other sites

You are just reading through a large file and finding a ‘O’ program numbers.
Then wanting to save just the NC code between each ‘O’ and ‘M30’ (or ‘M99’) that denotes the end of the NC program,
and write just those sections of NC code out to separate files using the 'O' program numbers for the output filenames?
I may be missing something here? As that sounds like a simple utility to create. 
Can I see a example of the file you wish to breakup?   sdk[at]Mastercam[dot]com
 

  • Like 1
Link to comment
Share on other sites
36 minutes ago, Roger Martin from CNC Software said:

You are just reading through a large file and finding a ‘O’ program numbers.
Then wanting to save just the NC code between each ‘O’ and ‘M30’ (or ‘M99’) that denotes the end of the NC program,
and write just those sections of NC code out to separate files using the 'O' program numbers for the output filenames?
I may be missing something here? As that sounds like a simple utility to create. 
Can I see a example of the file you wish to breakup?   sdk[at]Mastercam[dot]com
 

Sample file sent.

Thanks Roger!

Ideally, we'd get "output" from the program where each "program section file" would be named "Oxxxx", where the x's = the actual O-Number from the output file...

Link to comment
Share on other sites

Colin,

I put together a utility that works as described.

image.png.e6d1b716c9961afce62760898be17fd3.png

Then you threw me a curve with your file, as it has code lines before the initial 'O' program number.

I need to rework the breakup logic. I'll hopefully have something for you tomorrow.

%
&F=//CNC_MEM/
&F=/MTB1/
&F=/MTB2/
&F=/SYSTEM/
&F=/USER/
&F=/USER/LIBRARY/
O9630(S.DATUM--FWB-4S4)

  • Like 2
Link to comment
Share on other sites

Colin,

Do you know what parameter it is to output an "O" instead of a : when transferring files out? We have some machines that output a : and some machines that output a O. I would like them to all be the same especially if Roger is going through the trouble to write us an application to sort this stuff. If not, I could always find and replace to take care of it. This is on a Fanuc 18 by the way.

Link to comment
Share on other sites
16 hours ago, Roger Martin from CNC Software said:

Colin,

I put together a utility that works as described.

image.png.e6d1b716c9961afce62760898be17fd3.png

Then you threw me a curve with your file, as it has code lines before the initial 'O' program number.

I need to rework the breakup logic. I'll hopefully have something for you tomorrow.

%
&F=//CNC_MEM/
&F=/MTB1/
&F=/MTB2/
&F=/SYSTEM/
&F=/USER/
&F=/USER/LIBRARY/
O9630(S.DATUM--FWB-4S4)

Thanks Roger! That is awesome.

Technically, any line that starts with an Ampersand Character can simply be ignored. These are the Fanuc File Paths, where the utility scanned the control, and just gives you a basic "directory" list. However, there is no flag present in the actual text file, to "map" the particular files to a given folder. So again, we can simply "toss away" those lines of text.

 

2 hours ago, Corey Hampshire said:

Colin,

Do you know what parameter it is to output an "O" instead of a : when transferring files out? We have some machines that output a : and some machines that output a O. I would like them to all be the same especially if Roger is going through the trouble to write us an application to sort this stuff. If not, I could always find and replace to take care of it. This is on a Fanuc 18 by the way.

I don't know that particular parameter number Corey, so you'd need to reach out to Fanuc, or dig inside the Fanuc Operator's Manuals. I think there are about 6,000 pages, between the three volumes of the Fanuc 31i-B5 Operator's Manual.

Link to comment
Share on other sites

I use a text editor called UltraEdit that you can make macros.  This one should be easy.

It's an editor mainly used by software developers so much of it is overkill for G-code but we use it to convert old G-code files from previous cam systems to run on our Haas mills. 

Ultracompare is the companion software for comparing text files.

  • Like 3
Link to comment
Share on other sites

I've sent Colin a copy of this newly created utility.
We'll let him try it out to see if it's good, and if others want it, I can make it available after next week.
*This is not an official CNC Software item, and thus receives no official support from CNC.

What this utility does appears to be something similar to what user Elvincnc showed.
[This utility works on code "lines", not a mass of run-on code as Elvincnc showed.]

You can specify the Program Number character* to find/split on.
You can specify the file extension for the output files.

*If you use something like ":" it will work.
But, that is not a valid character for a file name.
It will fallback to using "O" instead of an invalid character in the output file names.

image.png.5cd3d0fdf3fe1fcd85d474725a9d255d.png

This is a stand-alone program that does not require Mastercam.

It remembers and recalls the last setting used each time it is run.


 

  • Thanks 1
  • Like 6
Link to comment
Share on other sites
6 hours ago, Roger Martin from CNC Software said:

I've sent Colin a copy of this newly created utility.
We'll let him try it out to see if it's good, and if others want it, I can make it available after next week.
*This is not an official CNC Software item, and thus receives no official support from CNC.

What this utility does appears to be something similar to what user Elvincnc showed.
[This utility works on code "lines", not a mass of run-on code as Elvincnc showed.]

You can specify the Program Number character* to find/split on.
You can specify the file extension for the output files.

*If you use something like ":" it will work.
But, that is not a valid character for a file name.
It will fallback to using "O" instead of an invalid character in the output file names.

image.png.5cd3d0fdf3fe1fcd85d474725a9d255d.png

This is a stand-alone program that does not require Mastercam.

It remembers and recalls the last setting used each time it is run.


 

I think we're close Roger! I've sent you some feedback, but it looks like you may be off through next week for some well-deserved vacation time. Enjoy it in good health with your family, and let's touch base when you are back.

Thanks so much for doing this!

Best regards,

Colin

  • Like 3
Link to comment
Share on other sites
On 11/18/2021 at 10:22 AM, Corey Hampshire said:

Good morning all. I was wondering if any one had a better way to do this. I needed to backup a machine today, and punched out O-9999 to dump all the files. Process creates one single file with all of the programs listed in one file. 

Does anyone know of any apps or programs that can take the O-9999 file and split the individual files out and create separate files?  I find it very time consuming and tedious to punch them all out one by one. There has to be a way to dump them all out together and split them out on my pc.

Are you wanting the files separated to save individual files that you would prefer to permanently stay in the control?

Link to comment
Share on other sites
22 hours ago, Elvincnc said:

link to the program under the video

Hello. I am the author of the "ALL-PROG.TXT splitter" program. Recently I discovered that the video tutorials for it began to be viewed more often than usual and found this forum.
Slightly improved the algorithm of work and added a version in English. Link to download the new version in the video description. If you come across a bug or have any idea how to improve the program, please let me know.

Prog.png.a6cba50a46fa465a3658f0771617bfbf.png

 

  • Like 4
Link to comment
Share on other sites
19 hours ago, Roger Martin from CNC Software said:

....

[This utility works on code "lines", not a mass of run-on code as Elvincnc showed.]
...

Roger,

That behavior is fairly typical of CNC programs that came from the CNC Control and are opened in Notepad. Open the same file in WordPad, CIMCO Edit, Mastercam Editor, etc... and it reads as one would expect. Notepad does not seem to respect CR/LF

On 11/18/2021 at 3:36 PM, Roger Martin from CNC Software said:

...

%
&F=//CNC_MEM/
&F=/MTB1/
&F=/MTB2/
&F=/SYSTEM/
&F=/USER/
&F=/USER/LIBRARY/
.....

Day late and a dollar short, but, FYI, this is the ALL-PROG.TXT output from a FANUC 30i and 0i-F Series controlled machines. HTH

Link to comment
Share on other sites
On 11/19/2021 at 5:46 AM, Corey Hampshire said:

Colin,

Do you know what parameter it is to output an "O" instead of a : when transferring files out? We have some machines that output a : and some machines that output a O. I would like them to all be the same especially if Roger is going through the trouble to write us an application to sort this stuff. If not, I could always find and replace to take care of it. This is on a Fanuc 18 by the way.

#3201.3 is the parameter. 0 =  ":: and 1 = "O"

  • Like 4
Link to comment
Share on other sites

Here is a c# version of a split up program. To compile open a command prompt and enter "c:\windows\microsoft.net\framework\v4.0.30319\csc.exe SplitNC.cs". You may have to change the command based on the location of the c# compiler but "csc.exe" is on every windows system. To use the program just drag and drop the dumped NC file onto the SplitNC.exe file. It will output O#.NC files using O# or :#.

HTH

using System;
using System.IO;
using System.Text.RegularExpressions;

class program
{    
  static string ProgName;
    static string strLineIn;
    static StreamWriter fileOut;
    static StreamReader fileIn;
    
  static void Main(string[] args)
    {
        ProgName = Regex.Replace(args[0], @"\\","\\\\");
        fileIn = new StreamReader(ProgName);
    fileOut = new StreamWriter("PRE.NC"); // Open for any Lines not in a program
        
        while ((strLineIn = fileIn.ReadLine()) != null)
        {    
            if (strLineIn.Length > 0)
             if ( (strLineIn[0] == 'O') || (strLineIn[0] == ':') ) // If Line starts with O or :
              {
                  fileOut.WriteLine("%"); // Close old Output File
                  fileOut.Close();
                    
                  Match match = Regex.Match(strLineIn,@"^[O:]\d+"); // Get New File Name
                  ProgName = match.Value+".NC";
                  ProgName = Regex.Replace(ProgName, @":","O"); // Change Program Name to start with an O
                    
                    fileOut = new StreamWriter(ProgName); // Open New Output File
                    fileOut.WriteLine("%");
              }                    
            fileOut.WriteLine(strLineIn); // Always Write to an Output File
        }
        fileIn.Close();
        fileOut.Close();
        Console.WriteLine("Done");
        Console.ReadKey();
    }    
}

  • Like 1
Link to comment
Share on other sites
On 11/20/2021 at 8:56 AM, Tim Johnson said:

Are you wanting the files separated to save individual files that you would prefer to permanently stay in the control?

I like to back  them up as individual files on our network. It is  part of our periodic maintenance that  I try and do. At least once a year back programs and parameters up.  That way, when the batteries go dead, or when they move something and they don't hook it back up or someone shorts out a drive, or someone deletes a program,.....or whatever.....I have what I need to get it back up to speed. It's just way easier to dump them out as one program.

 

On 11/20/2021 at 1:25 PM, cncappsjames said:

#3201.3 is the parameter. 0 =  ":: and 1 = "O"

Thanks James, that's what I was  looking for.

  • Like 3
Link to comment
Share on other sites
  • 4 weeks later...

Hello to all! I released a small update of my utility.
1. Added "&F= ..." string handler.
For example, when the line "&F =/USER/CALIBRATION/" is encountered, a folder will be created along the path "OUTPUT FOLDER\USER\CALIBRATION\" and all programs found after this entry will be output to this folder.
2. Fixed several minor bugs.

ALL-PROG_splitter_ENG_20.12.21_19.15.zip

  • Thanks 1
  • Like 2
Link to comment
Share on other sites
  • 11 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.

Join us!

eMastercam - your online source for all things Mastercam.

Together, we are the strongest Mastercam community on the web with over 56,000 members, and our online store offers a wide selection of training materials for all applications and skill levels.

Follow us

×
×
  • Create New...