Get Help

Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Community
- :
- Creo Parametric
- :
- Part Modeling
- :
- Convert real number in string

Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

09-09-2018
01:51 AM

09-09-2018
01:51 AM

Greatings whole community,

have a simply question: How to convert real number to string, including decimal places? String value **CAN NOT** be rounded.

Example:

d150 = 1.5 (it is real number dimmension)

string_value=1.5

Have found some topics about this, but no simply solution.

l´m trying to use exctract and itos function, but my design strat to be complicated.

Maybe in creo 5.0 has been added some better function or someone was god-lighted up and got an idea for Nobel price

Thanks in any advice...

Regards

Solved! Go to Solution.

Labels:

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

09-10-2018
06:30 AM

09-10-2018
06:30 AM

Relations functions haven't been changed since they were introduced. In my past conversations with PTC their position as been that while complicated you can do nearly everything with the existing relation functions. There are numerous ideas to add additional functions to make things easier but none have been implemented.

If you haven't stumbled on it already you might want to try @TomU's method here:

https://community.ptc.com/t5/Simulation/Converting-Real-Numbers-to-Strings/m-p/189624

He links to some official PTC examples as well.

5 REPLIES 5

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

09-10-2018
06:30 AM

09-10-2018
06:30 AM

Relations functions haven't been changed since they were introduced. In my past conversations with PTC their position as been that while complicated you can do nearly everything with the existing relation functions. There are numerous ideas to add additional functions to make things easier but none have been implemented.

If you haven't stumbled on it already you might want to try @TomU's method here:

https://community.ptc.com/t5/Simulation/Converting-Real-Numbers-to-Strings/m-p/189624

He links to some official PTC examples as well.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

09-10-2018
07:06 AM

09-10-2018
07:06 AM

Re: Convert real number in string

Despite years and years of needing it, a simple "real to string" function has never been added to Pro/E or subsequently, Creo. A bit of programming that has been handled for decades (I even remember doing so in assembly language back in the olden times) is not available.

Anyway, here's my bit of code to approach this.

/* /* Convert a real number into a string. /* numReal = the number to convert /* strResult = the resulting string /* numDigits = integer for how many digits after the decimal you want. /* strResult = ITOS ( floor ( abs ( numReal ) ) ) + "." IF abs( numReal ) < 1.0 strResult = "0." ENDIF strResult = strResult + EXTRACT ( ITOS ( floor ( 10^numDigits * ( 1 + abs ( numReal ) - floor ( abs ( numReal ))))),2,numDigits ) IF numReal < 0.0 strResult = "-" + strResult ENDIF

There are lots of other approaches to this problem. Without a built-in function to do the conversion, you end up with a large amount of relation code if you need to do this for a lot of numbers.

Note that the "rounding avoidance" is done by the "floor" applied to the shifted number before the ITOS function call within the EXTRACT function call. It truncates all the digits after the decimal.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

09-10-2018
07:06 AM

09-10-2018
07:06 AM

Re: Convert real number in string

Hi @Chris3 and @KenFarley

thanks for links, l will study it later.

Wish you both happy day and many thanks to you...

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

09-26-2018
10:10 AM

09-26-2018
10:10 AM

Re: Convert real number in string

Hi @KenFarley

in result l´m using your solution.

Following row is pure logical and mathematical beauty:

strResult = strResult + EXTRACT ( ITOS ( floor ( 10^numDigits * ( 1 + abs ( numReal ) - floor ( abs ( numReal ))))),2,numDigits )

Thanks to pople like you

Have nice day

Regards

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

11-21-2018
04:40 PM

11-21-2018
04:40 PM

Re: Convert real number in string

Hello,

I've requested this option back in 2012, still waiting. You can vote on this and maybe someday we'll see a simple solution from PTC:

https://community.ptc.com/t5/Creo-Parametric-Ideas/Real-to-String-in-Relations/idi-p/465330

Top Tags

- ptcuser_portal
- creo_parametric_proengi…
- creo
- creo_machining_proengin…
- modeling
- creo_simulate_proengine…
- parametric
- renderings
- drawing
- design
- creo_system_administrat…
- rendering
- creo_customization_proe…
- 3d
- pro/engineer
- cad
- proengineer
- material
- arx
- assembly
- library
- parameters
- pro/e
- creo_parametric
- ptc
- sheetmetal
- graphic
- part
- wildfire5
- creo_2.0