Turn on suggestions

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

Showing results for

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

Showing results for

** Community Tip** - Want the oppurtunity to discuss enhancements to PTC products? Join a working group!
X

- Community
- Creo+ and Creo Parametric
- 3D Part & Assembly Design
- How to adjust decimal places in a parameter

Options

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

Jun 30, 2017
07:54 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Jun 30, 2017
07:54 AM

How to adjust decimal places in a parameter

The 0.015000 radius comes from a parameter. How do I adjust this so that it has fewer decimal places. I can't type anything else in the &MIN_RADIUS box (such as [.3]), and if I enter text manually it doesn't recognize that I'm trying to pull a parameter.

Solved! Go to Solution.

1 ACCEPTED SOLUTION

Accepted Solutions

Jun 30, 2017
10:41 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Jun 30, 2017
10:41 AM

Yes, the problem is that your parameter is of type "Real Number", and the sketch text tool works better when displaying parameters of type "String".

And "converting" real numbers into strings in Creo is possible but difficult because PTC never provided the "RTOS" (Real to String) function. They do give you the "ITOS" (integer to string) function, which can be manipulated to give you what you the result you want but you will have to write relations to do it. Maybe you can find them on this new forum by searching for "RTOS".

This is one that works well for me:

RN = FLOOR((MIN_RADIUS+(5/10^(DEC_PLACES+1))),DEC_PLACES) IF FLOOR(RN) == 0 MIN_RAD_STRING = "0."+EXTRACT(ITOS((RN-FLOOR(RN)+1)*10^(DEC_PLACES)),2,DEC_PLACES) ELSE MIN_RAD_STRING = ITOS(FLOOR(RN))+"."+EXTRACT(ITOS((RN-FLOOR(RN)+1)*10^(DEC_PLACES)),2,DEC_PLACES) ENDIF

Note:

MIN_RADIUS = the parameter that is of type REAL NUMBER

MIN_RAD_STRING = parameter of type STRING that is the rounded number

DEC_PLACES = parameter of type INTEGER which value specifies the # of decimal places in the produced MIN_RAD_STRING

6 REPLIES 6

Jun 30, 2017
10:41 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Jun 30, 2017
10:41 AM

Yes, the problem is that your parameter is of type "Real Number", and the sketch text tool works better when displaying parameters of type "String".

And "converting" real numbers into strings in Creo is possible but difficult because PTC never provided the "RTOS" (Real to String) function. They do give you the "ITOS" (integer to string) function, which can be manipulated to give you what you the result you want but you will have to write relations to do it. Maybe you can find them on this new forum by searching for "RTOS".

This is one that works well for me:

RN = FLOOR((MIN_RADIUS+(5/10^(DEC_PLACES+1))),DEC_PLACES) IF FLOOR(RN) == 0 MIN_RAD_STRING = "0."+EXTRACT(ITOS((RN-FLOOR(RN)+1)*10^(DEC_PLACES)),2,DEC_PLACES) ELSE MIN_RAD_STRING = ITOS(FLOOR(RN))+"."+EXTRACT(ITOS((RN-FLOOR(RN)+1)*10^(DEC_PLACES)),2,DEC_PLACES) ENDIF

Note:

MIN_RADIUS = the parameter that is of type REAL NUMBER

MIN_RAD_STRING = parameter of type STRING that is the rounded number

DEC_PLACES = parameter of type INTEGER which value specifies the # of decimal places in the produced MIN_RAD_STRING

Sep 08, 2020
04:39 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Sep 08, 2020
04:39 AM

Hi psobejko,

So i found that a simplified version of your method still works:

instead of

EXTRACT(ITOS((RN-FLOOR(RN)+1)*10^(DEC_PLACES)),2,DEC_PLACES)

you could just use

ITOS((RN-FLOOR(RN))*10^(DEC_PLACES))

the syntax would than be:

RN = FLOOR((MIN_RADIUS+(5/10^(DEC_PLACES+1))),DEC_PLACES) IF FLOOR(RN) == 0 MIN_RAD_STRING = "0."+ITOS((RN-FLOOR(RN))*10^(DEC_PLACES)) ELSE MIN_RAD_STRING = ITOS(FLOOR(RN))+"."+ITOS((RN-FLOOR(RN))*10^(DEC_PLACES)) ENDIF

The EXTRACT function just extracted the values behind the comma (AKA decimals) as a string, which is what ITOS ((RN-FLOOR(RN))*10^(DEC_PLACES)) will do also.

For EXAMPLE:

RN=2,594956

DEC_PLACES=2

RN-FLOOR(RN) equals a real number with only decimals: 0,594956

Multiplying that number by 10^(DEC_PLACES) will give you a real number with x=(DEC_PLACES) decimals "promoted" to whole numbers: 59,4956

Using ITOS will extract only the WHOLE numbers, which is what we want:

ITOS(RN-FLOOR(RN)*10^(DEC_PLACES))=59

Jun 30, 2017
11:32 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Jun 30, 2017
11:32 AM

I've used relations to do this also, but sometimes the number I want is a negative number, making the floor function provide unexpected results ( floor ( -5.1 ) = -6, etc). The code I need to use is more complicated to handle this possibility. Also, I've noticed that ITOS rounds the value it is using, for example ITOS ( 12.6 ) = "13", so I don't need to "adjust" the integer I'm converting to get a rounded value.

--- Variables ---

realnum : the real number that will be represented by the string

stringer : the resultant string

numplaces : the number of decimal places in the final result

--- Relations Code ---

if realnum < 0

stringer = "-" + ITOS ( floor ( ABS ( realnum ) ) )

else

stringer = ITOS ( floor ( realnum ) )

endif

stringer = stringer + "."

stringer = stringer + EXTRACT ( ITOS ( 10^numplaces * ( 1 + ABS ( realnum ) - floor ( ABS ( realnum ) ) ) ), 2, numplaces )

Kind of fun if you're doing this for one number, but this stuff gets tedious if you have a lot of numbers you want to use in notes and such.

Jul 05, 2017
04:38 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Jul 05, 2017
04:38 PM

I want to do the same... except the parameter is in the weld symbol. 45.000**° What I want is 45° Ill mess around w/ your relations techniqe. I like it BTW but those darn SW users are guna laugh. **

Bart Brejcha

Jul 07, 2017
08:14 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Jul 07, 2017
08:14 AM

Annotate>Format>Decimal Places enter number of decimal places and select the parameter. You might have to click 2 or 3 times to select the parameter.

As displayed in drawing after changing decimal places:

Aug 16, 2018
03:55 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Aug 16, 2018
03:55 PM

I noticed that there is a quick way to change/add decimal places in a real number parameter by using text "&PARAMETER[.3]" in the drawing. The number in brackets is the number of decimal places you get (in this case, 3). If you need only 1 decimal place, for instance, just replace the .3 in the brackets with .1.

-Jessica Hadfield