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:

Operation comment question


Recommended Posts

Hello,

I am using MP post for 3x VMC, I have edit the post to move M01 from before M06 to after M06 like the code I have pasted here.

Quote

G5.1 Q1
(ROUGH OUTSIDE)
(COMPENSATION TYPE - WEAR COMP)
N1 T18 M6
M01
 (2 INCH SHELL MILL 4.5 LOT)
( MAX -  Z2. )
( MIN -  Z-4.3016 )
G00 G17 G90 G54 X-3.025 Y-1.25 S8500 M03
G43 H18 Z2. T1
M08
Z.1

My question is how can I edit the post to move the operation comment location like this one

Quote

G00 G17 G20 G40 G80 G90
G91 G28 Z0.
G5.1 Q1
(ROUGH OUTSIDE)  <--- Move from here
(COMPENSATION TYPE - WEAR COMP)
N1 T18 M6
M01
 (2 INCH SHELL MILL 4.5 LOT)
(ROUGH OUTSIDE) <--- to here
( MAX -  Z2. )
( MIN -  Z-4.3016 )
G00 G17 G90 G54 X-3.025 Y-1.25 S8500 M03
G43 H18 Z2. T1
M08
Z.1
G G01 Z.05 F150.

 

Thank you very much

Link to comment
Share on other sites

You will need to move the location of the 'comment$' Command Variable.

Typically, the 'comment$' command is setup to "dump all the buffered comment strings", at whatever location you see that Command Variable.

'comment$' needs to be on a line, all by itself. (It must also have at least 1 space character in front of it. Typical "indent" spacing is 6 space characters.)

