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:

Loigical "if" operator


Leandro
 Share

Recommended Posts

Leandro,

 

What are these variables

 

dir_rosca_neg

dir_rosca_pos

 

 

and are they formatted and set with a value properly.

 

BTW there should be a else, dir_rosca_pos

You're missing the comma on that line

 

What is it you are trying to accomplish?

Link to comment
Share on other sites

Jhon this is almost the complete code

 

fmt X 2 x_ini_rosca #Diametro inicial de la rosca

fmt Z 2 z_ini_rosca #Z inicial de la rosca

fmt Q 2 x_fin_rosca #Diametro final de la rosca

fmt R 2 z_fin_rosca #Z final de la rosca

fmt B 2 ap_rosca #Profundidad de pasada

fmt E 2 ap_min_rosca #Profundidad minima de pasada

fmt D 2 dist_seg_rosca #Distancia de seguridad en la rosca

fmt L 2 dem_acab_rosca #Demasía de acabado de la rosca

fmt J 2 z_salida_rosca #anticipo de salida de rosca

fmt C 2 paso_rosca #Paso para rosca en G86

fmt I 2 prof_rosca #profundidad de la rosca G86

 

 

dir_rosca_neg

z_ini_rosca = thdz1$ + thdzclr$

 

dir_rosca_pos

z_ini_rosca = thdz1$ - thdzclr$

 

pg76$ #G76 threading

comment$

gcode$ = zero

lrapid$

x_ini_rosca = thdx1$ * 2

if thdz1$ > thdz2$, dir_rosca_neg

else, dir_rosca_pos

z_fin_rosca = thdz2$

ap_min_rosca = thdlast$ * 2

dist_seg_rosca = thdxclr$

dem_acab_rosca = thdlast$

z_salida_rosca = thdpulloff$

 

if thdface$ = zero, copy_x = thdx2$

else, copy_z = thdx2$

if thdface$ = zero, copy_z = thdz2$

else, copy_x = thdz2$

pcom_moveb

nstart_cnt = zero

while nstart_cnt < nstarts$, pg76nstart

pcom_movea

prv_gcode$ = -1

 

 

pcom_moveb

pe_inc_calc

!gcode$, !xabs, !yabs, !zabs, !xinc, !yinc, !zinc

 

 

z_ini_rosca is formatted.

 

Did I need to declare dir_rosca_neg and dir_rosca_pos too??

 

Thanks in advanced

 

Leandro

Link to comment
Share on other sites

I think you might need to try it like this.

 

The current way you have it set up, I don't believe you can call the function that way.

 

You could set them up as a post block but you would have to rename your calls to

 

pdir_rosca_neg

pdir_rosca_pos

 

 

Then you could call them

 

code:

if thdz1$ > thdz2$, pdir_rosca_neg

else, pdir_rosca_pos

Where you would then define then variables values

 

code:

pdir_rosca_neg

z_ini_rosca = thdz1$ + thdzclr$

 

pdir_rosca_pos

z_ini_rosca = thdz1$ - thdzclr$

Link to comment
Share on other sites

Lendro, John is trying to explain you what is supposed to happen with these variables after the conditional check:

 

I mean:

 

if thdz1$ > thdz2$, dir_rosca_neg = 1 (or a value that you wish to assign to the variable)

else dir_rosca_pos = 0 (same idea)

 

If you want to create a jump for a specific post section that you created to handle the code that you want to output, then you can make your variables become postblocks, something like that: (By the way, in order to make your variables becomes postblocks, you must add a p character in front of their name:

 

pdir_rosca_neg

 

pdir_rosca_pos

 

A sample:

 

.......

 

if thdz1$ > thdz2$, pdir_rosca_neg

else, pdir_rosca_pos

 

pdir_rosca_pos

 

n, "Faz a rosca positiva", e$

n, "Fim da postblock", e$

 

pdir_rosca_neg

 

n, "Faz a rosca negativa", e$

n, "Fim da postblock", e$

 

.......

 

Espero que ajude.

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