Continue to Site

Welcome to MCAD Central

Join our MCAD Central community forums, the largest resource for MCAD (Mechanical Computer-Aided Design) professionals, including files, forums, jobs, articles, calendar, and more.

Proprogram If statements help!!

omarhernandez

New member
I am having a hard time believing that proprogram will not let you execute an if statement inside of an execute command.


I'm trying to execute dimension from an assy to a subassy. If there is anyone that could help me it would be greatly appreciated.Here's the if statement...


EXECUTE ASSEMBLY 045_PEA3
PASS_VAR_DOWN = PASS_VAR_DOWN


IF PASS_VAR_DOWN == YES
ANVIL_SPACER_BLOCK = ANVIL_SPACER_BLOCK
PUNCH_EXT_BACKUP_BLOCK = PUNCH_EXT_BACKUP_BLOCK
A_PEA3 = A_PEA3
B_PEA3 = B_PEA3
C_PEA3 = C_PEA3
D_PEA3 = D_PEA3
ENDIF


END EXECUTE


P.S. - I didn't have any empty lines in the program, I just posted It this way to make it easier to debug for myself.


Omar
 
hi omar,


What happens?


does the relation editor give an error or does the execute fail?


suggestion:-


I recently had some strange results with a long if statement.


What worked was to breakit up into stages:-


EXECUTE ASSEMBLY 045_PEA3
PASS_VAR_DOWN = PASS_VAR_DOWN


IF PASS_VAR_DOWN == YES



ANVIL_SPACER_BLOCK = ANVIL_SPACER_BLOCK


endif


IF PASS_VAR_DOWN == YES

PUNCH_EXT_BACKUP_BLOCK = PUNCH_EXT_BACKUP_BLOCK


endif


IF PASS_VAR_DOWN == YES

A_PEA3 = A_PEA3


endif


IF PASS_VAR_DOWN == YES

B_PEA3 = B_PEA3


endif


IF PASS_VAR_DOWN == YES

C_PEA3 = C_PEA3


endif


IF PASS_VAR_DOWN == YES

D_PEA3 = D_PEA3



ENDIF


END EXECUTE





This (strangely) worked for my relation file, but it didnt have the execute around it.


I have no explanation as to why it behaves differently apart from it does!


BTW, the second and third lines are a little unclear to me too:-


$2nd$PASS_VAR_DOWN = PASS_VAR_DOWN


$3rd$IF PASS_VAR_DOWN == YES


if PASS_VAR_DOWN = PASS_VAR_DOWN


then IF PASS_VAR_DOWN (does not) == YES


Regards


Jbuckl
Edited by: jbuckl
 
Thank for responding julian,


When I close the .als file to verify pro program, pro/e asks me if I want to abort or edit the file because on an error. I don't know if you know what an execute stament is, but I'm going to post it anyway for other members. An execute statement allow you to pass variables down. In my overall assy (n74_machine_assy), I have a sub assy (045_PEA assy), which contain one more subassy (045_assy). They all have a variable called pass_var_down.


I want those three var to have the same value. I could execute one statment in relations (pass_var_down = pass_var_down),and just use the component ID or session id, but those Id tend to change constantly therefor my realtions would be invalid.


Btw, julian, I am going to try your suggestion and see how it goes. I keep you updated. Thanks one again for your help!!


Omar
 
Forgot to answer your third question julian,


Pass_var_down = Pass_var_down. Proe always uses the variable on the left as the sub assembly and the one on the right of the assembly containing the sub assy. The If statement IF pass_var_down is == Yes .... Execute component..... I want the, which means if pass_var_down == yes all of the parameters/dimensions (variables) will be passed down from one assembly to another. If some doesn't want to pass the var done the just change the yes to a no.


Omar
 
I tried the statment you posted, but It didn't work. I just think that proe wasn't program to allow if statment inside of proe. If i change some wording and put the if statment outside of the execute problem it works, but it doesn't solve me problem.


Omar
 
Sorry guys,


I learned from pro program from just experimenting. If you know how to do relations you should be ok with pro program.


Omar
 
Using WF 2.0 I get anerror messages when I put an if statement insidethe execute statement. The great thing about using execute in ProProgram is that if all variables are passed down then only one regeneration click (for the top assembly)is required. By introducing an if statement, you loose this benefit. The parts/subassemblies whose variablesare NOT passed down require their own regeneration click.


Since writing TWO execute statements for the same part is not allowed, the following code should do what you want:


IF PASS_VAR_DOWN == YES
EXECUTE PARTWHEEL
PASS_VAR_DOWN = PASS_VAR_DOWN
VAR1 = VAR1
VAR2 = VAR2
END EXECUTE


ELSE
EXECUTE PARTWHEEL
PASS_VAR_DOWN = PASS_VAR_DOWN
END EXECUTE
END IF
 
Russell,


Great way to get around the two execute staments!!!!
smiley32.gif
Thanks for responding, I though all hope was lost. The way I was now doing it was by component id + variable in relations. I tried the statement you posted, but I get an error message once I did the show design.


IF PASS_VAR_DOWN == YES
EXECUTE ASSEMBLY 045_PEA3
PASS_VAR_DOWN = PASS_VAR_DOWN
!*** WARNG: invalid input variable in assignment
ANVIL_SPACER_BLOCK = ANVIL_SPACER_BLOCK
PUNCH_EXT_BACKUP_BLOCK = PUNCH_EXT_BACKUP_BLOCK
A_PEA3 = A_PEA3
B_PEA3 = B_PEA3
C_PEA3 = C_PEA3
D_PEA3 = D_PEA3
END EXECUTE


ELSE
EXECUTE ASSEMBLY 045_PEA3
PASS_VAR_DOWN = PASS_VAR_DOWN
!*** WARNG: invalid input variable in assignment
END EXECUTE
END IF


Btw, thank for taking the time to help me out. Now I've just go to figure out why pro/e is posting that error message. I'll keep you updated.


Omar


WF2
 
The reason I kept getting an error message was because I deleted the input for pass_var_down and it was only a parameter. Once I put I back in the input section, the error was resolved. (kind of)


Russell,


Did you see any statement saying "Design contains warning." after you closed the notepad file or did a renenaration at the bottom leftside of your monitor?


Omar
 
I added a sub assembly to my test assembly and found no error messages in my EXECUTE statement. Your code looks good so it must be the variables. It looks like you may beassigning a number to a YES_NO variable which would give you that kindof error.Be sure that PASS_VAR_DOWN exists AND is a YES_NO type parameter in all assemblies and parts.


It's easy to forget to declare the variable YES_NO since Pro will default your variable to NUMBER (I think). Since you don't get a reminder when you create the variable, you get an error when you go to use it.


I hope that the problem is easy for you to find.
 
Nevermind
smiley24.gif
,


The problem was that I forgot to fix some relation in proprogram in sub assy inside the subassy I was executeing. Thanks once again to Russell and Julian for hepling me.


Omar
 
Yes I did get "Design contains warning" message but I didn't investigate. I think Pro may be seeing the two EXECUTE statements and bitting its fingernails
smiley2.gif
 
Omar


Just make sure you don't have anymore execute command inside of the subassy your executing. That's what was wrong with mine. My assy no longer states that error message.


Omar
 

Sponsor

Back
Top