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:

Post out operation name when the sub is called on the same line as the callout


Recommended Posts

Hello all

I have a question about posting out the operation name when I call for the sub?  I would like it on the same line as the callout. (see program example below)

Is it possible to do this?

I can post out a generic statement but not the operation comment itself.

from my post:

pbore2$          #Canned Bore #2 Cycle     #DJ  CHANGED TO A G66 OUTPUT
    drilgcode = 2
      pdrlcommonb
      pcan1, pbld, n$, *sgdrill, dwell$, pdrillparam1, "( TYPE OPERATION HERE SUB )", e$ #pbore2$ set to post a G66

 

( THROUGH HOLES / BALL SURFACES )     <-----------------------------------------------------------------
N100 M01
#752=#4314 (CURRENT BLOCK FOR TOOL BREAKAGE RERUN)
#753=0.
#720=0. (COMPLETED PART COUNTER)
G00 G17 G21 G64 G40
G69 G80 G90 G94 G98
G91 G28 Z0.
M31L4 (SET MACHINING MODE LEVEL)
M06 T02 ( 1.5 SPHERICAL / BALL-NOSED ENDMILL )
G65P8001 (TOOL LENGTH CALC SUB)
S23000 M03
G00 G90 G54 X-241.3 Y-43.0
G5.1 Q1. (HIGH SPEED MACHINING ON)
G43 H122 Z5.
M08
G04 X3.0 (WAIT FOR COOLANT)
G66 P0681 F750. (THROUGH HOLES / BALL SURFACES SUB)        <-----------------------------------------------------------------

 

Any suggestions would be greatly appreciated

Thanks and stay safe

Joey

Link to comment
Share on other sites
On 3/23/2020 at 3:37 PM, Joeyls319 said:

Sorry, forgot to mention we're running MasterCam 2019

 

I would think you would have to parse it out into a comment and then pull the comment variable like post does for other comments. Like I see that it is not referencing the variable comment which is what MP post use for controlling this.

Link to comment
Share on other sites

I tried the following and it didn't work.

 

pbore2$          #Canned Bore #2 Cycle     #DJ  CHANGED TO A G66 OUTPUT
    drilgcode = 2
      pdrlcommonb
      pcan1, pbld, n$, *sgdrill, dwell$, pdrillparam1, "(" comment$, ")", e$ #pbore2$ set to post a G66
Link to comment
Share on other sites
9 minutes ago, Joeyls319 said:

I tried the following and it didn't work.

 


pbore2$          #Canned Bore #2 Cycle     #DJ  CHANGED TO A G66 OUTPUT
    drilgcode = 2
      pdrlcommonb
      pcan1, pbld, n$, *sgdrill, dwell$, pdrillparam1, "(" comment$, ")", e$ #pbore2$ set to post a G66

That is wrong.

You need a comma after the "(", <-- Like so and try that.

Link to comment
Share on other sites
19 hours ago, Joeyls319 said:

Not quite following you here.  I don't see a "pscomm" in my post.  Is that a comment section I would have to create in my post?

 

Hi Joey,

 

Try looking for pcomment$ or pcomment2 instead. pcomment$ can be called multiple times by a single comment$ call and is used to read in comments, manual entries, machine name, etc.

If you write a string variable using scomm$ when gcode$ is 1008 that will save out the operation comment.

mpmaster already does this using a  variable called scomm_sav to prevent the operation comment from being output in the header of the post, and move it to the first toolchange.

You might even be able to get away with calling scomm_sav in pbore2$ where you currently have comment$.

Just note that this will only work correctly if your operation comment is a single line. If you want multi-line support you will need use a buffer to store out the comments, in which case I would recommend going through your reseller to get a dedicated post developer like me to take care of it for you :)

 

Alex

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

Alex

Sorry it's been a few weeks since I was working on this.  Not quite following you here.  Can you post an example please?

I also tried doing what Gunther suggested and that's not working either.

What I'm looking to do is inserting the group name right after my sub callout

G66 P0681 F750. (THROUGH HOLES / BALL SURFACES SUB)        <-------------------------------------- Group name ------------------------

Link to comment
Share on other sites
19 minutes ago, Joeyls319 said:

Alex

Sorry it's been a few weeks since I was working on this.  Not quite following you here.  Can you post an example please?

