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:

Comment manipulation


Guest
 Share

Recommended Posts

I added some additional code to the 'pcomment_out' post block, to allow you to break a string using a special character within the string to provide the specific break point.

 

I added several variables, the most important being 'smatch'. Set this string to the character you want to use to break a line at a specific position. You must use a character you can produce with your keyboard. I don't think "Enter" works at all. I set the default to use the Tilde character (~). You can always set it to another character like the Pipe symbol (|) or something you know your control won't allow like @.

 

When you place a Tilde (or whatever character you set 'smatch' to) inside a comment string, this triggers a routine in the post that breaks the line up using that 'smatch' character value. The while loop breaks the string, and discards the 'smatch' character at the front of the broken string. Then it searches the remaining string for the match character. If not found, it outputs the rest of the broken string, and exits the loop.

 

I used a silly example for the Machine Group Comment String. The tongue twister is about 210 characters long, including the Tilde characters. Using the Tilde characters, the comment is output in broken pieces.

(GENERIC HAAS 4 - AXIS VMC)
(MACHINE GROUP-1)

(-----------------------)
(STRING BREAKING CHARACTER DETECTED IN A MACHINE GROUP COMMENT)
(YOUR COMMENTS HAVE BEEN BROKEN AT THE ~ CHARACTER)
(HOW MUCH WOOD)
(WOULD A WOODCHUCK CHUCK,)
(IF A WOODCHUCK)
(COULD CHUCK)
(WOOD?)
(WELL,)
(IF A WOODCHUCK)
(COULD CHUCK)
(WOOD,)
(A WOODCHUCK)
(WOULD CHUCK)
(ALL THE WOOD)
(THAT A WOODCHUCK)
(COULD CHUCK,)
(IF A WOODCHUCK)
(COULD CHUCK)
(WOOD!)
(-----------------------)

N3 T239 M6
N4 G94 G1 G90 G54 X-4.7493 Y-.0448 A0. S119 M3 F500.

sccomp_comm      : ""    #String to output cutter comp "type" string in ptooltable
sstock_left_comm : ""    #String to output "stock to leave" strings in ptooltable
scomm_out        : ""    #Return string for comment_fx function (pcomment_out)
scomm_fx_arg     : ""    #Comment temp string (always set 'scomm_fx_arg' before calling pcomment_out)
stemp1           : ""    #Temp string
stemp2           : ""    #Temp string
scomm_type       : ""    #
shoriz           : "-----------------------" #Horizontal separator, use to help format broken comments
smatch           : "~"   #Delimiter Matching String, use to parse comments into separate lines from one comment string

pcomment_out #Check comment length, truncate/shorten if necessary
      comm_len = strlen(sopen_prn + sclose_prn) #Get length of comment begin and end strings
      if comment_mode < two,
        [
        scomm_out = comment_fx(maxnccomment$ - comm_len, scomm_fx_arg, comment_mode)
        sopen_prn, no_spc$, scomm_out, no_spc$, sclose_prn, e$ #Output truncated comment
        ]
      else, #Break comment into multiple lines of output. Must set 'max nc comment' length in CD to 256, so MP won't truncate the string
        [
         #Search 'scomm_fx_arg' for break character
        str_brk = no$ #Set breaking to zero
        if smatch <> sblank, str_brk = strstr(smatch, scomm_fx_arg)
        if str_brk, #the break character is present.
          [
          #Use this block to parse scomm_fx_arg into separate strings to output
          #The next line outputs a blank line to the NC code file, and the line after is the horizontal seperator
          *e$
          sopen_prn, no_spc$, shoriz, no_spc$, sclose_prn, e$
          
          #These IF statements set the 'scomm_type' to report on the type of comment being broken.
          # This is mostly for debugging purposes, to tell you the programmer which comment type is being broken.
          # Even if you remove the message output below with a pound sign, leaving this code does no harm
          if gcode$ = 1005, scomm_type = "MANUAL ENTRY COMMENT"
          if gcode$ = 1008, scomm_type = "OPERATION COMMENT"
          if gcode$ = 1051, scomm_type = "MACHINE NAME COMMENT"
          if gcode$ = 1052, scomm_type = "MACHINE GROUP COMMENT"
          if gcode$ = 1053, scomm_type = "GROUP NAME COMMENT"
          if gcode$ = 1054, scomm_type = "FILE DESCRIPTOR COMMENT"
          
          
          #The next two lines are just a message. Add a pound sign (#) in front of the lines to remove
          sopen_prn, no_spc$, "STRING BREAKING CHARACTER DETECTED IN A", scomm_type, no_spc$, sclose_prn, e$
          sopen_prn, no_spc$, "YOUR COMMENTS HAVE BEEN BROKEN AT THE", smatch, "CHARACTER", no_spc$, sclose_prn, e$
          
          #The next line converts all comments to uppercase characters
          scomm_fx_arg = ucase(scomm_fx_arg)
          
          #The following 'while' loop breaks the comment into multiple strings, using the 'smatch' character.
          #The default 'smatch' character is the tilde (~), but you can edit the 'smatch' variable definition,
          #  if you wish to change the character used to break the string. For example, replace the "~" with "|" to use the pipe symbol.
          scomm_out = scomm_fx_arg #assign string to scomm_out
          while str_brk > zero,
            [
            stemp1 = brksps(str_brk, scomm_out) #Break string at specified position
            sopen_prn, no_spc$, scomm_out, no_spc$, sclose_prn, e$ #Output broken comment
            stemp2 = brksps(two, stemp1) #Remove 'smatch' character from front of string
            scomm_out = stemp2 #Set 'scomm_out' back to stemp1, so that it can be broken again
            str_brk = strstr(smatch, scomm_out)
            str_len = strlen(scomm_out)
            if str_brk = zero & str_len > zero, sopen_prn, no_spc$, scomm_out, no_spc$, sclose_prn, e$ #Output broken comment
            ]
            
          #These two lines output a horizontal separator, then a blank line to the NC file
          sopen_prn, no_spc$, shoriz, no_spc$, sclose_prn, e$
          *e$
          ]
        else, #This code reads the string, and breaks using a string length parameter
          [
          comm_brk_len = comm_brk_len - comm_len #subtract comment begin/end strings
          str_len = strlen(scomm_fx_arg) #Get length of comment string
          str_brk = int(str_len / comm_brk_len) #Get number of broken output strings
          if frac(str_len / comm_brk_len), str_brk = str_brk + one #Add one more output if not even division
          scomm_out = scomm_fx_arg #assign string to scomm_out
          while str_brk > zero, #Output broken comments
            [
            stemp1 = brksps(comm_brk_len, scomm_out) #Break string at specified position
            sopen_prn, no_spc$, scomm_out, no_spc$, sclose_prn, e$ #Output broken comment
            scomm_out = stemp1 #Set 'scomm_out' back to stemp1, so it can be broken again in while loop
            str_brk = str_brk - one #Decrement counter
            ]
          ]
          
        ]
        scomm_out = sblank #Reset scomm_out

