cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Parameters automation - limitation of typed values

SOLVED
Highlighted
Newbie

Parameters automation - limitation of typed values

Hello everyone.

I am now working on the project for my Creo course and I am using parameters and relations. I have also added an extra option according to which during every regeneration of the model there appears a small window where you can provide the value of each parameter (I did it as follows: Tools > Model Intent > Program > Edit Design). Everything works perfectly, however, I would like to limit the possibility of entering values. I'm going to explain it according to the specific example. Let's go.

I decide at the begining that my model has for example a shape of the rectangle and is extruded at some distance. So, I create three parameter: SIDE1, SIDE2 and EXTRUDE. I'm choosing Tools > ... > Edit Design and in the new window between INPUT - END INPUT I provide each parameter with the proper command (e.g. "Enter the value of side 1" and so on). Now, after each regeneration I can change those values and my model is transformed. Ok, but I would like to limit now the range of each parameter. For instance, I want SIDE1 to be not shorter than 1 and ad the same time not longer than 5, so if someone provides 6 for this parameter there will appear the information "Wrong value. Operate between 1-5".

And my question is: does anyone have any idea how to do this limitation? I expect that it is connected somehow with IF fuction, however, I don't know where exactly should I use it (I expect that in the same window as I introduced parameters to be displayed but I don't know the exact place in this document).

I will be very grateful for your help

PS.: I attach my file. Please explain it according to this one, if you can of course

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Parameters automation - limitation of typed values

Right, don't loop, just keeping asking the same question a pre-determined number of times. 

View solution in original post

9 REPLIES 9

Re: Parameters automation - limitation of typed values

I'm not sure you're going to get exactly what you want.

  • You can use conditional statements in the INPUT section of the program to determine whether or not the user is prompted to enter a value.
  • You can use conditional statements in the RELATIONS section to determine how to handle the value they entered.  Change it to something else, round it, etc.  (Relations editing it better done with the relations editor instead of the program editor.)
  • I don't know of any way to get the system to re-prompt you if the first value entered is not acceptable.  I haven't tried it, but you might be able to simply list the same parameter multiple times in the INPUT section but with different prompts based on the last entered value.

Make sure you read through the Pro/PROGRAM section of the help docs:

http://help.ptc.com/creo_hc/creo30_pma_hc/usascii/#page/pma/fundamentals/Conditional_Input_Statement...

Re: Parameters automation - limitation of typed values

Thank you for your answer I tried to get the system to re-prompt in case of wrong value, unfortunately, it works only partialy. I used IF-ELSE function and "asked" it to check if the value is greater than 5 or smaller than 1 and alert if it is. However, when I checked it and typed wrong values from both sides in the next step I could enter every value. To reach well-working IF-ELSE statement I need to close it in some kind of loop. So I want it to re-prompt until the user provides the proper value. Do you know maybe how can I close the loop in this case?

This is the code I prepared and it works as I've explained above:

SIDE1 NUMBER

"Enter value for side 1 (1-5):"

IF SIDE1>5

     SIDE1 NUMBER

     "Wrong value! Operate in the limit (1-5):"

ELSE

     IF SIDE1<1

         SIDE1 NUMBER

         "Wrong value! Operate in the limit (1-5):"

     ELSE

         SIDE1 NUMBER

         "Confirm the value for side 1 (1-5):"

     END IF

END IF

Re: Parameters automation - limitation of typed values

Would this work?

SIDE1 NUMBER

"Enter value for side 1 (1-5):"

IF SIDE1>5

     SIDE1 = 5

     "Value defaults to 5:"

ELSE

     IF SIDE1<1

         SIDE1 = 1

         "Value defaults to 1:"

     END IF

END IF

Re: Parameters automation - limitation of typed values

Hey, thanks for your answer. Unfortunately, it still does not work. I can provide any value and nothing happens (I mean, there is no limit). The idea was ok and I understand what you have meant by this, however, Creo cannot read this I was searching for some information if there is any possibility to close the IF-ELSE statement as a loop but I didn't find anything helpful. Maybe some of you know how to do this?

Re: Parameters automation - limitation of typed values

Good morning (or afternoon/evening), Marcin,

If I am not mistaken, this is not possible with ProProgram.  Looping is only available through, say, one of the external api's.  There is an ability to limit the parameter values, but I haven't tested that against ProProgram.  The JLink api is very nice for this type of automation.  I presume the vb api as well but, well, I'm not a vb guy so I don't know.  The challenge to using the JLink api (well, any of them) is the use of external files (not optimal).  But given the java part, it can make some very nice, robust interfaces for things like this.

For anyone else, please correct me if I'm wrong.

Re: Parameters automation - limitation of typed values

Hi,

IF SIDE1>5

     SIDE1 = 5

ELSE

     IF SIDE1<1

         SIDE1 = 1

     END IF

END IF

The above sequence has to be defined in Relation dialog box.

I agree with Brian Krieger that you need to develop external program to get requested functionality. I think you can use AutoIt/AutoHotkey software.

MH


Martin Hanák

Re: Parameters automation - limitation of typed values

Okay, it's not pretty but it does work quite well.

INPUT

LENGTH NUMBER

"Please enter the desired length (1-5):"

IF LENGTH < 1 | LENGTH > 5

     LENGTH NUMBER

     "The number entered was not valid.  Please try again (1-5):"

END IF

IF LENGTH < 1 | LENGTH > 5

     LENGTH NUMBER

     "The number entered was not valid.  Please try again (1-5):"

END IF

IF LENGTH < 1 | LENGTH > 5

     LENGTH NUMBER

     "The number entered was not valid.  Please try again (1-5):"

END IF

IF LENGTH < 1 | LENGTH > 5

     VALIDATE YES_NO

     "Really!?!?  It is that hard to enter a number between 1 and 5?"

END IF

END INPUT

What is a little confusing is that the same parameter is listed multiple times in the input selection box.  Fortunately it doesn't matter though, since only the first listing can be selected.

See attached model.  (Creo 3)

Re: Parameters automation - limitation of typed values

Right, don't loop, just keeping asking the same question a pre-determined number of times. 

View solution in original post

Re: Parameters automation - limitation of typed values

Ok people, thank you very much for your help It is really kind of you that your tried to solve this task with me. To sum up all your messages and the whole conversation I think, that the best for my project, and also enough, will be the following option:

INPUT

SIDE1 NUMBER

"Enter value for side 1 (1-5):"

IF SIDE1 < 1 | SIDE1 > 5

     SIDE1 NUMBER

     "Wrong value! Operate in the limit (1-5):"

END IF

IF SIDE1 < 1 | SIDE1 > 5

     SIDE1 NUMBER

     "Wrong value! Operate in the limit (1-5):"

END IF

END INPUT

According to this the user can write wrong values twice (and there will appear the prompt that something is incorrect) until the program accepts it. I know it is not exactly what I was looking for, however, it is enough for my project if I don't use the external software. Once again thank you all very much for your support. It makes my work much easier with your ideas

Announcements