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:

Inch to MM conversion within post


Recommended Posts

Morning All.

I run a post from IMS in CATIA that converts inches to mm within the post.

 

My question....is it possible to do this in a MC post?

 

Note: I know how to convert inch to metric files within MC and do not like the process...nor the problems it causes.  I want a solution outside of MC.

 

Thank you,

Rob

Link to comment
Share on other sites

Yes, I'd simply setup a Global Formula at the top of the Post to control the output values. I would only recommend doing this for 3X or 4X Positioning work. It *may* work for 4X or 5X continuous, but there are a bunch of other calculations that are happening internally, so I wouldn't trust it for 4X/5X work without a good review.

First, create a new Format Statement in the Post. (put it below the others)

fs2 30  0.9 0.9   #Format 9 decimal places for Metric Conversion

Then, add these codes,  at the top of your post, starting in the first column:

met_conv : 0.039370078

fmt  ""  30  met_conv

xout = xout * met_conv
yout = yout * met_conv
zout = zout * met_conv
arcrad$ = arcrad$ * met_conv
iout = iout * met_conv
jout = jout * met_conv
kout = kout * met_conv

 

  • Like 1
Link to comment
Share on other sites
16 hours ago, Colin Gilchrist said:

Yes, I'd simply setup a Global Formula at the top of the Post to control the output values. I would only recommend doing this for 3X or 4X Positioning work. It *may* work for 4X or 5X continuous, but there are a bunch of other calculations that are happening internally, so I wouldn't trust it for 4X/5X work without a good review.

First, create a new Format Statement in the Post. (put it below the others)


fs2 30  0.9 0.9   #Format 9 decimal places for Metric Conversion

Then, add these codes,  at the top of your post, starting in the first column:


met_conv : 0.039370078

fmt  ""  30  met_conv

xout = xout * met_conv
yout = yout * met_conv
zout = zout * met_conv
arcrad$ = arcrad$ * met_conv
iout = iout * met_conv
jout = jout * met_conv
kout = kout * met_conv

 

If you're going to multiply then met_conv should be 25.4.

  • Like 1
Link to comment
Share on other sites

Sorry it has taken me some time to get back to this thread....been up to my eyes in alligators the last few days.

 

Colin, thank  you for taking the time to help with this question, and all the threads you share your knowledge on.  

I'm a bit thick headed when it comes to a MC post.  I read your instructions and interpreted them as best I could.  I was not able to get it to work based on my original interpretation.

I made a second attempt by inserting your changes at positions that seemed to make sense to me, as well as changing the variable names until I was able to get the output affected.  I am not getting the correct output still, but at least the numbers are changing.  The problem seems to be that it is applying the multiplier twice.  

In the test program I am using I have a move 1.5" which is being output as Y967.74.    (1.5*25.4=38.1*25.4=967.74)

I will post the position that I have the multiplication functions inserted.  You will also be able to see what other variable names I tried that are now commented out.

 

# --------------------------------------------------------------------------
# Motion NC output
# --------------------------------------------------------------------------
#The variables for absolute output are xabs, yabs, zabs.
#The variables for incremental output are xinc, yinc, zinc.
# --------------------------------------------------------------------------

arcrad$ = arcrad$ * met_conv

#xout = xout * met_conv
#yout = yout * met_conv
#zout = zout * met_conv
#iout = iout * met_conv
#jout = jout * met_conv
#kout = kout * met_conv

#pxout = pxout * met_conv
#pyout = pyout * met_conv
#pzout = pzout * met_conv
#piout = piout * met_conv
#pjout = pjout * met_conv
#pkout = pkout * met_conv


#pfxout = pfxout * met_conv
#pfyout = pfyout * met_conv
#pfzout = pfzout * met_conv
#pfiout = pfiout * met_conv
#pfjout = pfjout * met_conv
#pfkout = pfkout * met_conv

xabs = xabs * met_conv
yabs = yabs * met_conv
zabs = zabs * met_conv
iabs = iabs * met_conv
jabs = jabs * met_conv
kabs = kabs * met_conv

#xinc = xinc * met_conv
#yinc = yinc * met_conv
#zinc = zinc * met_conv
#iinc = iinc * met_conv
#jinc = jinc * met_conv
#kinc = kinc * met_conv
 

Please let me know if you have any other thoughts I can try.

 

Thank you Sir.

Rob

 

Link to comment
Share on other sites

Quick update....I was finally able to get a version that works so far.  I have not completely tested this to ensure it works in all cases though.

 

I inserted the following.  You can see its position as right in front the motion output section. 

x$ =  x$ * met_conv
y$ =  y$ * met_conv
z$ =  z$ * met_conv
      

# --------------------------------------------------------------------------
# Motion NC output
# --------------------------------------------------------------------------

 

I am trying to figure these MC post out, but it is terribly hard without good documentation.  Note to self...call my reseller and get post editing documents.

Colin, please correct me if I am wrong, but it appears as though the XYZ positions are captured from the NCI file via "xnci$...ynci$...znci$"...which in turn stores the value in the "x$...y$...z$" strings.  At least that is what I was banking on.

 

Rob

  • Like 1
Link to comment
Share on other sites
  • 9 months later...
I came across this unresolved thread a few days ago and it helped get me going in the right direction. I was able to eliminate the multiplication from stacking upon itself by transferring the formula statements to a new variable and having the new variable post out in the motion post blocks. I inserted the code below in the 2018 MPMaster post and did not have any issues with the multiplication stacking upon itself. I hope this helps somebody in the future save some time trying to figure this out. 
 
 
# --------------------------------------------------------------------------
# FORMULAS - global formulas
# --------------------------------------------------------------------------
met_conv  : 25.4      # Inch to Metric Conversion Amount
fmt  "" 30  met_conv  # Inch to Metric Conversion Output Format
arcrad$ = arcrad$ * met_conv #Arc/Radius Metric Conversion
iout = iout * met_conv  #X Arc Metric Conversion
jout = jout * met_conv  #Y Arc Metric Conversion
kout = kout * met_conv  #Z Arch Metric Conversion
fr_pos$ = fr_pos$ * met_conv #Feedrate Metric Conversion
 
