converting Number Value to string

converting Number Value to string

Anonymous
Not applicable
5,697 Views
4 Replies
Message 1 of 5

converting Number Value to string

Anonymous
Not applicable

Hello,

 

What's the easiest rule/function for converting the value from a number rule to a string?

 

For example, I have...

 

Rule DoorWidth As Number = 21

 

 

What I would like end up with is an additional rule like this, based off of the DoorWidth value:

 

Rule DoorWidthString As String = "21"

 

I'm just trying to convert a numerical value, evaluated from a rule, to a string.  I know this can be done with :Name rules, by using the MakeString function, but I'm not sure how to change the value of a numerical rule to a string.

 

I imagine I'm missing something obvious.

 

Thanks!

 

Joe

Reply
Reply
0 Likes
Accepted solutions (1)
5,698 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable

Nevermind,

 

It looks like the "StringValue" function is what I was looking for. 

 

Well, now I know 🙂

Reply
Reply
0 Likes
Message 3 of 5

rsimington
Contributor
Contributor
Accepted solution

You can also use format(%d,expression) or format(%g,expression). %d will round a number to an integer, whereas %g will keep it a decimal.

Reply
Reply
0 Likes
Message 4 of 5

Anonymous
Not applicable

Thanks, that could be handy as well!

Reply
Reply
0 Likes
Message 5 of 5

ebachrach
Alumni
Alumni

Hi,

Be aware that stringvalue is not intended to reliably format the output.

 

For that you use the format function which uses C like notation, such as

Intent >format("my number is %g",2.301)
--> "my number is 2.301"
Intent >format("my number is %3.2g",2.301)
--> "my number is 2.3"

 

-- 

Autodesk 

Elly Bachrach 

Manager 

Manufacturing Consulting Services - ETO 

Direct      +1 (847) 676-2880 

elly.bachrach@autodesk.com

format("my number is %3.2g",2.301)

--
Autodesk
Elly Bachrach
ETO/CTO Solutions Designer
Intelligent Configuration Solutions
Mobile +1 (773) 401-6980
elly.bachrach@gmail.com

************************************************************************************
If this post helps, please click the "thumbs up" to give kudos
If this post answers your question, please click "Accept as Solution"
************************************************************************************
Reply
Reply