Dhananjay @Mastercam India

Macro Variable Value Increment is not getting

Recommended Posts

Hello everyone, 

I need help in below macro variable value  addition with the  increment of  1  

if macro_active,      #25/06/20
	  [ 
	  submacro = 101
	  if angle_from_x_plus <> prv_angle_from_x_plus, submacro = 101 + n$
	  pbld, *submacro, no_spc$, *angle_from_x_plus, e$
	  ]

Result= 

#101= 

#102=

#103= 

so on ......

Share this post


Link to post
Share on other sites

I'm not seeing what you're wanting here...  Can you share a zip2go and posted code edited to what you want?

Share this post


Link to post
Share on other sites

n$ may not be the best variable to use since it can be used in a lot of places and might be incrementing at each location. You might be better of to create a new variable that you increment instead. Or initialize submacro at 100, and just add 1 to that variable at each instance.

 

 

  • Like 1

Share this post


Link to post
Share on other sites
On 7/1/2020 at 1:34 AM, Alex Dales said:

n$ may not be the best variable to use since it can be used in a lot of places and might be incrementing at each location. You might be better of to create a new variable that you increment instead. Or initialize submacro at 100, and just add 1 to that variable at each instance.

 

 

Thank You sir ! I'm getting correct increment value 

submacro : 100 (By  initialization the Numeric variable  )

Share this post


Link to post
Share on other sites

Also, be careful to recognize changes to Variable Modality.

  • The 'prv_' variable value only gets updated when a value is output to the NC File.
  • If you are only using a variable "internally" in your Post calculations, then the 'prv_' value will never be updated, because the 'current value' of the variable is never written to the NC File, so the 'replace prv_ value with current' action never takes place.
  • If the variable is only used by you 'internally', then you can use the "Update Variable Modifier" (!) by putting the Exclamation Mark in front of the variable name. You must be careful to do this "at the end of the intended action", since you only want that 'update action' to take place "once", before you loop around to test the condition again.
  • This is why you will typically see the "variable updates" at the end of a major post block, like 'posf$', 'ptlchg$', and 'ptlchg0$'.

This is from 'MPFAN.PST', notice the "Variable Updates" at the end of the Post Block:

ptlchg$          #Tool change
      pcuttype
      toolchng = one
      if mi1$ = one, #Work coordinate system
        [
        pfbld, n$, *sg28ref, "X0.", "Y0.", e$
        pfbld, n$, sg92, *xh$, *yh$, *zh$, e$
        ]
      inhibit_probe$
      if prog_stop = 1, pbld, n$, *sm01, e$
      if prog_stop = 2, pbld, n$, *sm00, e$
      pcom_moveb
      pcheckaxis
      c_mmlt$ #Multiple tool subprogram call
      ptoolcomment
      comment$
      pcan
      result = newfs(15, feed)  #Reset the output format for 'feed'
      pbld, n$, *t$, sm06, e$
      pindex
      sav_absinc = absinc$
      if mi1$ > one, absinc$ = zero
      if use_rot_lock & (cuttype <> zero | (index = zero & prv_cabs <> fmtrnd(cabs))), prot_unlock
      if convert_rpd$, pconvert_rpd
      pcan1, pbld, n$, [if gcode$, *sgfeed], *sgcode, *sgabsinc, pwcs, pfxout, pfyout, pfcout,
        [if nextdc$ <> 7, *speed, *spindle], pgear, [if gcode$, *feed], strcantext, e$
      if use_rot_lock & cuttype = zero, prot_lock
      pbld, n$, sg43, *tlngno$, pfzout, pscool, pstagetool, e$
      absinc$ = sav_absinc
      pbld, n$, sgabsinc, e$
      pcom_movea
      toolchng = zero
      c_msng$ #Single tool subprogram call
      !xnci$, !ynci$, !znci$

 

  • Like 1

Share this post


Link to post
Share on other sites
On 7/8/2020 at 9:01 PM, Colin Gilchrist said:

Also, be careful to recognize changes to Variable Modality.

  • The 'prv_' variable value only gets updated when a value is output to the NC File.
  • If you are only using a variable "internally" in your Post calculations, then the 'prv_' value will never be updated, because the 'current value' of the variable is never written to the NC File, so the 'replace prv_ value with current' action never takes place.
  • If the variable is only used by you 'internally', then you can use the "Update Variable Modifier" (!) by putting the Exclamation Mark in front of the variable name. You must be careful to do this "at the end of the intended action", since you only want that 'update action' to take place "once", before you loop around to test the condition again.
  • This is why you will typically see the "variable updates" at the end of a major post block, like 'posf$', 'ptlchg$', and 'ptlchg0$'.

This is from 'MPFAN.PST', notice the "Variable Updates" at the end of the Post Block:

ptlchg$          #Tool change
      pcuttype
      toolchng = one
      if mi1$ = one, #Work coordinate system
        [
        pfbld, n$, *sg28ref, "X0.", "Y0.", e$
        pfbld, n$, sg92, *xh$, *yh$, *zh$, e$
        ]
      inhibit_probe$
      if prog_stop = 1, pbld, n$, *sm01, e$
      if prog_stop = 2, pbld, n$, *sm00, e$
      pcom_moveb
      pcheckaxis
      c_mmlt$ #Multiple tool subprogram call
      ptoolcomment
      comment$
      pcan
      result = newfs(15, feed)  #Reset the output format for 'feed'
      pbld, n$, *t$, sm06, e$
      pindex
      sav_absinc = absinc$
      if mi1$ > one, absinc$ = zero
      if use_rot_lock & (cuttype <> zero | (index = zero & prv_cabs <> fmtrnd(cabs))), prot_unlock
      if convert_rpd$, pconvert_rpd
      pcan1, pbld, n$, [if gcode$, *sgfeed], *sgcode, *sgabsinc, pwcs, pfxout, pfyout, pfcout,
        [if nextdc$ <> 7, *speed, *spindle], pgear, [if gcode$, *feed], strcantext, e$
      if use_rot_lock & cuttype = zero, prot_lock
      pbld, n$, sg43, *tlngno$, pfzout, pscool, pstagetool, e$
      absinc$ = sav_absinc
      pbld, n$, sgabsinc, e$
      pcom_movea
      toolchng = zero
      c_msng$ #Single tool subprogram call
      !xnci$, !ynci$, !znci$

 

 Thank You sir ! For quick guide line 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • 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