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:

adding / editing tool comments


Recommended Posts

I did a search and didn't find what I was looking for. I've edited posts a bit and have a basic understanding... but assume I know nothing.

 

At the start of my G-code program, I get the program header ( everything there looks like I want it to ) then it goes into a G20 and setting default codes. G40 G80 etc.

 

Between the start comments ( date, time etc. ) and the start of the tool ( G20, G80 etc. ) the tools are listed. I want to edit them because the comment it soooo long giving too many details. then I want to add the tool comments at tool changes. I want to see the tool comment when I start that tool just to make sure when tool 12 is a 1/2 endmill, that I see the comment and can look in the machine to make sure before running.

 

I told one of our new machinists that was into rap music.... YOU NEED TO CHECK YOURSELF BEFORE YOU WRECK YOURSELF

 

so, I like to have a double check before running the tool.

 

Anyway, thanks for the help. Dan

Link to comment
Share on other sites

I figured out how to change the tool comment to post in the header and before each tool...

 

this part in the post...

 

tool_info    : 3     #Output tooltable information?
                     #0 = Off - Do not output any tool comments or tooltable
                     #1 = Tool comments only
                     #2 = Tooltable in header - no tool comments at T/C
                     #3 = Tooltable in header - with tool comments at T/C

 

It was set on tool info :2 and I changed it to 3 to get the comment in the header and before each tool.

 

 

 

Now to adjust what info is in the tool comment

Link to comment
Share on other sites

There are two different post blocks that generate the output for the Tool Table, and the Tool Comments (at tool change).

 

The names of the blocks are 'ptoolcomment' and 'ptooltable'. These are the "start" of the block that will output that comment to the NC file while the post is running.

 

When you open a PST file and read through it in a text editor, there are a bunch of different sections. Much like a "subprogram" on a machining center, the code in the PST file makes many "jumps" to different locations inside the post. Some of the sections output data to the NC file, when they are called at the right moment.

 

The mechanism that triggers when a block is "called" is the NCI file. The NCI file is the "generic tool data and tool path motion" that is created by your operations when you post them.

 

The NCI file is organized as a "script", to be read in by the Post Processor as "input". The job of the Post file is to take that input and generate NC code "output" that is formatted for your specific machine and personal preferences.

 

The NCI file is read two lines at a time, and based on the value in the first line (this is the NCI "Gcode" value), a specific post block (chunk of script code in the PST file) is called. This is the "Entry" post block, and determines how the data on the next line of the NCI file is read. The 2nd NCI line is the "data" line, and it is read by MP during posting. MP reads each parameter on this line and assigns the parameter to a "pre-defined" variable. Most of the time, each line of NCI code produces output when you are processing "motion". (G0, G1, G2, G3). However, there are a bunch of NCI lines that are "preparatory". They set the values of Pre-Defined variables prior to the Tool Change event. Then the Tool Change happens, and the motion for the path is processed.

 

When you read the PST file, it is broken up into "chunks" of script code called a "post block". The thing that designates a "Post block" is that the Post block name starts with a "p" (or "l" or "m"), and it must start in the first column. All other code inside the post block must be indented (has to have space characters in front of the code). In fact, having another post block name or variable declaration is what "ends" the post block above the new post block name.

 

What you need to do is learn how to edit the code in the two post blocks I mentioned above: ptoolcomment and ptooltable. You can add or remove data, and change the formatting of the comment to your heart's content.

Link to comment
Share on other sites

In your post go find this:

 

# --------------------------------------------------------------------------
# Tool Comment / Manual Entry Section
# --------------------------------------------------------------------------
ptoolcomment    #Comment for tool
      tnote = t$, toffnote = tloffno$, tlngnote = tlngno$
      if tool_info = 1 | tool_info = 3,
        sopen_prn, pstrtool, sdelimiter, *tnote, sdelimiter, *toffnote, sdelimiter, *tlngnote, sdelimiter, *tldia$, sclose_prn, e$
 

Which gives you this:

 

( T1 |  3/16 FLAT ENDMILL | H1 | D1 | WEAR COMP | TOOL DIA. - .1875 | XY STOCK TO LEAVE - .0025 | Z STOCK TO LEAVE - 0. )
( T2 |  5/32 FLAT ENDMILL | H2 | D2 | WEAR COMP | TOOL DIA. - .15625 )
( T3 |  1/4 CHAMFER MILL | H3 | D3 | WEAR COMP | TOOL DIA. - .25 )

 