So, in your existing Post, locate the line of code that has 'comment$' on it, and place a Pound Sign (or Hash Mark, depending on your word choice). [ # ]

This will 'comment out' the line of code.

Now, simply insert a new blank line, after the line where your "M01" is coming out, and then enter  '     comment$'.

Your Operation Comment will be output after the "M01" line.

Link to comment
Share on other sites
11 hours ago, Colin Gilchrist said:

You will need to move the location of the 'comment$' Command Variable.

Typically, the 'comment$' command is setup to "dump all the buffered comment strings", at whatever location you see that Command Variable.

'comment$' needs to be on a line, all by itself. (It must also have at least 1 space character in front of it. Typical "indent" spacing is 6 space characters.)

So, in your existing Post, locate the line of code that has 'comment$' on it, and place a Pound Sign (or Hash Mark, depending on your word choice). [ # ]

This will 'comment out' the line of code.

Now, simply insert a new blank line, after the line where your "M01" is coming out, and then enter  '     comment$'.

Your Operation Comment will be output after the "M01" line.

Thank you for your rely,

I have try to edit my post file like this but still not worked.

Quote

ptlchg_com      #Tool change common blocks
      if force_output | sof,
        [
        result = force(ipr_type,ipr_type)
        result = force(absinc$,absinc$)
        result = force(plane$,plane$)
        ]
      pcom_moveb
      pcheckaxis      #Check for valid rotary axis
      if sof, uninhibit_probe$
      c_mmlt$ #Multiple tool subprogram call
      #ptoolcomment
      if sof & scomm_sav <> snull,
        [
        spaces$ = 0
        n$, pspc, scomm_str, *scomm_sav, scomm_end, e$
        spaces$ = sav_spc
        ]
      if sof = 0, scomm_sav = snull
      #comment$
      #pcomment3
      pmisccheck
      pcan
      if stagetool >= zero,
        [
        if omitseq$ = 1 & tseqno > 0,
          [
          if tseqno = 2, n$ = t$
          pbld, *n$, *t$, *sm06, e$
          pbld, n$, *sm01, e$
          comment$
          pbld, n$, ptoolcomm, e$
          ]
        else, [
        pbld, n$, *t$, *sm06, e$
        pbld, n$, *sm01, e$
        comment$
        pbld, n$, ptoolcomm, e$
        ]
        ]
      spaces$=0
      if output_z = yes$,

and here is my nc file

Quote

G00 G17 G20 G40 G80 G90
G91 G28 Z0.
G5.1 Q1
(SPOT DRILL M4 HOLE)
M08
N1 T5 M6
M01
 (3/8 SPOTDRILL 3.75 LOT)
(MAX - Z2.)
(MIN - Z-.0675)
G00 G17 G90 G55 X5.1378 Y-.8573 S2000 M03
G43 H5 Z2. T9
Z.1

there is something wrong with my post?

 

Thank you

Link to comment
Share on other sites

Thank you Colin, I have make my post work by add the code for comment

Quote

if stagetool >= zero,
        [
        if omitseq$ = 1 & tseqno > 0,
          [
          if tseqno = 2, n$ = t$
          pbld, *n$, *t$, *sm06, e$
		  pbld, n$, *sm01, e$ 
		  #pbld, n$, ptoolcomm, e$
          ]		  	  
        else, [
		pbld, n$, *t$, *sm06, e$
		pbld, n$, *sm01, e$
		#pbld, n$, ptoolcomm, e$
        ]	
		]
        [
        spaces$ = 0
		comment$
		"(",*t$, "-",pstrtool, ")", e$
        ]

I have another question the line 

Quote

"(",*t$, "-",pstrtool, ")", e$

I used that line for Tool number and comment so the Setup guy can check with tool list. But my question is does it is proper code to use?

here is my nc code output

Quote

G5.1Q1
(SPOT DRILL M4 HOLE)
N5 T5 M06
M01
(T5-3/8 SPOTDRILL 3.75 LOT )
(MAX - Z2.)
(MIN - Z-.0675)
G00 G17 G90 G55 X5.1378 Y-.8573 S2000 M03
G43 H5 Z2. T9
M08
....
.
.
.
.
N9 T9 M06
M01
(DRILL M3 HOLE DEPTH 0.259)
(T9-0.0995 DRILL #39 )
(MAX - Z2.)
(MIN - Z-.4253)
G00 G17 G90 G55 X6.4961 Y-.7874 S3500 M03
G43 H9 Z2. T10

The first tool still do not have the operation comment. 

Can anyone tell me how to fix it or which post block to looking for.

Thank you

Best Regard

Link to comment
Share on other sites
  • 4 years later...
On 6/7/2020 at 10:14 AM, akuser said:

Hello,

I am using MP post for 3x VMC, I have edit the post to move M01 from before M06 to after M06 like the code I have pasted here.

My question is how can I edit the post to move the operation comment location like this one

 

Thank you very much


I don't know this is what you need as below but I have done it.  It worked really well.  I have separated the comment from the built-in "comment$ # AS CODE here, originally"

================
G-CODE SAMPLE...
 

N14(FINISH 90 DEG, SHT1, B7, CUT#25)
G0 G17 G40 G49 G80 G90
G53 Z0. M19
T14 M6(T14, 1/2"X90DEG SPOT DRILL)
G0 G17 G90 G55
X-.2119 Y0. S6000 M3
G43 H14 Z1.(DOC= Z-.24)
M8
Z.125
G1 Z-.115 F25.
G41 D14 X-.2229 Y.011 Z-.24 F12.5
(CUTTING...)
G3 X-.2254 Y-.0173 I.0156 J0.
G1 G40 X-.2144 Y-.0063 Z-.115
G0 Z1.
M9(19.79SECs)
G53 Z0. M5
G53 Y0. M19
M30
%
(1.184 KB)

 

================

sOperationComment       : ""   #String for Operation Comment for Transform


#Region, Comment from manual entry
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$ >= 1051, scomm_str, scomm$, scomm_end, e$
      #if gcode$ = 1005, n$, pspc, scomm_str, scomm$, scomm_end, e$ =================> ENSURE TO DISABLE THIS...

      #if gcode$ = 1006 & ForceToolChange = 0 & not(xform_type | mirror_flg | mirror_dir) & #Check if M0 and Force Tool Change is not used while using Manual Entry As Code
       #strstr ("M0", scomm$) & (prv_t$ = t$), [if mprint(sManualEntryAsCode), exitpost$]

      if gcode$ = 1006, scomm$, e$ # As Code
	  #if gcode$ = 1006 & strstr ("CLAMP", scomm$) & (abs(ClearancePlaneValue)< 2.9999), [if mprint(sIndexHeigthCheck, 2) = 2, exitpost$ ], e$ #
	  #if gcode$ = 1006 & strstr ("CLAMP", scomm$) & ((ClearancePlaneValue) - (RetractPlaneValue) < 1.9999), [if mprint(sIndexRetractValueWarn, 2) = 2, exitpost$ ], e$ #
	  
      if gcode$ = 1007, scomm_str, scomm$, scomm_end # As Comment with output line, change at point
      if gcode$ = 1026, scomm$
      #if sof & gcode$ = 1052, scomm_str, scomm$, scomm_end # Group Comment
      #if gcode$ = 1053, scomm_str, scomm$, scomm_end
      #if gcode$ = 1008 & header = zero, n$, pspc, scomm_str, scomm$, scomm_end, e$
      #if gcode$ = 1008, scomm_sav = ucase(scomm$)
      #if sof & gcode$ = 1054, scomm_fx_arg = scomm$, scomm_sav  #File Descriptor
      spaces$ = sav_spc
#EndRegion, Comment from manual entry
 
#Region pparameter$
pparameter$ # Run parameter table
           #"pparameter", ~prmcode$, ~sparameter$, e$
           if prmcode$ = 15239,
            [
             sOperationComment = sparameter$ #Capture the Operation Comment
            ]
#EndRegion pparameter$


#Region, ptlchg_com
ptlchg_com      #Tool change common blocks
      ToolSequenceNumber = t$
      PToolSquenceFirstTimeUsed
      *ToolSequenceNumber, no_spc$, scomm_str, no_spc$, sOperationComment, no_spc$, ", CUT#", no_spc$, sToolPathNumber, no_spc$, scomm_end, e$ #FIRST TOOL SEQUENCE

      pbld, *sgcode, "G17", "G40", "G49", "G80", *sgabsinc, e$ # FIRST SAFETY LINE
      #pbld, sgabsinc, *sg28, "Z0.", e$ # First Z0.
      if strstr ("VERT", sMachineDefinitionManagerDescription),
       [
        "G53 Z0. M19", no_spc$, e$#

        #pCircleMill, pHelix, pSlotMill, pMultiPass, pPocket, PThreadMill, pChamferCounts, pChamfer
       ]

      if strstr ("HORI", sMachineDefinitionManagerDescription),
       [
        "G91 G28 Z0.", e$ # First Z0.
       ]
#EndRegion, ptlchg_com
Link to comment
Share on other sites
3 hours ago, S.Luong said:


I don't know this is what you need as below but I have done it.  It worked really well.  I have separated the comment from the built-in "comment$ # AS CODE here, originally"

================
G-CODE SAMPLE...
 

N14(FINISH 90 DEG, SHT1, B7, CUT#25)
G0 G17 G40 G49 G80 G90
G53 Z0. M19
T14 M6(T14, 1/2"X90DEG SPOT DRILL)
G0 G17 G90 G55
X-.2119 Y0. S6000 M3
G43 H14 Z1.(DOC= Z-.24)
M8
Z.125
G1 Z-.115 F25.
G41 D14 X-.2229 Y.011 Z-.24 F12.5
(CUTTING...)
G3 X-.2254 Y-.0173 I.0156 J0.
G1 G40 X-.2144 Y-.0063 Z-.115
G0 Z1.
M9(19.79SECs)
G53 Z0. M5
G53 Y0. M19
M30
%
(1.184 KB)

 

================

sOperationComment       : ""   #String for Operation Comment for Transform


#Region, Comment from manual entry
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$ >= 1051, scomm_str, scomm$, scomm_end, e$
      #if gcode$ = 1005, n$, pspc, scomm_str, scomm$, scomm_end, e$ =================> ENSURE TO DISABLE THIS...

      #if gcode$ = 1006 & ForceToolChange = 0 & not(xform_type | mirror_flg | mirror_dir) & #Check if M0 and Force Tool Change is not used while using Manual Entry As Code
       #strstr ("M0", scomm$) & (prv_t$ = t$), [if mprint(sManualEntryAsCode), exitpost$]

      if gcode$ = 1006, scomm$, e$ # As Code
	  #if gcode$ = 1006 & strstr ("CLAMP", scomm$) & (abs(ClearancePlaneValue)< 2.9999), [if mprint(sIndexHeigthCheck, 2) = 2, exitpost$ ], e$ #
	  #if gcode$ = 1006 & strstr ("CLAMP", scomm$) & ((ClearancePlaneValue) - (RetractPlaneValue) < 1.9999), [if mprint(sIndexRetractValueWarn, 2) = 2, exitpost$ ], e$ #
	  
      if gcode$ = 1007, scomm_str, scomm$, scomm_end # As Comment with output line, change at point
      if gcode$ = 1026, scomm$
      #if sof & gcode$ = 1052, scomm_str, scomm$, scomm_end # Group Comment
      #if gcode$ = 1053, scomm_str, scomm$, scomm_end
      #if gcode$ = 1008 & header = zero, n$, pspc, scomm_str, scomm$, scomm_end, e$
      #if gcode$ = 1008, scomm_sav = ucase(scomm$)
      #if sof & gcode$ = 1054, scomm_fx_arg = scomm$, scomm_sav  #File Descriptor
      spaces$ = sav_spc
#EndRegion, Comment from manual entry
 
#Region pparameter$
pparameter$ # Run parameter table
           #"pparameter", ~prmcode$, ~sparameter$, e$
           if prmcode$ = 15239,
            [
             sOperationComment = sparameter$ #Capture the Operation Comment
            ]
#EndRegion pparameter$


#Region, ptlchg_com
ptlchg_com      #Tool change common blocks
      ToolSequenceNumber = t$
      PToolSquenceFirstTimeUsed
      *ToolSequenceNumber, no_spc$, scomm_str, no_spc$, sOperationComment, no_spc$, ", CUT#", no_spc$, sToolPathNumber, no_spc$, scomm_end, e$ #FIRST TOOL SEQUENCE

      pbld, *sgcode, "G17", "G40", "G49", "G80", *sgabsinc, e$ # FIRST SAFETY LINE
      #pbld, sgabsinc, *sg28, "Z0.", e$ # First Z0.
      if strstr ("VERT", sMachineDefinitionManagerDescription),
       [
        "G53 Z0. M19", no_spc$, e$#

        #pCircleMill, pHelix, pSlotMill, pMultiPass, pPocket, PThreadMill, pChamferCounts, pChamfer
       ]

      if strstr ("HORI", sMachineDefinitionManagerDescription),
       [
        "G91 G28 Z0.", e$ # First Z0.
       ]
#EndRegion, ptlchg_com

We talked about this. I agreed you would never, EVER post walls of text like this again. :twak: 

 

image.png.15e9948a842f82679b2f912ca0b857c7.png

  • Haha 2
Link to comment
Share on other sites
On 1/10/2025 at 5:26 PM, S.Luong said:

 

Mr.Saturday, I am trying to help the guy who used to be like me 10 years ago about post.  If I help anyone, I want to ensure they can do it.

It's (mostly) a joke. But if you put the text walls in a quote it will truncate it so the other people can choose to see it. Have a look at your post above this one, see how it truncated the quoted text? Or look at both methods as posted below. :) 

Quote

Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")

Dim proofedFolder
proofedFolder = "Q:\Proven Programs"

Dim newFolder
newFolder = "Q:\New Programs"

Dim fileExtension
fileExtension = ".PIM"

Sub Main

    Do
        ' Get the list of files in the Proofed Programs folder
        Dim files
        Set files = fso.GetFolder(proofedFolder).Files

        ' Check each file
        For Each file In files
            ' Check if the file has the correct extension
            If fso.GetExtensionName(file.Name) = "PIM" Then
                ' Parse the file name
                Dim parsedFileName
                parsedFileName = ParseFileName(file.Name)
                ' If the file name was parsed successfully
                If parsedFileName <> "" Then
                    ' Construct the full path to the corresponding file in the New Programs folder
                    Dim newFilePath
                    newFilePath = newFolder & "\" & parsedFileName
        msgbox newfilepath
                    ' Check if the corresponding file exists in the New Programs folder
                    If fso.FileExists(newFilePath) Then
        msgbox newfilepath & " exists"
                        ' Remove the corresponding file
                        fso.DeleteFile newFilePath, True
                        WScript.Echo "Removed " & newFilePath
                    Else
        msgbox newfilepath & " does not exist"
                    End If
                End If
            End If
        Next

        ' Sleep for 2 second
        WScript.Sleep 2000
        msgbox "Looping"
    Loop
End Sub

Function ParseFileName(fileName)
    ' Remove the leading zeros
    Dim regex
    Set regex = New RegExp
    regex.Pattern = "^0+"
    regex.Global = True
    ParseFileName = regex.Replace(fileName, "")
End Function

Call Main

The code function used to truncate it too but I don't think it does any more. Ahem, admin, looking at you. :) 

Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")

Dim proofedFolder
proofedFolder = "Q:\Proven Programs"

Dim newFolder
newFolder = "Q:\New Programs"

Dim fileExtension
fileExtension = ".PIM"

Sub Main

    Do
        ' Get the list of files in the Proofed Programs folder
        Dim files
        Set files = fso.GetFolder(proofedFolder).Files

        ' Check each file
        For Each file In files
            ' Check if the file has the correct extension
            If fso.GetExtensionName(file.Name) = "PIM" Then
                ' Parse the file name
                Dim parsedFileName
                parsedFileName = ParseFileName(file.Name)
                ' If the file name was parsed successfully
                If parsedFileName <> "" Then
                    ' Construct the full path to the corresponding file in the New Programs folder
                    Dim newFilePath
                    newFilePath = newFolder & "\" & parsedFileName
		msgbox newfilepath
                    ' Check if the corresponding file exists in the New Programs folder
                    If fso.FileExists(newFilePath) Then
		msgbox newfilepath & " exists"
                        ' Remove the corresponding file
                        fso.DeleteFile newFilePath, True
                        WScript.Echo "Removed " & newFilePath
					Else
		msgbox newfilepath & " does not exist"
                    End If
                End If
            End If
        Next

        ' Sleep for 2 second
        WScript.Sleep 2000
		msgbox "Looping"
    Loop
End Sub

Function ParseFileName(fileName)
    ' Remove the leading zeros
    Dim regex
    Set regex = New RegExp
    regex.Pattern = "^0+"
    regex.Global = True
    ParseFileName = regex.Replace(fileName, "")
End Function



Call Main

 

  • Like 1
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...