Comment breaking test_break at smatch character.Z2G

 

Hopefully someone gets some use out of this code...

 

Best regards,

 

Colin

 

 

 

 

  • Like 3
Link to comment
Share on other sites

Hello everyone,

   Thank for the info as you guys sharing the GROUP COMMENT, and I would like to use the "~"

 

at the

 

swcsplcomm : ""        #20015 - WCS Plane Comment

 

Would you guys please help me to guide me how to do it?

 

Here is what I want to put like this:

 

(Work Offset Info:)
(TOP)
(X0 = CENTER OF PART~Y0=FRONT OF PART~Z0= TOP OF PART) ======> From WCS NAME COMMENT and I would like it to be:

(X0 = CENTER OF PART)

(Y0=FRONT OF PART)

(Z0= TOP OF PART)

 

 

 

----------------------------------------

Thank you.

Link to comment
Share on other sites

Hello everyone,

   Thank for the info as you guys sharing the GROUP COMMENT, and I would like to use the "~"

 

at the

 

swcsplcomm : ""        #20015 - WCS Plane Comment

 

Would you guys please help me to guide me how to do it?

 

Here is what I want to put like this:

 

(Work Offset Info:)

(TOP)

(X0 = CENTER OF PART~Y0=FRONT OF PART~Z0= TOP OF PART) ======> From WCS NAME COMMENT and I would like it to be:

(X0 = CENTER OF PART)

(Y0=FRONT OF PART)

(Z0= TOP OF PART)

 

 

 

----------------------------------------

Thank you.

 

 

Will your machine accept that character?

 

Will need to look for the ASCII number and use it if your attempt to use it "as is" did not work.

 

HTH

Link to comment
Share on other sites

Will your machine accept that character?

 

Will need to look for the ASCII number and use it if your attempt to use it "as is" did not work.

 

HTH

 

Hi 5th Axis Consulting,

  My machine cannot read "~" and I would love to have the function as I ask for WCS PLANE COMMENT. 

 

I'm trying to look for ENTER KEY ASCII number so I can make it ENTER KEY works out.

 

Thank you for your help.

Link to comment
Share on other sites

Okay I misunderstood. You would like to use that as the character for the post to use as the break command for the output?

 

If so reread what Colin put up it is explained in great detail about middle of the code section here:

 #The following 'while' loop breaks the comment into multiple strings, using the 'smatch' character.
          #The default 'smatch' character is the tilde (~), but you can edit the 'smatch' variable definition,
          #  if you wish to change the character used to break the string. For example, replace the "~" with "|" to use the pipe symbol.
          scomm_out = scomm_fx_arg #assign string to scomm_out

I am still Ron or the Crazy^Millman just changed my Posting name to reflect our company name. :laughing:

Link to comment
Share on other sites

Steven,

 

I've given you all the code you need. The post block is already setup to search the string for the "~" character, and break the string at that place, while also removing that character from the output.

 

Just set 'scomm_fx_arg' to the string 'swcsplcomm', then call 'pcomment_out'.

scomm_fx_arg = swcsplcomm, pcomment_out
Link to comment
Share on other sites

 

Steven,

 

I've given you all the code you need. The post block is already setup to search the string for the "~" character, and break the string at that place, while also removing that character from the output.

 

Just set 'scomm_fx_arg' to the string 'swcsplcomm', then call 'pcomment_out'.

scomm_fx_arg = swcsplcomm, pcomment_out

 

Good morning Colin,

    Would you please tell me where I should put this line?

 

"scomm_fx_arg = swcsplcomm, pcomment_out"

 

#The following 'while' loop breaks the comment into multiple strings, using the 'smatch' character. #The default 'smatch' character is the tilde (~), but you can edit the 'smatch' variable definition, # if you wish to change the character used to break the string. For example, replace the "~" with "|" to use the pipe symbol. scomm_out = scomm_fx_arg #assign string to scomm_out

 

 ======> scomm_fx_arg = swcsplcomm, pcomment_out  #(You mean I replace here?)

 

I tried to replaced below the "pcomment_out" and it didn't work. 

 

Thank you.

Link to comment
Share on other sites

Okay I have read this at least 15 times and still think this is a failure to communicate here. You want to use the enter key as your separator? If the answer is yes you cannot use it. You must use some other key besides enter for this function Colin put up to work. It is take lets say 5000 words and allowing you to break it up into manreadable code for the NC output. In a Word Program we hit enter to end a line. Here the ~ Character is inserted into a written out information and it will the break those 5000 words into short enough lines when we use the ~ symbol in it. Using the Enter Key is not part of this.

 

Colin said the Enter Key will not work so accept you can use the ~ character or anything else you want to be the break, but not ENTER IT WILL NOT WORK!!!!

  • Like 1
Link to comment
Share on other sites

Okay I have read this at least 15 times and still think this is a failure to communicate here. You want to use the enter key as your separator? If the answer is yes you cannot use it. You must use some other key besides enter for this function Colin put up to work. It is take lets say 5000 words and allowing you to break it up into manreadable code for the NC output. In a Word Program we hit enter to end a line. Here the ~ Character is inserted into a written out information and it will the break those 5000 words into short enough lines when we use the ~ symbol in it. Using the Enter Key is not part of this.

 