Change it to something like this:

 

# --------------------------------------------------------------------------
# Tool Comment / Manual Entry Section
# --------------------------------------------------------------------------
ptoolcomment    #Comment for tool
      tnote = t$, toffnote = tloffno$, tlngnote = tlngno$
      if tool_info = 1 | tool_info = 3,
        sopen_prn, t$, pstrtool,tldia$, sclose_prn, e$

 

Which will give you something like this:

 

( T1  3/16 FLAT ENDMILL / DIA .1875 / D1 / WEAR )
( T2  5/32 FLAT ENDMILL / DIA .15625 / D2 / WEAR )
( T3  1/4 CHAMFER MILL / DIA .25 / D3 / WEAR )

 

Also need to play with:

 

# --------------------------------------------------------------------------
fmt "TOOL - "      4   tnote    #Note format
fmt "DIA. OFF. - " 4   toffnote #Note format
fmt "LEN. - "      4   tlngnote #Note format
fmt "TOOL DIA. - " 1   tldia$   #Note format
fmt "XY STOCK TO LEAVE - " 2  xy_stock #Note format
fmt "Z STOCK TO LEAVE - "  2  z_stock  #Note format

 

To get the comments to read as you like.

 

From one who barely understands the posts to another. Hope this helps. :thumbsup:

Link to comment
Share on other sites
  • 10 months later...

Hello guys,

I hope I'm posting this in the right place. I've read a bunch of stuff here and I have my comments almost perfect for how I want them.

However, my first Tool Comment (1008) is 2 lines in mastercam but only the second line is posted out. On tools other than the first, it works OK.

I'm using X9 and a modified MPOkuma.pst

