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

Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X

Business needs X, Y, Z parameters in Real Number data type from Model Check OVERALL_SIZE value

BikrantS
7-Bedrock

Business needs X, Y, Z parameters in Real Number data type from Model Check OVERALL_SIZE value

Hi All,

 

We were able to extract the X , Y and Z from the OVERALL_SIZE parameter values using relations. However, the extracted parameters are String Type, but we need them as Real Number data Type.

 

Please could you suggest on how to extract the X , Y and Z Parameters as Real Number Type.

 

Thanks

 

 

 

1 REPLY 1

Regrettably, the string to number or number to string functions available in Creo relations consist of ITOS() which converts a number into an integer string. Not very useful, I know. And it doesn't handle zero values properly.

If you already have a number in a string and the format is consistent, you might want to consider developing further relations to parse the string and "build" a numerical value. Simply stated, it'd be something like:

(1) Extract the part of the number before the decimal point.

(2) Process each digit of that to build the integer part of the real number.

     value = ( rightmost digit ) * 1

     value = value + ( 2nd digit from right ) * 10

     value = value * ( 3rd digit from right ) * 100

     .... etc.

(3) Extract part of the number after the decimal point.

(4) Process each digit of that to build the decimal part of the real number

     value = value + ( leftmost digit ) * 0.1

      value = value + ( 2nd digit from left ) * 0.01

      ... etc.

 

Not an elegant thing to do, and you need to be very careful about number formats (for example, does the number have a leading zero?).

If Creo had looping capabilities, this would be pretty easy, but it doesn't, so it'll be a lot of nested IF statements for sure.

Announcements
NEW Creo+ Topics: Real-time Collaboration


Top Tags