Colin said the Enter Key will not work so accept you can use the ~ character or anything else you want to be the break, but not ENTER IT WILL NOT WORK!!!!

Hi 5th Axis Consutling,

   I'm not using ENTER KEY, I'm using as "~" so I can use it at the WCS PLANE COMMENT just like someone who likes to use at the GROUP COMMENT. I think you may be missunderstanding what I meant an I'm applygize for my leglect.

Link to comment
Share on other sites

PcRobotic,

 

I believe all you need to do is copy his postblock pcomment_out and add it to your existing post, along with the variable definitions that he also includes in his post above the pcomment_out postblock

 

Once you have done that, all you need to do is find in your post where you are currently outputting the group comment swcsplcomm

 

And then add his line scomm_fx_arg = swcsplcomm, pcomment_out

 

and then make a call to the new postblock pcomment_out

 

 

so basically add his stuff.. then where you were outputting your group comment  .. change it to..

scomm_fx_arg = swcsplcomm, pcomment_out

pcomment_out

I don't believe there is anything in his code you need to change.

  • Like 1
Link to comment
Share on other sites

Thank you to Collin and DJSTEDMAN,

     With your help here is how I did and I hope my little work can help others who have the same needs...

 

 

# --------------------------------------------------------------------------
#String and string selector definitions for NC output
# --------------------------------------------------------------------------

stemp1           : ""    #Temp string
stemp2           : ""    #Temp string
scomm_type       : ""    #
shoriz           : "*" #Horizontal separator, use to help format broken comments
smatch           : "`"   #Delimiter Matching String, use to parse comments into separate lines from one comment string
 

# --------------------------------------------------------------------------
# Tool Comment / Manual Entry Section
# --------------------------------------------------------------------------

pcomment2       #Comment from manual entry
      #1005 - As Comment
      #1006 - As Code
      #1007 - As Comment with output line, change at point
      #1026 - As Code with output line, change at point
      #1008 - Operation comment

      #1051 - Machine Name
      #1052 - Group Comment
      #1053 - Group Name
      #1054 - File Descriptor

      spaces$ = 0
      scomm$ = ucase (scomm$)
      if gcode$ = 1052, scomm_fx_arg = scomm$, pcomment_out  #Group comment
      if sof & gcode$ = 1053, scomm_str, "P/NAME= ", scomm$, scomm_end, e$
      if gcode$ = 1005, scomm_fx_arg = scomm$, pcomment_out  #Manual entry - as comment
      #if gcode$ = 1005, n$, pspc, scomm_str, scomm$, scomm_end, e$
      if gcode$ = 1006, n$, pspc, scomm$, e$
      #if gcode$ = 1007, scomm_str, scomm$, scomm_end
      #if gcode$ = 1026, scomm$
      #if gcode$ = 1008 & header = zero, n$, pspc, scomm_str, scomm$, scomm_end, e$
      if gcode$ = 1008, scomm_sav = ucase(scomm$)

      if gcode$ = 1008, scomm_fx_arg = scomm$, pcomment_out  #Operation comment
      if gcode$ = 1051, scomm_fx_arg = scomm$, pcomment_out  #Machine name
      #if gcode$ = 1052, scomm_fx_arg = scomm$, pcomment_out  #Group comment
      if gcode$ = 1053, scomm_fx_arg = scomm$, pcomment_out  #Group name
      if gcode$ = 1054, scomm_fx_arg = scomm$, pcomment_out  #File Descriptor
      spaces$ = sav_spc

pcomment_out #Check comment length, truncate/shorten if necessary
      comm_len = strlen(scomm_str + scomm_end) #Get length of comment begin and end strings
      if comment_mode < two,
        [
        scomm_out = comment_fx(maxnccomment$ - comm_len, scomm_fx_arg, comment_mode)
        scomm_str, no_spc$, scomm_out, no_spc$, scomm_end, e$ #Output truncated comment
        ]
      else, #Break comment into multiple lines of output. Must set 'max nc comment' length in CD to 256, so MP won't truncate the string
        [
         #Search 'scomm_fx_arg' for break character
        str_brk = no$ #Set breaking to zero
        if smatch <> sblank, str_brk = strstr(smatch, scomm_fx_arg)
        if str_brk, #the break character is present.
          [
          #Use this block to parse scomm_fx_arg into separate strings to output
          #The next line outputs a blank line to the NC code file, and the line after is the horizontal seperator
          #*e$
          scomm_str, no_spc$, shoriz, no_spc$, scomm_end, e$
         
          #These IF statements set the 'scomm_type' to report on the type of comment being broken.
          # This is mostly for debugging purposes, to tell you the programmer which comment type is being broken.
          # Even if you remove the message output below with a pound sign, le         
          if gcode$ = 1005, scomm_type = "MANUAL ENTRY COMMENT"
          if gcode$ = 1008, scomm_type = "OPERATION COMMENT"
          if gcode$ = 1051, scomm_type = "MACHINE NAME COMMENT"
          if gcode$ = 1052, scomm_type = "MACHINE GROUP COMMENT"
          if gcode$ = 1053, scomm_type = "GROUP NAME COMMENT"
          if gcode$ = 1054, scomm_type = "FILE DESCRIPTOR COMMENT"
      
          #The next two lines are just a message. Add a pound sign (#) in front of the lines to remove
          #scomm_str, no_spc$, "STRING BREAKING CHARACTER DETECTED IN A", scomm_type, no_spc$, scomm_end, e$
          #scomm_str, no_spc$, "YOUR COMMENTS HAVE BEEN BROKEN AT THE", smatch, "CHARACTER", no_spc$, scomm_end, e$
         
          #The next line converts all comments to uppercase characters
          scomm_fx_arg = ucase(scomm_fx_arg)
         
          #The following 'while' loop breaks the comment into multiple strings, using the 'smatch' character.
          #The default 'smatch' character is the tilde (~), but you can edit the 'smatch' variable definition,
          #  if you wish to change the character used to break the string. For example, replace the "~" with "|" to use the pipe symbol.
          scomm_out = scomm_fx_arg #assign string to scomm_out
          while str_brk > zero,
            [
            stemp1 = brksps(str_brk, scomm_out) #Break string at specified position
            scomm_str, no_spc$, scomm_out, no_spc$, scomm_end, e$ #Output broken comment
            stemp2 = brksps(two, stemp1) #Remove 'smatch' character from front of string
            scomm_out = stemp2 #Set 'scomm_out' back to stemp1, so that it can be broken again
            str_brk = strstr(smatch, scomm_out)
            str_len = strlen(scomm_out)
            if str_brk = zero & str_len > zero, scomm_str, no_spc$, scomm_out, no_spc$, scomm_end, e$ #Output broken comment
            ]
           
          #These two lines output a horizontal separator, then a blank line to the NC file
          scomm_str, no_spc$, shoriz, no_spc$, scomm_end, e$
          ]
        else, #This code reads the string, and breaks using a string length parameter
          [
          comm_brk_len = comm_brk_len - comm_len #subtract comment begin/end strings
          str_len = strlen(scomm_fx_arg) #Get length of comment string
          str_brk = int(str_len / comm_brk_len) #Get number of broken output strings
          if frac(str_len / comm_brk_len), str_brk = str_brk + one #Add one more output if not even division
          scomm_out = scomm_fx_arg #assign string to scomm_out
          while str_brk > zero, #Output broken comments
            [
            stemp1 = brksps(comm_brk_len, scomm_out) #Break string at specified position
            scomm_str, no_spc$, scomm_out, no_spc$, scomm_end, e$ #Output broken comment
            scomm_out = stemp1 #Set 'scomm_out' back to stemp1, so it can be broken again in while loop
            str_brk = str_brk - one #Decrement counter
            ]
          ]
         
        ]
        scomm_out = sblank #Reset scomm_out

 