This is what I get at the beginning of the program after the header:

 
G0 G40 G80 G90
IF [VTLCN EQ 1] N1
T1 M6
N1
( T-1  H-1  D-1  DIA-3.  -  3" FACE MILL   )
( H11 RIGHT VISE )
G15 H01
G0 G90 X4.775 Y-.7875
S3500 M3 T2
G56 H1 Z2.
 
And this is further down in the program:
 
IF [VTLCN EQ 6] N6
T6 M6
N6
/ T6 M6 (BLOCK SKIP ON FOR OKUMA MX)
( T-6  H-6  D-6  DIA-.25  -  1/4 CHAMFER MILL   )
( H6 LEFT VISE )
( H16 RIGHT VISE )
G15 H01
 
The first section of code should have ( H1 LEFT LEFT VISE ) right above the ( H11 RIGHT VISE )
 
Here are the relevant sections from my post:
 
# Start of File and Toolchange Setup
# --------------------------------------------------------------------------

header   : 0     #Header flag variable for comment processing
sop_comm : ""    #String variable for saved operation comment

ptime           #Convert 24-hour time format into 12-hour AM/PM format
      if time$ >= 13, time2 = (time$ - 12)
      else, time2 = time$
      hour = int(time2), min = frac(time2)
      *hour, ":", *min,
      if time$ > 12, " PM"
      else, " AM"

pheader$         #Call before start of file                         
      header = one
      #"%", e$
      sav_spc = spaces$
      spaces$ = 0
      #*progno$, sopen_prn, sspace, sprogname$, sspace, sclose_prn, e$
      sopen_prn, sspace, sprogname$, sspace, sclose_prn, e$
      #sopen_prn, sspace, "PROGRAM NAME - ", sprogname$, sspace, sclose_prn, e$
      "(PROGRAMMED CENTERLINE OF TOOL)", e$
      "(FULL SIZE TOOLS HAVE -0- IN D RAD COMP)", e$
      "(BLOCK SKIP ON FOR OKUMA MX-45VAE)", e$
      #sopen_prn, sspace, "DATE=DD-MM-YY - ", date$, " TIME=HH:MM - ", time$, sspace, sclose_prn, e$ #Date and time output Ex. 12-02-05 15:52
      #sopen_prn, sspace, "DATE - ", month$, "-", day$, "-", year$, sspace, sclose_prn, e$  #Date output as month,day,year - Ex. 02-12-05
      sopen_prn, sspace, *smonth, " ", day$, " ", *year2, sspace, time$, sspace, sclose_prn, e$ #Date output as month,day,year - Ex. Feb. 12 2005
      #sopen_prn, sspace, "TIME - ", time$, sspace, sclose_prn, e$  #24 hour time output - Ex. 15:52
      #sopen_prn, sspace, "TIME - ", ptime, sspace, sclose_prn, e$  #12 hour time output 3:52 PM
      #spathnc$ = ucase(spathnc$)
      #smcname$ = ucase(smcname$)
      #stck_matl$ = ucase(stck_matl$)
      snamenc$ = ucase(snamenc$)
      #sopen_prn, sspace, "MCX FILE - ", *smcpath$, *smcname$, *smcext$, sspace, sclose_prn, e$
      #sopen_prn, sspace, "NC FILE - ", *spathnc$, *snamenc$, *sextnc$, sspace, sclose_prn, e$
      #sopen_prn, sspace, "MATERIAL - ", *stck_matl$, sspace, sclose_prn, e$
      spaces$ = sav_spc
      comment$
      header = zero

psof0$           #Start of file for tool zero                        
      psof$

psof$            #Start of file for non-zero tool number             
      pcuttype
      toolchng = one
      if ntools$ = one,
        [
        #skip single tool outputs, stagetool must be on
        stagetool = m_one
        !next_tool$
        ]

      pbld, n$, *sgcode, "G40", "G80", *sgabsinc, e$
      sav_absinc = absinc$
      #if stagetool >= zero, pbld, n, *t$, e$

      spaces$=0
      okuma_skip_toolnumber = t$
      pbld, n$, "IF [VTLCN EQ ", *okuma_skip_toolnumber, "] ", *n$, e$
      spaces$=sav_spc
      n$ = n$ - seqinc$
      pbld, n$, *t$, "M6", e$
      #pbld, n$, "M6", e$
      #t_nt = t$
      pbld, *n$, e$


      #pbld, n$, *t$, "M6", e$
      ptoolcomment
      if sop_comm <> sblank, sopen_prn, sop_comm, sclose_prn, e$ #Output saved operation comment
      if mi1$ <= one, #Work coordinate system
        [
        absinc$ = one
      #####  pfbld, n, sgabsinc, *sg28ref, "Z0.", e
      #####  pfbld, n, *sg28ref, "X0.", "Y0.", e
      #####  pfbld, n, "G92", *xh, *yh, *zh, e
        absinc$ = sav_absinc
        ]
      else, pwcs,e$

This is my first post, so I apologize for not getting the format correct.

On our Okumas it is common to use different height offsets for different work offsets. I haven't been able to come up with a better way that the boss will accept.

But I would like to be able to easily note the changes in the program as I did successfully with T6 in the above example.

Any help at all would be greatly appreciated.

Thank you

Jeff 

 

Link to comment
Share on other sites

There is code in your post (pcomment2) for "saving" the operation comment. (1008 line)

 

This is saved in a single variable, and what is happening is that you've got 2 - 1008 lines to process.

 

So the post saves the first line, then overwrites the variable when it processes the 2nd line of data.

 

You need to use a String Buffer to capture the multiple lines during Header processing, and then output the data in 'psof$'...

Link to comment
Share on other sites
  • 2 weeks later...

Back in '92 I had a guy explain a few things to me about editing a post on Cadkey 5 with Cutting Edge4. Everything since then has been trial and error.

This one might just be above what I can do. I've spent all my "free" time the past couple of weeks trying to figure out string buffers and maybe it's just beyond me.

All I have come up with is something like:

# --------------------------------------------------------------------------
# Buffer definitions
# --------------------------------------------------------------------------
#Buffer 9, output strings for testing
wc9          : 1     #Initial count for write buffer 9
rc9          : 1     #Initial count for read buffer 9
size9        : 0     #Buffer 9 size
string9      : ""    #Buffer 9
fbuf 9 0 255 0 1     #Buffer 9

Maybe that will work to define a buffer (and maybe not)

But how would I get gcode 1008 into it and how then would I pull that back out where I want it?

Is it something like string9 = gcode 1008 and then pwritebuffer_9?

I'm not trying to get you all to just give me an easy answer. I really have tried to figure this out.

If you think this is just too advanced for me then let me know.

Thanks,

Jeff

Link to comment
Share on other sites

Hi Jeff,

 

You're on exactly the right track. I always like helping someone that is willing to put in the work, which you are doing nicely.

 

You've defined the buffer correctly. Now you just need to store the data during comment processing, and recall it properly.

 

Post up your 'pcomment2' post block. That is where we need to store the data into the buffer.

 

Then, since this issue is only at the "start of file", we'll modify the output to count the number of lines in the buffer, and output them both.

Link to comment
Share on other sites

To answer your question on "how do we store information into the buffer file", I will answer that.

 

Data is stored into a String Buffer by setting the string you want to write, and using the 'wbuf' function.

 

pcomment2
     if gcode$ = 1008,
        [
        if header = 1,
          [
          string9 = scomm$
          string9 = wbuf (9, wc9)
          ]
        else, pbld, n$, scomm$, e$
        ]
Link to comment
Share on other sites

Thank you Colin :)