I also tried doing what Gunther suggested and that's not working either.

What I'm looking to do is inserting the group name right after my sub callout

G66 P0681 F750. (THROUGH HOLES / BALL SURFACES SUB)        <-------------------------------------- Group name ------------------------

Joey,

Do you want the "Toolpath Group Name String", or the "Operation Name String" (For example; from the Drill Operation that created the code output you posted)?

If you want the Toolpath Group Name, you can grab it from the NCI 1052 Line. This is processed in 'pcomment2' Post Block. You would simply need to add a user-defined String Variable, and inside "pcomment2", you would set your user-defined variable equal to the NCI 1052 Comment String. (NOTE: for this to work, you must have some switches enabled inside the MD/CD Files, so that "group comments" are enabled!) The Operation Comment is processed as NCI 1008 Strings.

Then, inside 'pbore2$', you'd simply check to see if "sgrp_comm <> sblank", and use that to determine what comment string to output.

Now, in order to do this "properly", you need to check "where" you are dumping the comments. In other words, where is your 'comment$' keyword?

Depending on exactly where in the Post your comment command variable is located, you may need to "test" the value of 'nextdc$'. The variable 'nextdc$' gives you access to tell the Post "which drill cycle is coming up next in the NCI data?". So if you test "if nextdc$ = 5", you can tell if the "bore 2 cycle" was selected in the Mastercam interface. (Note: the index is "zero-based", so "simple drill means nextdc$ = 0, peck = 1, chip = 2, tap = 3, bore1 = 4, and bore2 = 5.)

 

Link to comment
Share on other sites

Colin

I'm looking to insert the Toolpath group name.

I turned on my switches in the control definition.

Here's what I have for pbore2$:

pbore2$          #Canned Bore #2 Cycle     #DJ  CHANGED TO A G66 OUTPUT
    drilgcode = 2
      pdrlcommonb
      pcan1, pbld, n$, *sgdrill, dwell$, pdrillparam1, sopen_prn, scomm$, sclose_prn, e$
      pbld, n$, pfxout, pfyout, e$ #force out X and Y again for 1st cycle
      pcom_movea

 

 

Link to comment
Share on other sites

Hi Joey,

Use scomm_sav to output the operation comment inline.

pcan1, pbld, n$, *sgdrill, dwell$, pdrillparam1, sopen_prn, scomm_sav, sclose_prn, e$

scomm_sav is set in pcomment$ or pcomment2

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$
      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$) #<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<THIS LINE
      spaces$ = sav_spc

 

If you wanted to use the group name instead, you could create a new string variable, and use that with gcode$ = 1053

      if gcode$ = 1053, scomm_sav2 = ucase(scomm$)

 

  • Thanks 1
Link to comment
Share on other sites
52 minutes ago, Peter from S.C.C.C. said:

Loving the syntax of the mp language! 

When I write my first programming language, I will definetly include $ signs in it as well! :rofl:

The "dollar sign" indicator was a huge help. In the MP Language, prior to "Mastercam X" being released, there was simply a "list of predefined variables", with no syntactical difference between a user-defined variable, and a predefined variable.

This led many people astray, as you were often likely to define your own variable, only to find out during runtime that you'd get an error, due to that variable already being defined elsewhere. (In fact, predefined variables are defined inside the MP.dll Post Engine, itself.)

With the release of Mastercam X, predefined variables, Post Blocks, and Strings, all include a Dollar Sign as a token, to indicate that the variable is indeed a predefined variable.

If you use the Mastercam Code Expert Editor, there are internal lists of predefined variables, functions, strings, and operators, and an auto-complete list that populates as you type (ESC to temporarily disable the pop-up list as you are typing).

By using the Code Expert Editor, you get auto-highlighting, allowing you to use existing NCI and command variables with increased confidence.

Link to comment
Share on other sites

Rather than use MP's comment mechanism, query parameter 15239.

s_op_comment : ""

p_any_postblock
    # Get the op comment of the current operation
    s_op_comment = opinfo(15239, 0, 0000)

    # If we are in a transform operation, we can query the soure operation...
    s_op_comment = opinfo(15239, 0, 0000)

    # ...or we can query the transform parameters.
    s_op_comment = opinfo(15239, 0, 0010)

 

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