# --------------------------------------------------------------------------
# Format statements - n=nonmodal, l=leading, t=trailing, i=inc, d=delta
# --------------------------------------------------------------------------
fs2 30  0.9 0.9     #Format 9 decimal places for Metric Conversion
 
# --------------------------------------------------------------------------
# Toolchange / NC output Variable Formats
# --------------------------------------------------------------------------
fmt  "X" 2  xabsmm        #X position output
fmt  "Y" 2  yabsmm        #Y position output
fmt  "Z" 2  zabsmm        #Z position output
fmt  "X" 3  xincmm        #X position output
fmt  "Y" 3  yincmm        #Y position output
fmt  "Z" 3  zincmm        #Z position output
 
# --------------------------------------------------------------------------
# Motion output components
# --------------------------------------------------------------------------
pfxout          #Force X axis output
      xabsmm = xabs * met_conv
      xincmm = xinc * met_conv
      if absinc$ = zero, *xabsmm, !xincmm
      else, *xincmm, !xabsmm
pxout           #X output
      xabsmm = xabs * met_conv
      xincmm = xinc * met_conv
      if absinc$ = zero, xabsmm, !xincmm
      else, xincmm, !xabsmm
pfyout          #Force Y axis output
      yabsmm = yabs * met_conv
      yincmm = yinc * met_conv
      if absinc$ = zero, *yabsmm, !yincmm
      else, *yincmm, !yabsmm
pyout           #Y output
      yabsmm = yabs * met_conv
      yincmm = yinc * met_conv
      if absinc$ = zero, yabsmm, !yincmm
      else, yincmm, !yabsmm
pfzout          #Force Z axis output
      zabsmm = zabs * met_conv
      zincmm = zinc * met_conv
      if absinc$ = zero, *zabsmm, !zincmm
      else, *zincmm, !zabsmm

pzout           #Z output
      zabsmm = zabs * met_conv
      zincmm = zinc * met_conv
      if absinc$ = zero, zabsmm, !zincmm
      else, zincmm, !zabsmm
Link to comment
Share on other sites
16 hours ago, dmaier said:
I came across this unresolved thread a few days ago and it helped get me going in the right direction. I was able to eliminate the multiplication from stacking upon itself by transferring the formula statements to a new variable and having the new variable post out in the motion post blocks. I inserted the code below in the 2018 MPMaster post and did not have any issues with the multiplication stacking upon itself. I hope this helps somebody in the future save some time trying to figure this out. 
 
 
# --------------------------------------------------------------------------
# FORMULAS - global formulas
# --------------------------------------------------------------------------
met_conv  : 25.4      # Inch to Metric Conversion Amount
fmt  "" 30  met_conv  # Inch to Metric Conversion Output Format
arcrad$ = arcrad$ * met_conv #Arc/Radius Metric Conversion
iout = iout * met_conv  #X Arc Metric Conversion
jout = jout * met_conv  #Y Arc Metric Conversion
kout = kout * met_conv  #Z Arch Metric Conversion
fr_pos$ = fr_pos$ * met_conv #Feedrate Metric Conversion
 
# --------------------------------------------------------------------------
# Format statements - n=nonmodal, l=leading, t=trailing, i=inc, d=delta
# --------------------------------------------------------------------------
fs2 30  0.9 0.9     #Format 9 decimal places for Metric Conversion
 
# --------------------------------------------------------------------------
# Toolchange / NC output Variable Formats
# --------------------------------------------------------------------------
fmt  "X" 2  xabsmm        #X position output
fmt  "Y" 2  yabsmm        #Y position output
fmt  "Z" 2  zabsmm        #Z position output
fmt  "X" 3  xincmm        #X position output
fmt  "Y" 3  yincmm        #Y position output
fmt  "Z" 3  zincmm        #Z position output
 
# --------------------------------------------------------------------------
# Motion output components
# --------------------------------------------------------------------------
pfxout          #Force X axis output
      xabsmm = xabs * met_conv
      xincmm = xinc * met_conv
      if absinc$ = zero, *xabsmm, !xincmm
      else, *xincmm, !xabsmm
pxout           #X output
      xabsmm = xabs * met_conv
      xincmm = xinc * met_conv
      if absinc$ = zero, xabsmm, !xincmm
      else, xincmm, !xabsmm
pfyout          #Force Y axis output
      yabsmm = yabs * met_conv
      yincmm = yinc * met_conv
      if absinc$ = zero, *yabsmm, !yincmm
      else, *yincmm, !yabsmm
pyout           #Y output
      yabsmm = yabs * met_conv
      yincmm = yinc * met_conv
      if absinc$ = zero, yabsmm, !yincmm
      else, yincmm, !yabsmm
pfzout          #Force Z axis output
      zabsmm = zabs * met_conv
      zincmm = zinc * met_conv
      if absinc$ = zero, *zabsmm, !zincmm
      else, *zincmm, !zabsmm

pzout           #Z output
      zabsmm = zabs * met_conv
      zincmm = zinc * met_conv
      if absinc$ = zero, zabsmm, !zincmm
      else, zincmm, !zabsmm

If you wanted to be real slick you could add a switch in the post using a mi or mr trigger that would allow you to convert code on the fly with a trigger inside of the posted code and done.

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