Almost there. I had to add the parenthesis for the op comments later on in the program.

The comment is no longer showing up in the wrong place in between the header and the tool table, but it's not showing up after the tool comment after the first tool change either.

I've got 3 machines that are just about to finish up their jobs so I'll be busy setting up most of the rest of the day :/

Here is ( I think ) all of the relevant code so far:

# --------------------------------------------------------------------------
# Buffer definitions
# --------------------------------------------------------------------------
#Buffer 9, output strings for testing
wc9          : 1     #Initial count for write buffer 9
rc9          : 1     #Initial count for read buffer 9
size9        : 0     #Buffer 9 size
string9      : ""    #Buffer 9
fbuf 9 1 255 0 1     #Buffer 9

# --------------------------------------------------------------------------
# Tool Comment / Manual Entry Section
# --------------------------------------------------------------------------
ptoolcomment    #Comment for tool
      tnote = t$
      toffnote = tloffno$
      tlngnote = tlngno$
      "(", *tnote, *tlngnote, *toffnote, *tldia$," - ", pstrtool, ")", e$
      if tool_info = 1 | tool_info = 3,
        "(", pstrtool, sdelimiter, *tnote, sdelimiter, *toffnote, sdelimiter, *tlngnote, ")", e$

ptooltable      #Tooltable output 999
      sopen_prn, *t$, pstrtool, *tldia$, sclose_prn, e$
#        [if comp_type > 0 & comp_type < 4, sdelimiter, *tloffno$, sdelimiter, *scomp_type, sdelimiter, *tldia$],
#        [if xy_stock <> 0 | z_stock <> 0, sdelimiter, *xy_stock, sdelimiter, *z_stock],

pstrtool        #Comment for tool
      if strtool$ <> sblank,
        [
        strtool$ = ucase(strtool$)
        *strtool$, " "
        ]

pcomment$        #Comment from manual entry (must call pcomment2 if booleans)
      pcomment2,e$

pcomment2       #Comment from manual entry
      scomm$ = ucase (scomm$)
      if gcode$ = 1005, sopen_prn, scomm$, sclose_prn, e$  #Manual entry - as comment
      if gcode$ = 1006, scomm$, e$                         #Manual entry - as code
      if gcode$ = 1007, sopen_prn, scomm$, sclose_prn      #Manual entry - as comment with move NO e$
      if gcode$ = 1026, scomm$                             #Manual entry - as code with move NO e$
#     if gcode$ = 1008, sopen_prn, scomm$, sclose_prn, e$  #Operation comment
      if gcode$ = 1008,
         [
         if header = 1,
           [
            string9 = scomm$
            string9 = wbuf (9, wc9)
           ]
         else, pbld, n$, sopen_prn, scomm$, sclose_prn, e$
         ]
      if gcode$ = 1051, sopen_prn, scomm$, sclose_prn, e$  #Machine name
      if gcode$ = 1052, sopen_prn, scomm$, sclose_prn, e$  #Group comment
      if gcode$ = 1053, sopen_prn, scomm$, sclose_prn, e$  #Group name
      if gcode$ = 1054, sopen_prn, scomm$, sclose_prn, e$  #File Descriptor
      # else, scomm$, e$

# --------------------------------------------------------------------------
# Start of File and Toolchange Setup
# --------------------------------------------------------------------------

header   : 0     #Header flag variable for comment processing
sop_comm : ""    #String variable for saved operation comment

ptime           #Convert 24-hour time format into 12-hour AM/PM format
      if time$ >= 13, time2 = (time$ - 12)
      else, time2 = time$
      hour = int(time2), min = frac(time2)
      *hour, ":", *min,
      if time$ > 12, " PM"
      else, " AM"