pheader$         #Call before start of file

      "(Work Offset Info:)", e$
      if stoolplname, "(", stoolplname, ")", *e$, else, "(WHAT OPERATAION?)", e$
      if swcsplcomm, "(", scomm_fx_arg = swcsplcomm, pcomment_out
, ")", *e$, else, "(WHERE IS THE WORKOFFSET?)", e$

  • Like 1
Link to comment
Share on other sites

PcRobotic,

 

I believe all you need to do is copy his postblock pcomment_out and add it to your existing post, along with the variable definitions that he also includes in his post above the pcomment_out postblock

 

Once you have done that, all you need to do is find in your post where you are currently outputting the group comment swcsplcomm

 

And then add his line scomm_fx_arg = swcsplcomm, pcomment_out

 

and then make a call to the new postblock pcomment_out

 

 

so basically add his stuff.. then where you were outputting your group comment  .. change it to..

scomm_fx_arg = swcsplcomm, pcomment_out

pcomment_out

I don't believe there is anything in his code you need to change.

 

Hi Steven and DJ,

 

DJ was correct. You just need to go into your post, and set the variable 'scomm_fx_arg' to whatever string you want to break. Then you need to call 'pcomment_out'.

 

Actually, if you look at the sample code, I've done that already. You can separate the formula statement (scomm_fx_arg = swcsplcomm), and the call to 'pcomment_out' with a comma, which separates them into separate actions.

 

