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.

Please help with Pro/Program & Relations Coding

c_bellamy

New member
Hello everyone, I am relatively new to using the pro/program within Creo assemblies and I have having a lot of trouble to accomplish what I feel is a simple task. Below is what I have written in the input & relations sections of the upper level assembly Pro/Program.

INPUT
DEFAULT_LOCATIONS YES_NO
"Place all components in locations used for MPIs (ANSWER YES BEFORE SAVING!)?"
IF DEFAULT_MPI_LOCATIONS = YES
GANTRY_X_DISTANCE:3 = 757.2552
CAMERA_Y_DISTANCE:269 = 350.000
Z_HEIGHT:273 = 313

ELSE
GANTRY_X_DISTANCE:3 NUMBER
"Enter Gantry X-Direction [mm]"
CAMERA_Y_DISTANCE:269 NUMBER
"Enter Camera Y-Direction [mm]"
Z_HEIGHT:273 NUMBER
"Enter the Camera Z-Height [mm]"
END IF
END INPUT

I am wanting the following to take place: When the assembly is regenerated and I click “Select All” from the “Input Selection Menu Manager” A prompt will come up asking the yes or no question: “Place all components in locations used for MPIs (ANSWER YES BEFORE SAVING!)?”. If I select “Yes”, I want the following variables (dimensions) to have the values as shown:
GANTRY_X_DISTANCE:3 = 757.2552
CAMERA_Y_DISTANCE:269 = 350.000
Z_HEIGHT:273 = 313

If I select No, I want to be able to enter the dimension value for the three variables listed above. This seems very straight forward, but when I run the code as shown above and answer YES to the “DEFAULT_MPI_LOCATIONS” question, it WILL NOT assign the values as the coding says it should. After doing this, when I go back and look at the Pro/Program coding, Everything I have shown in red text above disappears from the pro/program coding. When I regenerate and answer NO to the “DEFAULT_MPI_LOCATIONS” question, I can enter the variable (dimension) values individually, as intended.

I have tried playing with the “MODIFY” command, I have tried using different variables to assign the default location values, and have tried defining the default location values in the “Relations” section of the coding with no luck.

Can someone please help me find a way for the three variable to have an assigned value when the DEFAULT_MPI_LOCATIONS = YES, and be able to input the values when DEFAULT_MPI_LOCATIONS = NO???

Thank you all for your time and for your replies.
-Cameron
 
I believe that you can't have that section in the input section.

Try putting the following as the first section of the relations, note the double = in the if statement (required in relations)

IF DEFAULT_MPI_LOCATIONS == YES
GANTRY_X_DISTANCE:3 = 757.2552
CAMERA_Y_DISTANCE:269 = 350.000
Z_HEIGHT:273 = 313
ENDIF

If you have already tried that, I would recommend removing the INPUTS and creating a parameter for each input, and use the description in the parameters page to note what the default lengths are, and have those parameters drive the dimensions.
 
Thank you for the reply. I tried your first suggestion and entered it exactly as you have written. Here is the code I saved in Pro/Program:
INPUT
DEFAULT_MPI_LOCATIONS YES_NO
"Place all components in locations used for MPIs (ANSWER YES BEFORE SAVING!)?"
IF DEFAULT_MPI_LOCATIONS == YES
GANTRY_X_DISTANCE:3 = 757.2552
CAMERA_Y_DISTANCE:269 = 350.000
Z_HEIGHT:273 = 313
ELSE
GANTRY_X_DISTANCE:3 NUMBER
"Enter Gantry X-Direction [mm]"
CAMERA_Y_DISTANCE:269 NUMBER
"Enter Camera Y-Direction [mm]"
Z_HEIGHT:273 NUMBER
"Enter the Camera Z-Height [mm]"
END IF
END INPUT

When I regenerate the model and run the code, Creo automatically changes the code to the following (differences shown in blue):
INPUT
DEFAULT_MPI_LOCATIONS YES_NO
"Place all components in locations used for MPIs (ANSWER YES BEFORE SAVING!)?"
IF DEFAULT_MPI_LOCATIONS == YES
GANTRY_X_DISTANCE:3 NUMBER
CAMERA_Y_DISTANCE:269 NUMBER
Z_HEIGHT:273 NUMBER
ELSE
GANTRY_X_DISTANCE:3 NUMBER
"Enter Gantry X-Direction [mm]"
CAMERA_Y_DISTANCE:269 NUMBER
"Enter Camera Y-Direction [mm]"
Z_HEIGHT:273 NUMBER
"Enter the Camera Z-Height [mm]"
END IF
END INPUT

This code asks me to input the values for the three variables wheather I answer YES or NO to the "DEFAULT_MPI_LOCATIONS" question. I will play around with you second suggestion and see if I can get anywhere. Thank you again, and please let me know if you have any other suggestions.
 
Just wanting to post that I was able to finally come up with some coding that worked! I discovered that my main problem with due to haveing a space inbetween "END IF", where it should have been written "ENDIF" (Especially when writing an IF statement in the Relations section). I also could not figure out why I could not get IF statements to work in the relations section, and I found that they need to be written in a slightly different format! Below is a compy of the code I used that finally accomplished what I was wanting:

INPUT
DEFAULT_MPI_LOCATIONS YES_NO
"Place all components in locations used for MPIs (ANSWER YES BEFORE SAVING!)?"
IF DEFAULT_MPI_LOCATIONS == NO
GANTRY_X_DISTANCE:3 NUMBER
"Enter Gantry X-Direction [mm]"
CAMERA_Y_DISTANCE:269 NUMBER
"Enter Camera Y-Direction [mm]"
Z_HEIGHT:273 NUMBER
"Enter the Camera Z-Height [mm]"
END IF
END INPUT

RELATIONS
IF(DEFAULT_MPI_LOCATIONS==YES)
GANTRY_X_DISTANCE:3 = 757.2552
CAMERA_Y_DISTANCE:269 = 350.000
Z_HEIGHT:273 = 313
ENDIF
END RELATIONS

Thank you for your help.
 

Sponsor

Articles From 3DCAD World

Back
Top