pheader$         #Call before start of file                         
      header = one
      #"%", e$
      sav_spc = spaces$
      spaces$ = 0
      #*progno$, sopen_prn, sspace, sprogname$, sspace, sclose_prn, e$
      sopen_prn, sspace, sprogname$, sspace, sclose_prn, e$
      #sopen_prn, sspace, "PROGRAM NAME - ", sprogname$, sspace, sclose_prn, e$
      "(PROGRAMMED CENTERLINE OF TOOL)", e$
      "(FULL SIZE TOOLS HAVE -0- IN D RAD COMP)", e$
      "(BLOCK SKIP ON FOR OKUMA MX-45VAE)", e$
      #sopen_prn, sspace, "DATE=DD-MM-YY - ", date$, " TIME=HH:MM - ", time$, sspace, sclose_prn, e$ #Date and time output Ex. 12-02-05 15:52
      #sopen_prn, sspace, "DATE - ", month$, "-", day$, "-", year$, sspace, sclose_prn, e$  #Date output as month,day,year - Ex. 02-12-05
      sopen_prn, sspace, *smonth, " ", day$, " ", *year2, sspace, time$, sspace, sclose_prn, e$ #Date output as month,day,year - Ex. Feb. 12 2005
      #sopen_prn, sspace, "TIME - ", time$, sspace, sclose_prn, e$  #24 hour time output - Ex. 15:52
      #sopen_prn, sspace, "TIME - ", ptime, sspace, sclose_prn, e$  #12 hour time output 3:52 PM
      #spathnc$ = ucase(spathnc$)
      #smcname$ = ucase(smcname$)
      #stck_matl$ = ucase(stck_matl$)
      snamenc$ = ucase(snamenc$)
      #sopen_prn, sspace, "MCX FILE - ", *smcpath$, *smcname$, *smcext$, sspace, sclose_prn, e$
      #sopen_prn, sspace, "NC FILE - ", *spathnc$, *snamenc$, *sextnc$, sspace, sclose_prn, e$
      #sopen_prn, sspace, "MATERIAL - ", *stck_matl$, sspace, sclose_prn, e$
      spaces$ = sav_spc
      comment$
      header = zero

psof0$           #Start of file for tool zero                        
      psof$

psof$            #Start of file for non-zero tool number             
      pcuttype
      toolchng = one
      if ntools$ = one,
        [
        #skip single tool outputs, stagetool must be on
        stagetool = m_one
        !next_tool$
        ]

      pbld, n$, *sgcode, "G40", "G80", *sgabsinc, e$
      sav_absinc = absinc$
      #if stagetool >= zero, pbld, n, *t$, e$

      spaces$=0
      okuma_skip_toolnumber = t$
      pbld, n$, "IF [VTLCN EQ ", *okuma_skip_toolnumber, "] ", *n$, e$
      spaces$=sav_spc
      n$ = n$ - seqinc$
      pbld, n$, *t$, "M6", e$
      #pbld, n$, "M6", e$
      #t_nt = t$
      pbld, *n$, e$


      #pbld, n$, *t$, "M6", e$
      ptoolcomment
      comment$
    if mi1$ <= one, #Work coordinate system
        [
        absinc$ = one
      #####  pfbld, n, sgabsinc, *sg28ref, "Z0.", e
      #####  pfbld, n, *sg28ref, "X0.", "Y0.", e
      #####  pfbld, n, "G92", *xh, *yh, *zh, e
        absinc$ = sav_absinc
        ]
      else, pwcs,e$

      #pbld, pwcs,e$

      pcom_moveb
      c_mmlt$ #Multiple tool subprogram call
      pcan
      pindex
      if mi1$ > one, absinc$ = zero
      pcan1, pbld, n$, *sgcode, *sgabsinc, pfxout, pfyout, pfcout, e$
      pbld, n$, *speed, *spindle, pgear, next_tool$, strcantext, e$
      pbld, n$, "G56", *tlngno$, pfzout, scoolant, e$
      absinc$ = sav_absinc
      pcom_movea
      toolchng = zero
      c_msng$ #Single tool subprogram call

ptlchg0$         #Call from NCI null tool change (tool number repeats)                        

And this is what's in the buffer file:

 

LEFT VISE H1
RIGHT VISE H11
 
So it is getting into the buffer, just having a little trouble getting back out again. I tried a few things so far but mostly got "label not defined" errors.
I'll try again later on after I get the machines running again.
Thank you again,
Jeff
Link to comment
Share on other sites

Ok I almost got it by adding:

      string9 = rbuf(9, rc9)
      sopen_prn, string9, sclose_prn, e$  #Operation comment

after

      ptoolcomment
      comment$

in about the middle of psof$, but it is only giving me the first line from the buffer file.

The buffer file does have both lines in it still.

And it is exactly where I want it now :)