First, the formula statement sets the string variable. Then, there is a call to 'pcomment_out', which will either Truncate, Shorten, Break with a character limit, or Break at a specified position. All of the comments (doesn't matter what the output format is), will be output with the comment start and end characters.

 

So just to reiterate, you either need code that looks like this:

scomm_fx_arg = swcsplcomm, pcomment_out

Or, code that looks like this:

scomm_fx_arg = swcsplcomm
pcomment_out

Both methods accomplish the same thing. They set a string, and then call the post block that outputs that string as a comment. (or multiple comments)

 

You would not add that code inside "pcomment_out". You would add that code either in 'pheader$', or 'psof$', or 'ptlchg$' or 'ptlchg0$'.

 

 

Steven, I really want to help you. I think it is great that you put so much effort into customizing your post processors, but I think you end up making it harder on yourself than it needs to be.

 

You had sent in a request for quote to Eapprentice for some post processor modificaitons. I would recommend spending that money instead on taking a training class in Post Processing. If you took some training, it would make your life so much easier, and we can make many of the modifications that you are asking for in class. That way you learn how to make the edits yourself, instead of paying someone to make them for you.

 

I think you've got a great start, but you are just missing some of the fundamental steps in understanding how posts work. If someone gives you the code, you are pretty good at copying and pasting it into your post, and through trial-and-error, getting some usable output. By taking a class and understanding more of the MP language, I can help take you to the next level. You would learn how to write your own code, but more importantly, you would learn how to use the post documentation resources to figure out how to develop and write your own code. I promise it will be the best money you ever spent on educating yourself.

 

Best regards,

 

Colin Gilchrist

  • Like 1
Link to comment
Share on other sites

Hi Steven and DJ,

 

DJ was correct. You just need to go into your post, and set the variable 'scomm_fx_arg' to whatever string you want to break. Then you need to call 'pcomment_out'.

 

Actually, if you look at the sample code, I've done that already. You can separate the formula statement (scomm_fx_arg = swcsplcomm), and the call to 'pcomment_out' with a comma, which separates them into separate actions.

 

First, the formula statement sets the string variable. Then, there is a call to 'pcomment_out', which will either Truncate, Shorten, Break with a character limit, or Break at a specified position. All of the comments (doesn't matter what the output format is), will be output with the comment start and end characters.

 

So just to reiterate, you either need code that looks like this:

scomm_fx_arg = swcsplcomm, pcomment_out

Or, code that looks like this:

scomm_fx_arg = swcsplcomm
pcomment_out

Both methods accomplish the same thing. They set a string, and then call the post block that outputs that string as a comment. (or multiple comments)

 

You would not add that code inside "pcomment_out". You would add that code either in 'pheader$', or 'psof$', or 'ptlchg$' or 'ptlchg0$'.

 

 

Steven, I really want to help you. I think it is great that you put so much effort into customizing your post processors, but I think you end up making it harder on yourself than it needs to be.

 

You had sent in a request for quote to Eapprentice for some post processor modificaitons. I would recommend spending that money instead on taking a training class in Post Processing. If you took some training, it would make your life so much easier, and we can make many of the modifications that you are asking for in class. That way you learn how to make the edits yourself, instead of paying someone to make them for you.

 

I think you've got a great start, but you are just missing some of the fundamental steps in understanding how posts work. If someone gives you the code, you are pretty good at copying and pasting it into your post, and through trial-and-error, getting some usable output. By taking a class and understanding more of the MP language, I can help take you to the next level. You would learn how to write your own code, but more importantly, you would learn how to use the post documentation resources to figure out how to develop and write your own code. I promise it will be the best money you ever spent on educating yourself.

 

Best regards,

 

Colin Gilchrist

 

Hi Collin,

   Would you please what did I do wrong?  I have REDONDANT GROUP COMMENT.  Would you please tell me what I did wrong?  Thank you.

%

O0000(T.NC Post REV.51)

(P/NAME= MACHINE GROUP HERE)

(MACHINE GROUP HERE)

(*)

(GROUP COMMENT HERE) ====> OKAY TO KEEP

(TESTING)====> OKAY TO KEEP

(AND)====> OKAY TO KEEP

(LINE 3)====> OKAY TO KEEP

(LINE 4)====> OKAY TO KEEP

(LINE 4)====> OKAY TO KEEP

(*)

(POSTED ON JAN.02.2015 AT 1*21PM)

(STEVEN LUONG{19BE57E4-77ED-4BE0-9B92-AA67B5961E6E})

(SOURCE= TESTING COMMENT.MCX-8)

(Vertical 4Axis Universial Post)

(*)

(MATERIAL TYPE= ALUMINUM INCH - 2024)

(MATERIAL STK= X.00 Y.00 Z.00)

(*)

(Work Offset Info:)

(TOP)

(*)

(X0 = CENTER OF PART)

(Y0=FRONT OF PART)

(Z0= TOP OF PART)

(*)

(TOOLS LIST)

(T1  -  1/2 FLAT ENDMILL    -  H1)

(T2  - 3/8 BALL ENDMILL     -  H2)

(*)

N1( 1/2 FLAT ENDMILL)

G0 G17 G40 G49 G53 G80 G90 Z0

T1 M6(, CUT#1)

G90 G54

X-4.7493 Y-.0448 S119 M3

G43 H1 Z2. T2 M8(DOC= Z-6.)

Z.2

G1 Z-6. F117.

..... (cutting)

Z.2 F118.

G0 Z2.

G90 G53 Z0 M9

G53 Y0 M5

M1

(MACHINE GROUP HERE) ===> NO NEED HERE

(*) ===> NO NEED HERE

(GROUP COMMENT HERE) ===> NO NEED HERE

(TESTING)  ===> NO NEED HERE

(AND) ===> NO NEED HERE

(LINE 3) ===> NO NEED HERE

(LINE 4) ===> NO NEED HERE

(LINE 4) ===> NO NEED HERE

(*)

(*)

N2(3/8 BALL ENDMILL)

G0 G17 G40 G49 G53 G80 G90 Z0

T2 M6(, CUT#2)

G90 G54

X-4.4368 Y.0802 S119 M3

G43 H2 Z2. T1 M8(DOC= Z-5.)

Z.2

G1 Z-5. F117.

... (Cutting...)

Z.2 F118.

G0 Z2.

G90 G53 Z0 M9

G53 Y0.

M1

T1 M6

M30

%

 

Link to comment
Share on other sites

For anyone else following along, the 'pcomment_out' post block (in the code I provided above), will output a comment string, and add the 'comment begin' and 'comment end' characters to the comment being output. It will do this in all cases, provided the 'comment begin' and 'comment end' characters are not "empty strings".

 

This makes it possible to take the code I provided, and add it to just about any post, even if that post doens't use Fanuc-style open and close paraentheses for comment start and end characters.

 

For example, here are the definitions used for the comment begin/end characters:

#Misc. string definitions
sopen_prn    : "("   #String for open parenthesis "(" 
sclose_prn   : ")"   #String for close parenthesis ")"

If your machine used an Acramatic 950 control, the Comment Begin is actual the character string "MSG,", and there is no Comment End character (the end of the line ends the comment).

 

So you would modify the code as follows:

#Misc. string definitions
sopen_prn    : "MSG, "   #String for open parenthesis "(" 
sclose_prn   : ""   #String for close parenthesis ")"

That would output any comment (that was output by making a call to 'pcomment_out') be output with 'MSG, ' in front of the comment string(s), and no end comment character.

 

Some other controls might use a Semi-colon to indicate a commment:

#Misc. string definitions
sopen_prn    : ";"   #String for open parenthesis "(" 
sclose_prn   : ""   #String for close parenthesis ")"
  • Like 1
Link to comment
Share on other sites

Steven can you please put code in like the rest of us?

# --------------------------------------------------------------------------
#String and string selector definitions for NC output
# --------------------------------------------------------------------------

stemp1           : ""    #Temp string
stemp2           : ""    #Temp string
scomm_type       : ""    #
shoriz           : "*" #Horizontal separator, use to help format broken comments
smatch           : "`"   #Delimiter Matching String, use to parse comments into separate lines from one comment string
 

# --------------------------------------------------------------------------
# Tool Comment / Manual Entry Section
# --------------------------------------------------------------------------

pcomment2       #Comment from manual entry
      #1005 - As Comment
      #1006 - As Code
      #1007 - As Comment with output line, change at point
      #1026 - As Code with output line, change at point
      #1008 - Operation comment

      #1051 - Machine Name
      #1052 - Group Comment
      #1053 - Group Name
      #1054 - File Descriptor

      spaces$ = 0
      scomm$ = ucase (scomm$)
      if gcode$ = 1052, scomm_fx_arg = scomm$, pcomment_out  #Group comment
      if sof & gcode$ = 1053, scomm_str, "P/NAME= ", scomm$, scomm_end, e$
      if gcode$ = 1005, scomm_fx_arg = scomm$, pcomment_out  #Manual entry - as comment
      #if gcode$ = 1005, n$, pspc, scomm_str, scomm$, scomm_end, e$
      if gcode$ = 1006, n$, pspc, scomm$, e$
      #if gcode$ = 1007, scomm_str, scomm$, scomm_end
      #if gcode$ = 1026, scomm$
      #if gcode$ = 1008 & header = zero, n$, pspc, scomm_str, scomm$, scomm_end, e$
      if gcode$ = 1008, scomm_sav = ucase(scomm$)

      if gcode$ = 1008, scomm_fx_arg = scomm$, pcomment_out  #Operation comment
      if gcode$ = 1051, scomm_fx_arg = scomm$, pcomment_out  #Machine name
      #if gcode$ = 1052, scomm_fx_arg = scomm$, pcomment_out  #Group comment
      if gcode$ = 1053, scomm_fx_arg = scomm$, pcomment_out  #Group name
      if gcode$ = 1054, scomm_fx_arg = scomm$, pcomment_out  #File Descriptor
      spaces$ = sav_spc

pcomment_out #Check comment length, truncate/shorten if necessary
      comm_len = strlen(scomm_str + scomm_end) #Get length of comment begin and end strings
      if comment_mode < two,
        [
        scomm_out = comment_fx(maxnccomment$ - comm_len, scomm_fx_arg, comment_mode)
        scomm_str, no_spc$, scomm_out, no_spc$, scomm_end, e$ #Output truncated comment
        ]
      else, #Break comment into multiple lines of output. Must set 'max nc comment' length in CD to 256, so MP won't truncate the string
        [
         #Search 'scomm_fx_arg' for break character
        str_brk = no$ #Set breaking to zero
        if smatch <> sblank, str_brk = strstr(smatch, scomm_fx_arg)
        if str_brk, #the break character is present.
          [
          #Use this block to parse scomm_fx_arg into separate strings to output
          #The next line outputs a blank line to the NC code file, and the line after is the horizontal seperator
          #*e$
          scomm_str, no_spc$, shoriz, no_spc$, scomm_end, e$
         
          #These IF statements set the 'scomm_type' to report on the type of comment being broken.
          # This is mostly for debugging purposes, to tell you the programmer which comment type is being broken.
          # Even if you remove the message output below with a pound sign, le         
          if gcode$ = 1005, scomm_type = "MANUAL ENTRY COMMENT"
          if gcode$ = 1008, scomm_type = "OPERATION COMMENT"
          if gcode$ = 1051, scomm_type = "MACHINE NAME COMMENT"
          if gcode$ = 1052, scomm_type = "MACHINE GROUP COMMENT"
          if gcode$ = 1053, scomm_type = "GROUP NAME COMMENT"
          if gcode$ = 1054, scomm_type = "FILE DESCRIPTOR COMMENT"
      
          #The next two lines are just a message. Add a pound sign (#) in front of the lines to remove
          #scomm_str, no_spc$, "STRING BREAKING CHARACTER DETECTED IN A", scomm_type, no_spc$, scomm_end, e$
          #scomm_str, no_spc$, "YOUR COMMENTS HAVE BEEN BROKEN AT THE", smatch, "CHARACTER", no_spc$, scomm_end, e$
         
          #The next line converts all comments to uppercase characters
          scomm_fx_arg = ucase(scomm_fx_arg)
         
          #The following 'while' loop breaks the comment into multiple strings, using the 'smatch' character.
          #The default 'smatch' character is the tilde (~), but you can edit the 'smatch' variable definition,
          #  if you wish to change the character used to break the string. For example, replace the "~" with "|" to use the pipe symbol.
          scomm_out = scomm_fx_arg #assign string to scomm_out
          while str_brk > zero,
            [
            stemp1 = brksps(str_brk, scomm_out) #Break string at specified position
            scomm_str, no_spc$, scomm_out, no_spc$, scomm_end, e$ #Output broken comment
            stemp2 = brksps(two, stemp1) #Remove 'smatch' character from front of string
            scomm_out = stemp2 #Set 'scomm_out' back to stemp1, so that it can be broken again
            str_brk = strstr(smatch, scomm_out)
            str_len = strlen(scomm_out)
            if str_brk = zero & str_len > zero, scomm_str, no_spc$, scomm_out, no_spc$, scomm_end, e$ #Output broken comment
            ]
           
          #These two lines output a horizontal separator, then a blank line to the NC file
          scomm_str, no_spc$, shoriz, no_spc$, scomm_end, e$
          ]
        else, #This code reads the string, and breaks using a string length parameter
          [
          comm_brk_len = comm_brk_len - comm_len #subtract comment begin/end strings
          str_len = strlen(scomm_fx_arg) #Get length of comment string
          str_brk = int(str_len / comm_brk_len) #Get number of broken output strings
          if frac(str_len / comm_brk_len), str_brk = str_brk + one #Add one more output if not even division
          scomm_out = scomm_fx_arg #assign string to scomm_out
          while str_brk > zero, #Output broken comments
            [
            stemp1 = brksps(comm_brk_len, scomm_out) #Break string at specified position
            scomm_str, no_spc$, scomm_out, no_spc$, scomm_end, e$ #Output broken comment
            scomm_out = stemp1 #Set 'scomm_out' back to stemp1, so it can be broken again in while loop
            str_brk = str_brk - one #Decrement counter
            ]
          ]
         
        ]
        scomm_out = sblank #Reset scomm_out

 

pheader$         #Call before start of file

      "(Work Offset Info:)", e$
      if stoolplname, "(", stoolplname, ")", *e$, else, "(WHAT OPERATAION?)", e$
      if swcsplcomm, "(", scomm_fx_arg = swcsplcomm, pcomment_out
, ")", *e$, else, "(WHERE IS THE WORKOFFSET?)", e$

Thanks.

Link to comment
Share on other sites

Steven can you please put code in like the rest of us?

# --------------------------------------------------------------------------
#String and string selector definitions for NC output
# --------------------------------------------------------------------------

stemp1           : ""    #Temp string
stemp2           : ""    #Temp string
scomm_type       : ""    #
shoriz           : "*" #Horizontal separator, use to help format broken comments
smatch           : "`"   #Delimiter Matching String, use to parse comments into separate lines from one comment string
 

# --------------------------------------------------------------------------
# Tool Comment / Manual Entry Section
# --------------------------------------------------------------------------

pcomment2       #Comment from manual entry
      #1005 - As Comment
      #1006 - As Code
      #1007 - As Comment with output line, change at point
      #1026 - As Code with output line, change at point
      #1008 - Operation comment

      #1051 - Machine Name
      #1052 - Group Comment
      #1053 - Group Name
      #1054 - File Descriptor

      spaces$ = 0
      scomm$ = ucase (scomm$)
      if gcode$ = 1052, scomm_fx_arg = scomm$, pcomment_out  #Group comment
      if sof & gcode$ = 1053, scomm_str, "P/NAME= ", scomm$, scomm_end, e$
      if gcode$ = 1005, scomm_fx_arg = scomm$, pcomment_out  #Manual entry - as comment
      #if gcode$ = 1005, n$, pspc, scomm_str, scomm$, scomm_end, e$
      if gcode$ = 1006, n$, pspc, scomm$, e$
      #if gcode$ = 1007, scomm_str, scomm$, scomm_end
      #if gcode$ = 1026, scomm$
      #if gcode$ = 1008 & header = zero, n$, pspc, scomm_str, scomm$, scomm_end, e$
      if gcode$ = 1008, scomm_sav = ucase(scomm$)

      if gcode$ = 1008, scomm_fx_arg = scomm$, pcomment_out  #Operation comment
      if gcode$ = 1051, scomm_fx_arg = scomm$, pcomment_out  #Machine name
      #if gcode$ = 1052, scomm_fx_arg = scomm$, pcomment_out  #Group comment
      if gcode$ = 1053, scomm_fx_arg = scomm$, pcomment_out  #Group name
      if gcode$ = 1054, scomm_fx_arg = scomm$, pcomment_out  #File Descriptor
      spaces$ = sav_spc

pcomment_out #Check comment length, truncate/shorten if necessary
      comm_len = strlen(scomm_str + scomm_end) #Get length of comment begin and end strings
      if comment_mode < two,
        [
        scomm_out = comment_fx(maxnccomment$ - comm_len, scomm_fx_arg, comment_mode)
        scomm_str, no_spc$, scomm_out, no_spc$, scomm_end, e$ #Output truncated comment
        ]
      else, #Break comment into multiple lines of output. Must set 'max nc comment' length in CD to 256, so MP won't truncate the string
        [
         #Search 'scomm_fx_arg' for break character
        str_brk = no$ #Set breaking to zero
        if smatch <> sblank, str_brk = strstr(smatch, scomm_fx_arg)
        if str_brk, #the break character is present.
          [
          #Use this block to parse scomm_fx_arg into separate strings to output
          #The next line outputs a blank line to the NC code file, and the line after is the horizontal seperator
          #*e$
          scomm_str, no_spc$, shoriz, no_spc$, scomm_end, e$
         
          #These IF statements set the 'scomm_type' to report on the type of comment being broken.
          # This is mostly for debugging purposes, to tell you the programmer which comment type is being broken.
          # Even if you remove the message output below with a pound sign, le         
          if gcode$ = 1005, scomm_type = "MANUAL ENTRY COMMENT"
          if gcode$ = 1008, scomm_type = "OPERATION COMMENT"
          if gcode$ = 1051, scomm_type = "MACHINE NAME COMMENT"
          if gcode$ = 1052, scomm_type = "MACHINE GROUP COMMENT"
          if gcode$ = 1053, scomm_type = "GROUP NAME COMMENT"
          if gcode$ = 1054, scomm_type = "FILE DESCRIPTOR COMMENT"
      
          #The next two lines are just a message. Add a pound sign (#) in front of the lines to remove
          #scomm_str, no_spc$, "STRING BREAKING CHARACTER DETECTED IN A", scomm_type, no_spc$, scomm_end, e$
          #scomm_str, no_spc$, "YOUR COMMENTS HAVE BEEN BROKEN AT THE", smatch, "CHARACTER", no_spc$, scomm_end, e$
         
          #The next line converts all comments to uppercase characters
          scomm_fx_arg = ucase(scomm_fx_arg)
         
          #The following 'while' loop breaks the comment into multiple strings, using the 'smatch' character.
          #The default 'smatch' character is the tilde (~), but you can edit the 'smatch' variable definition,
          #  if you wish to change the character used to break the string. For example, replace the "~" with "|" to use the pipe symbol.
          scomm_out = scomm_fx_arg #assign string to scomm_out
          while str_brk > zero,
            [
            stemp1 = brksps(str_brk, scomm_out) #Break string at specified position
            scomm_str, no_spc$, scomm_out, no_spc$, scomm_end, e$ #Output broken comment
            stemp2 = brksps(two, stemp1) #Remove 'smatch' character from front of string
            scomm_out = stemp2 #Set 'scomm_out' back to stemp1, so that it can be broken again
            str_brk = strstr(smatch, scomm_out)
            str_len = strlen(scomm_out)
            if str_brk = zero & str_len > zero, scomm_str, no_spc$, scomm_out, no_spc$, scomm_end, e$ #Output broken comment
            ]
           
          #These two lines output a horizontal separator, then a blank line to the NC file
          scomm_str, no_spc$, shoriz, no_spc$, scomm_end, e$
          ]
        else, #This code reads the string, and breaks using a string length parameter
          [
          comm_brk_len = comm_brk_len - comm_len #subtract comment begin/end strings
          str_len = strlen(scomm_fx_arg) #Get length of comment string
          str_brk = int(str_len / comm_brk_len) #Get number of broken output strings
          if frac(str_len / comm_brk_len), str_brk = str_brk + one #Add one more output if not even division
          scomm_out = scomm_fx_arg #assign string to scomm_out
          while str_brk > zero, #Output broken comments
            [
            stemp1 = brksps(comm_brk_len, scomm_out) #Break string at specified position
            scomm_str, no_spc$, scomm_out, no_spc$, scomm_end, e$ #Output broken comment
            scomm_out = stemp1 #Set 'scomm_out' back to stemp1, so it can be broken again in while loop
            str_brk = str_brk - one #Decrement counter
            ]
          ]
         
        ]
        scomm_out = sblank #Reset scomm_out

 

pheader$         #Call before start of file

      "(Work Offset Info:)", e$
      if stoolplname, "(", stoolplname, ")", *e$, else, "(WHAT OPERATAION?)", e$
      if swcsplcomm, "(", scomm_fx_arg = swcsplcomm, pcomment_out
, ")", *e$, else, "(WHERE IS THE WORKOFFSET?)", e$

Thanks.

Hello 5th Axis Consulting,

    I'm using MPMASTER Post, therefore I have to ensure my codes are "UNITED" to make my .PST clean and need.  I'm apologize for that. 

Link to comment
Share on other sites

Hi Steven,

 

My guess is that you are calling the Machine Group comment at a Tool Change. Since the comment is output with every operation, you should only call it at 'pheader'.

Hi Collin,

   Your guess is right, thank you so much for your help.  If someone wonders how I fixed it, this is how I did.

 

 

pcomment2       #Comment from manual entry

      #1005 - As Comment

      #1006 - As Code

      #1007 - As Comment with output line, change at point

      #1026 - As Code with output line, change at point

      #1008 - Operation comment

      #1051 - Machine Name

      #1052 - Group Comment

      #1053 - Group Name

      #1054 - File Descriptor

      spaces$ = 0

      scomm$ = ucase (scomm$)

      if sof & gcode$ = 1053, scomm_str, "P/NAME= ", scomm$, scomm_end, e$ #Group name

      #if gcode$ = 1005, n$, pspc, scomm_str, scomm$, scomm_end, e$

      #if gcode$ = 1006, n$, pspc, scomm$, e$

      #if gcode$ = 1007, scomm_str, scomm$, scomm_end

      #if gcode$ = 1026, scomm$

      #if gcode$ = 1008 & header = zero, n$, pspc, scomm_str, scomm$, scomm_end, e$

      #if gcode$ = 1008, scomm_sav = ucase(scomm$)

      if gcode$ = 1005, scomm_fx_arg = scomm$, pcomment_out  #Manual entry - as comment

      if gcode$ = 1006, scomm_fx_arg = scomm$, pcomment_out  #Manual entry - As Code

      if gcode$ = 1008, scomm_fx_arg = scomm$, pcomment_out  #Operation comment

      iif sof & code$ = 1051, scomm_fx_arg = scomm$, pcomment_out  #Machine name

      if sof & gcode$ = 1052, scomm_fx_arg = scomm$, pcomment_out  #Group comment

      if sof & code$ = 1053, scomm_fx_arg = scomm$, pcomment_out  #Group name

      if sof & gcode$ = 1054, scomm_fx_arg = scomm$, pcomment_out  #File Descriptor

      spaces$ = sav_spc

 

-------------------------------------------

 

Once again, thank you everyone in this forum have been helping me successfully to do write the right post for the right job on the floor.  THANK YOU.

 

PS: I tried to call out FILE DESCRIPTOR which under FILE - PROPERTIES of the file and I typed some notes and didn't work.  Don't know why, do you why?  Thank you.

 

      if sof & gcode$ = 1054, scomm_fx_arg = scomm$, pcomment_out  #File Descriptor

https://drive.google.com/file/d/0B4UZsmondnEzald3OHk4Z3Mxbms/view?usp=sharing

Link to comment
Share on other sites

I m talking about when posting things to the forum not what you are doing on your computer.

 

Makes it easier to sort out when you are putting code from a post or a NC program to use the code snippet tool for the forum.

pcomment2       #Comment from manual entry
      #1005 - As Comment
      #1006 - As Code
      #1007 - As Comment with output line, change at point
      #1026 - As Code with output line, change at point
      #1008 - Operation comment

      #1051 - Machine Name
      #1052 - Group Comment
      #1053 - Group Name
      #1054 - File Descriptor

      spaces$ = 0
      scomm$ = ucase (scomm$)
      if sof & gcode$ = 1053, scomm_str, "P/NAME= ", scomm$, scomm_end, e$ #Group name
      #if gcode$ = 1005, n$, pspc, scomm_str, scomm$, scomm_end, e$
      #if gcode$ = 1006, n$, pspc, scomm$, e$
      #if gcode$ = 1007, scomm_str, scomm$, scomm_end
      #if gcode$ = 1026, scomm$
      #if gcode$ = 1008 & header = zero, n$, pspc, scomm_str, scomm$, scomm_end, e$
      #if gcode$ = 1008, scomm_sav = ucase(scomm$)
      if gcode$ = 1005, scomm_fx_arg = scomm$, pcomment_out  #Manual entry - as comment
      if gcode$ = 1006, scomm_fx_arg = scomm$, pcomment_out  #Manual entry - As Code
      if gcode$ = 1008, scomm_fx_arg = scomm$, pcomment_out  #Operation comment
      iif sof & code$ = 1051, scomm_fx_arg = scomm$, pcomment_out  #Machine name
      if sof & gcode$ = 1052, scomm_fx_arg = scomm$, pcomment_out  #Group comment

      if sof & code$ = 1053, scomm_fx_arg = scomm$, pcomment_out  #Group name
      if sof & gcode$ = 1054, scomm_fx_arg = scomm$, pcomment_out  #File Descriptor
      spaces$ = sav_spc
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...