srAndritz
Mechanical
- Sep 15, 2015
- 8
I want to itterate the value of one expression (measurement) with input from another expression (length)
The first expression is directly relatetd to the second one.
I want to start with a value (say 2000) for the second expression (exp2), the first expression (exp1) is then 414.8119359.... (measured value)
I want to be able to set a value for instance 450.00 as a target value and a step value, for instance 10.
I want the code to function something like this:
If exp1 < target
then exp2 = exp2-step
Else end if
'loop this while exp1 < target
step = step/2
'smaller itteration steps as exp1 gets closer to target value
If exp1 > target
then exp2 = exp2+step
Else end if
and then i want to loop this over and over until exp1 reaches target value with at least 2 decimals precision.
I intend to build on this with excel imports and exports of values , i think i can handle that part but i really need some help with the itteration part.
I attached a simple partfile to further show how i want i to function.
I work in NX10 even though the part file is from NX8. I have no code to start from really and i don't expect a ready to go script in return but something to get me started
The first expression is directly relatetd to the second one.
I want to start with a value (say 2000) for the second expression (exp2), the first expression (exp1) is then 414.8119359.... (measured value)
I want to be able to set a value for instance 450.00 as a target value and a step value, for instance 10.
I want the code to function something like this:
If exp1 < target
then exp2 = exp2-step
Else end if
'loop this while exp1 < target
step = step/2
'smaller itteration steps as exp1 gets closer to target value
If exp1 > target
then exp2 = exp2+step
Else end if
and then i want to loop this over and over until exp1 reaches target value with at least 2 decimals precision.
I intend to build on this with excel imports and exports of values , i think i can handle that part but i really need some help with the itteration part.
I attached a simple partfile to further show how i want i to function.
I work in NX10 even though the part file is from NX8. I have no code to start from really and i don't expect a ready to go script in return but something to get me started