I just need to figure out how to make it give up the complete buffer file.

-Jeff

Link to comment
Share on other sites

No worries Jeff. It's easy, once you know the "proper" way to go about it.

 

I would add some code to get the "size" of the buffer file. This tells you how many rows are contained in the buffer, and let's you skip the code if the buffer has no lines of data. (if you didn't enter an Operation comment on the first op, for example.)

      ptoolcomment
      comment$
      size9 = rbuf(9, zero) #Get size of buffer (# of rows), by reading RECORD ZERO
      if size9 > zero, #Basically, if there are any records at all, then this is true...
        [
        while rc9 <= size9, #Iterate through rows in buffer.
          [
          string9 = rbuf(9, rc9) #Get row from buffer. (rc9 is initialized to '1' at start, and auto-incremented)
          sopen_prn, string9, sclose_prn, e$ #Print out comment row
          ]
        ]

That code above will get you both rows from the buffer. I used a little bit of a trick here, because I'm basing the 'while loop' condition on the value of the 'read counter' variable.

 

Buffer Files "auto-increment" the read/write counter automatically every time a record is read from, or written to the string buffer.

 

As a general rule, when getting records from a buffer, we follow a looping pattern using a "while" loop. The while loop tests a logic condition, and "while the condition remains true", the routine will execute the code that follows the test condition.

 

Typically, we follow a familiar pattern, like so:

 

  1. We usually start by getting the "size" of the buffer. This "size" is the number of Rows in the buffer file. Why? Because we need to build our loop logic to read each row, but we will get an error if we "read past" the end of the buffer. We typically store the size of the buffer in a variable called (appropriately enough), "size_", where the underscore is replaced with the buffer number we want to read/write. (you have to initialize this first!)
  2. Once we know how large the size is, we build a "while" loop, that uses some sort of "counter" variable, and tests the counter value vs. the "size" variable that we set previously by reading the buffer record zero.
  3. We start getting each line from the buffer file, by using the 'rbuf' command. We use a "read counter" variable, that is initialized to '1'. (so we get the 1st record. Otherwise, if it is set to zero, we only get the number of rows)
  4. As soon as we have "read" the line from the buffer, the "read counter" variable get "auto-incremented".
  5. Now, we do something with this Row data. In your case, we output the comment line.
  6. Typically, after we have done something with the Row, we then "increment" the counter variable. Because I'm using the "read counter" in the while loop test, this is done for us automatically in this example.
  7. Once we reach the end of the implied post block, the 'while' condition gets tested again. If the result is "true", we then go and execute the code in the loop body. In this case, we read a 2nd line from the buffer file. This 2nd row gets output as a comment string. (after we read the 2nd line, the 'rc9' variable now equals '3'.)
  8. We finish executing the loop body, and return to the logic test.
  9. The test returns "false", and so the while loop exits.
Link to comment
Share on other sites

To give a similar example to the above, but using a traditional "counter" variable, it would look something like this:

count9 : 0 #Initialize counter variable for buffer 9


psof$       #Start of file for non-zero tool
      .
      .
      .
      ptoolcomment
      comment$
      size9 = rbuf(9, zero) #Get size of buffer (# of rows), by reading RECORD ZERO
      if size9 > zero, #Basically, if there are any records at all, then this is true...
        [
        # In this example, assume buffer 9 holds 15 rows
        count9 = 1 #set counter to begin loop
        while count9 <= size9, #Iterate through rows in buffer.
          [
          # The code between the nested brackets here is the "loop body"
          # On the 1st pass, count9 = 1, and size9 = 15
          string9 = rbuf(9, rc9) #Get row from buffer. (rc9 is initialized to '1' at start, and auto-incremented)
          sopen_prn, string9, sclose_prn, e$ #Print out comment row
          count9 = count9 + 1
          #After the 1st row is read, and output to the NC file, we now have incremented the counter
          # And will test the while condition again, performing the loop body over and over, until the condition is "false".
          ]
        ]
Link to comment
Share on other sites

Colin, you are my new hero :)

I played with the While statement a little bit earlier and didn't terminate it properly.

I ended up with over a million lines of ( RIGHT VISE H11 ). The file size was over 20MB LOL

I'll use your first option since it seems to be the more straight forward of the 2.

And now that I have a little better understanding of what is going on, it shouldn't be hard to make the same changes to my other 3 posts.

I will also copy this thread to a file in my archives for future reference so I'll be able to do it again after I forget :)

I'm not really a programmer, just a lowly machinist that also has to do programming.

