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

Real to String in Relations

Real to String in Relations

I would like to have a Real to String function in relations. Our company standard defines the display of the dimensions of a part as a string parameter in our BOM;

T=6.35 100x500

In order to get this currently I have to write a very complex relation to extract the values from the models;

    

IF MODEL_THICKNESS < 10

TK=ITOS(MODEL_THICKNESS*100)

DIMENSION="T= "+ EXTRACT(TK,1,1) + "." + EXTRACT(TK,2,2) + " X " + ITOS(MODEL_WIDTH) + " X " + ITOS(MODEL_LENGTH)

ENDIF

IF MODEL_THICKNESS >= 10

TK = ITOS(MODEL_THICKNESS*100)

DIMENSION="T= "+ EXTRACT(TK,1,2) + "." + EXTRACT(TK,3,2) + " X " + ITOS(MODEL_WIDTH) + " X " + ITOS(MODEL_LENGTH)

ENDIF

Luckily we display our dimensions in mm, so I only have to support the imperial thickness of the materials.

9 Comments
Aquamarine

Same problem here. Too many lines of relations to get the same result.

Gravel

Rtos function would be a huge timesaver for starters.

Moonstone

We developed a "real to string" function for relations with Pro/TOOLKIT.

Only some 10 or 20 lines of code were necessary to realize this.

@ PTC: It's so easy, why we're still waiting for that?!

Regular Member

Not sure why we're waiting, as you said this should be a very simple request. I opened a request for this back in.... I would say 2004. It seems things have changed from their side, I don't see it in the SPR anymore.

Visitor

We ended up using JLink to create our real to string function.

Contributor

We are in the same case

We use relation:

     rtos_param=itos(floor(param))+"."+extract(itos((1+(param-floor(param)))*10000),2,3)

if param=2.05 rtos_param returns 2.050

for 4 digits after comma, use

     rtos_param=itos(floor(param))+"."+extract(itos((1+(param-floor(param)))*10000),2,4)

if param=2.05 rtos_param returns 2.0500

...

Emerald I

Here is my three decimal place version.  This includes automatic rounding.  X is the real number and Y is the string.

/* String Output - No Leading Zero, Three Decimal Places

Y = ITOS(FLOOR(X+.0005))+"."+EXTRACT(ITOS(((FLOOR((X+.0005),3))-FLOOR(FLOOR((X+.0005),3))+1)*1000),2,3)

Other versions are available here: Converting Real Numbers to Strings

Amethyst

Wow.  Still shaking my head about this one.

Keep voting Does PTC ever read these?

Community Manager
Status changed to: Acknowledged