I would buy you a beer if you weren't all the way on the other side of the country (I'm in Washington state just south of Seattle)

I thank you very much and wish you and yours all the best!

Jeff

Link to comment
Share on other sites

Glad you got it working Jeff. I grew up in Shoreline, WA and lived in the north seattle area for many years. I'm happy to help a fellow Seattlite.

 

Don't kid yourself about being a "lowly machinist". You figured out how to add a buffer file definition to your post, and that is no small feat. It's actually damn impressive. Let me know if you're ever applying for a new job and need a reference. I'd be happy to provide one.

  • Like 1
Link to comment
Share on other sites
  • 1 year later...

I am revisiting this post because I am still unclear on how to swap around some comments in the header. I am trying to post my Operation Comment after my Tool List for the program. I always have to manually cut and paste the Operation Comment after the Tool List.

 

Here is what my post looks like now:

O0( GHC058-101 )
( DATE - JUL. 24 2018 )
( TIME - 7:42 AM )
G20
G0 G17 G40 G49 G80 G90
G187 E0.001
 
( NEW AGE PROGRAM )
( )
( CYCLE TIME: )
( OPERATOR INITIALS: )
( STOCK SIZE: )
( G54 SET PART X Y )
( MAX DOWN IN VISE )
( X0 )
( Y0 )
( Z0 )
( )
( MILL RIGHT SIDE - MIDDLE SLOT - LEFT SIDE ) 
 
( T1 |  1/2 Z-CARB FLAT ENDMILL | DIA. - .5 )
 
T1 M6 ( T1 |  1/2 Z-CARB FLAT ENDMILL | DIA. - .5 )
G0 G90 G54 X11.185 Y.4 S1910 M3
G43 H1 Z.25
M8

 

This is what I want it to look like:

O0( GHC058-101 )
( DATE - JUL. 24 2018 )
( TIME - 7:42 AM )
G20
G0 G17 G40 G49 G80 G90
G187 E0.001
 
( NEW AGE PROGRAM )
( )
( CYCLE TIME: )
( OPERATOR INITIALS: )
( STOCK SIZE: )
( G54 SET PART X Y )
( MAX DOWN IN VISE )
( X0 )
( Y0 )
( Z0 )
( )
 
( T1 |  1/2 Z-CARB FLAT ENDMILL | DIA. - .5 )
( T2 |  1/2 SPOT DRILL | DIA. - .5 )
( T3 |  7/16 DRILL | DIA. - .4375 )

( MILL RIGHT SIDE - MIDDLE SLOT - LEFT SIDE )
 
T1 M6 ( T1 |  1/2 Z-CARB FLAT ENDMILL | DIA. - .5 )
G0 G90 G54 X11.185 Y.4 S1910 M3
G43 H1 Z.25
M8
Link to comment
Share on other sites

Are you using Mastercam 2017 or later?  If so, you can use opinfo and do something like the below example in pheader$.

stoolPathComment = opinfo(15239, 0)

You'll have to initialize stoolPathComment somewhere in the post in order for the above line to work.  

<LeftMargin>stoolPathComment : ""

I usually set up a post block that I call whenever I start a new op.  The post your using probably has something comparable.

#region Tool Path Comment

fmt "OP NUMBER - "            4 opNumber
fmt "TOOLPATH MAX Z DEPTH: "  3 toolpathZMin

stoolPathComment : ""

pToolPathComment
      opNumber = opinfo(15240, 0)
      stoolPathComment = opinfo(15239, 0)
      toolpathZMin= opinfo(19, 0)
      n$, scommentStart, *opNumber, [if stoolPathComment <> sBlank, "|", stoolPathComment], scommentEnd e$
      n$, scommentStart, *toolpathZMin, scommentEnd e$


#endregion End Tool Path Comment

 

Hope that helps,

Jeff

  • Like 1
Link to comment
Share on other sites
  • 2 years later...

Hello Folks,

It's been a while and now I have a new question that I can't find an answer for. I'm still using X9 and the MPOkuma post referenced above.

I have one job where I need to go to a safe tool change location. It's not that hard really, I just added a second comment as code after my comment as comment for origin location.

The thing I don't like is that both comments post out in between the header and the tool list. I know it's just a click and drag to fix this but it would be nice if the post would do it so I don't have to. I've tried everything I can think of to move the comments, but when I do get the comments to move they show up after the tool change which defeats the purpose. I can't seem to get the tool table to move at all.

This is what I am getting:

( 212.50.08.025 )
( B5008025.MIN )
(PROGRAMMED CENTERLINE OF TOOL)
(FULL SIZE TOOLS HAVE -0- IN D RAD COMP)
(BLOCK SKIP ON FOR OKUMA MX-45VAE)
( APR 15 2021 15:15 )
( X0 & Y0 CENTER OF THE PART )
( Z0 TOP OF THE PART )
( USE ER-32 HOLDERS )
( FOR ALL TOOLS )
G0 G90 G15 H1
G30 P1
X-9.
( T1 1/4 SPOTDRILL 2.1 OOH    DIA-.25 )
( T2 NO. 8 DRILL 2.5 OOH    DIA-.199 )
( T3 1/2 SPOTDRILL 4.25 OOH    DIA-.5 )
( T4 41/64 DRILL 5.1 OOH    DIA-.640625 )
( T5 1/2 SPECIAL IMCO 65286 4.6 OOH    DIA-.5 )
( T6 M6 X 1.0 TAP 2.1 OOH    DIA-.2398 )
( Toolpath Group-2 )
G0 G40 G80 G90
IF [VTLCN EQ 1] N1
T1 M6
N1
( T-1  H-1  D-1  DIA-.25  -  1/4 SPOTDRILL 2.1 OOH   )
G15 H01
G0 G90 X.4923 Y-.8526

And this is what I would like to get:

( 212.50.08.025 )
( B5008025.MIN )
(PROGRAMMED CENTERLINE OF TOOL)
(FULL SIZE TOOLS HAVE -0- IN D RAD COMP)
(BLOCK SKIP ON FOR OKUMA MX-45VAE)
( APR 15 2021 15:15 )
( X0 & Y0 CENTER OF THE PART )
( Z0 TOP OF THE PART )
( USE ER-32 HOLDERS )
( FOR ALL TOOLS )
( T1 1/4 SPOTDRILL 2.1 OOH    DIA-.25 )
( T2 NO. 8 DRILL 2.5 OOH    DIA-.199 )
( T3 1/2 SPOTDRILL 4.25 OOH    DIA-.5 )
( T4 41/64 DRILL 5.1 OOH    DIA-.640625 )
( T5 1/2 SPECIAL IMCO 65286 4.6 OOH    DIA-.5 )
( T6 M6 X 1.0 TAP 2.1 OOH    DIA-.2398 )
( Toolpath Group-2 )
G0 G90 G15 H1
G30 P1
X-9.
G0 G40 G80 G90
IF [VTLCN EQ 1] N1
T1 M6
N1
( T-1  H-1  D-1  DIA-.25  -  1/4 SPOTDRILL 2.1 OOH   )
G15 H01
G0 G90 X.4923 Y-.8526

Any ideas?

Thank you

-Jeff

Link to comment
Share on other sites

OK I moved comment$ from pheader$ to psof$ and that is probably good enough, but is there a way to separate 1005, 1007 comments from 1006, 1026 comments so that I can still have my origin information above my tool list and my manual entry as code comments down below?

This is what I'm getting now:

( 212.50.08.025 )
( B5008025.MIN )
(PROGRAMMED CENTERLINE OF TOOL)
(FULL SIZE TOOLS HAVE -0- IN D RAD COMP)
(BLOCK SKIP ON FOR OKUMA MX-45VAE)
( APR 16 2021 15:39 )
( T1 1/4 SPOTDRILL 2.1 OOH    DIA-.25 )
( T2 NO. 8 DRILL 2.5 OOH    DIA-.199 )
( T3 1/2 SPOTDRILL 4.25 OOH    DIA-.5 )
( T4 41/64 DRILL 5.1 OOH    DIA-.640625 )
( T5 1/2 SPECIAL IMCO 65286 4.6 OOH    DIA-.5 )
( T6 M6 X 1.0 TAP 2.1 OOH    DIA-.2398 )
( Toolpath Group-2 )
( X0 & Y0 CENTER OF THE PART )
( Z0 TOP OF THE PART )
( USE ER-32 HOLDERS )
( FOR ALL TOOLS )
G0 G90 G15 H1
G30 P1
X-9.
G0 G40 G80 G90
IF [VTLCN EQ 1] N1
T1 M6
N1
( T-1  H-1  D-1  DIA-.25  -  1/4 SPOTDRILL 2.1 OOH   )
G15 H01
G0 G90 X.4923 Y-.8526

 

Link to comment
Share on other sites

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...